@@ -18,6 +18,7 @@
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
+#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/gpio_keys.h>
@@ -494,23 +495,13 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
spin_lock_init(&bdata->lock);
if (child) {
- bdata->gpiod = devm_fwnode_gpiod_get(dev, child,
- 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;
- }
- }
+ /*
+ * GPIO is optional, we may be dealing with purely
+ * interrupt-driven setup.
+ */
+ bdata->gpiod = devm_fwnode_gpiod_get_optional(dev, child, NULL, GPIOD_IN, desc);
+ if (IS_ERR(bdata->gpiod))
+ return dev_err_probe(dev, PTR_ERR(bdata->gpiod), "failed to get gpio\n");
} else if (gpio_is_valid(button->gpio)) {
/*
* Legacy GPIO number, so request the GPIO here and