Input: gpio-keys - convert to dev_err_probe()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 17 Jul 2023 15:50:36 +0000 (08:50 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 17 Jul 2023 17:03:08 +0000 (10:03 -0700)
Use the dev_err_probe() helper, instead of open-coding the same
operation.

While at it, invert the error checking logic to simplify code flow.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/d225a837c50e2b19a41555a8f7ce0f94b1689aa4.1689600353.git.geert+renesas@glider.be
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/gpio_keys.c

index c928829..2e7c2c0 100644 (file)
@@ -523,18 +523,15 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
                                                     NULL, GPIOD_IN, desc);
                if (IS_ERR(bdata->gpiod)) {
                        error = PTR_ERR(bdata->gpiod);
-                       if (error == -ENOENT) {
-                               /*
-                                * GPIO is optional, we may be dealing with
-                                * purely interrupt-driven setup.
-                                */
-                               bdata->gpiod = NULL;
-                       } else {
-                               if (error != -EPROBE_DEFER)
-                                       dev_err(dev, "failed to get gpio: %d\n",
-                                               error);
-                               return error;
-                       }
+                       if (error != -ENOENT)
+                               return dev_err_probe(dev, error,
+                                                    "failed to get gpio\n");
+
+                       /*
+                        * GPIO is optional, we may be dealing with
+                        * purely interrupt-driven setup.
+                        */
+                       bdata->gpiod = NULL;
                }
        } else if (gpio_is_valid(button->gpio)) {
                /*