Skip to content

Commit

Permalink
Input: surface3_spi - simplify with dev_err_probe()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Krzysztof Kozlowski authored and Dmitry Torokhov committed Jul 7, 2023
1 parent d3aeb44 commit d08149c
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions drivers/input/touchscreen/surface3_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ static void surface3_spi_power(struct surface3_ts_data *data, bool on)
*/
static int surface3_spi_get_gpio_config(struct surface3_ts_data *data)
{
int error;
struct device *dev;
struct gpio_desc *gpiod;
int i;
Expand All @@ -231,15 +230,9 @@ static int surface3_spi_get_gpio_config(struct surface3_ts_data *data)
/* Get the reset lines GPIO pin number */
for (i = 0; i < 2; i++) {
gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_OUT_LOW);
if (IS_ERR(gpiod)) {
error = PTR_ERR(gpiod);
if (error != -EPROBE_DEFER)
dev_err(dev,
"Failed to get power GPIO %d: %d\n",
i,
error);
return error;
}
if (IS_ERR(gpiod))
return dev_err_probe(dev, PTR_ERR(gpiod),
"Failed to get power GPIO %d\n", i);

data->gpiod_rst[i] = gpiod;
}
Expand Down

0 comments on commit d08149c

Please sign in to comment.