Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: surface3_spi - simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230625162817.100397-21-krzysztof.kozlowski@linaro.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Krzysztof Kozlowski and committed by
Dmitry Torokhov
d08149c1 d3aeb44c

+3 -10
+3 -10
drivers/input/touchscreen/surface3_spi.c
··· 221 221 */ 222 222 static int surface3_spi_get_gpio_config(struct surface3_ts_data *data) 223 223 { 224 - int error; 225 224 struct device *dev; 226 225 struct gpio_desc *gpiod; 227 226 int i; ··· 230 231 /* Get the reset lines GPIO pin number */ 231 232 for (i = 0; i < 2; i++) { 232 233 gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_OUT_LOW); 233 - if (IS_ERR(gpiod)) { 234 - error = PTR_ERR(gpiod); 235 - if (error != -EPROBE_DEFER) 236 - dev_err(dev, 237 - "Failed to get power GPIO %d: %d\n", 238 - i, 239 - error); 240 - return error; 241 - } 234 + if (IS_ERR(gpiod)) 235 + return dev_err_probe(dev, PTR_ERR(gpiod), 236 + "Failed to get power GPIO %d\n", i); 242 237 243 238 data->gpiod_rst[i] = gpiod; 244 239 }