summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib-devres.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2020-10-21 16:25:28 +0200
committerBartosz Golaszewski <bgolaszewski@baylibre.com>2020-10-26 15:23:33 +0100
commit7b58696d9a8415576317615c63e9899797026f17 (patch)
treee941387d6206474b9086abfff4b0456d0300ef7c /drivers/gpio/gpiolib-devres.c
parentLinux 5.10-rc1 (diff)
downloadlinux-7b58696d9a8415576317615c63e9899797026f17.tar.xz
linux-7b58696d9a8415576317615c63e9899797026f17.zip
gpiolib: Extract gpiod_not_found() helper
Several places in the code are using same idiom, i.e. IS_ERR(desc) && PTR_ERR(desc) == -ENOENT which meaning is GPIO description is not found. For better readability extract gpiod_not_found() helper and use it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Diffstat (limited to 'drivers/gpio/gpiolib-devres.c')
-rw-r--r--drivers/gpio/gpiolib-devres.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c
index 7dbce4c4ebdf..174f88d5ec17 100644
--- a/drivers/gpio/gpiolib-devres.c
+++ b/drivers/gpio/gpiolib-devres.c
@@ -246,10 +246,8 @@ struct gpio_desc *__must_check devm_gpiod_get_index_optional(struct device *dev,
struct gpio_desc *desc;
desc = devm_gpiod_get_index(dev, con_id, index, flags);
- if (IS_ERR(desc)) {
- if (PTR_ERR(desc) == -ENOENT)
- return NULL;
- }
+ if (gpiod_not_found(desc))
+ return NULL;
return desc;
}
@@ -308,7 +306,7 @@ devm_gpiod_get_array_optional(struct device *dev, const char *con_id,
struct gpio_descs *descs;
descs = devm_gpiod_get_array(dev, con_id, flags);
- if (PTR_ERR(descs) == -ENOENT)
+ if (gpiod_not_found(descs))
return NULL;
return descs;