gpiolib: Extract gpiod_not_found() helper
[sfrench/cifs-2.6.git] / drivers / gpio / gpiolib.c
index 3cdf9effc13a5f2332120028ce19db2924cfa491..42fd6f3d6191fd2965978b8d8c60ae70a42b3acc 100644 (file)
@@ -3767,7 +3767,7 @@ struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 
                desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags,
                                              label);
-               if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
+               if (!gpiod_not_found(desc))
                        break;
        }
 
@@ -3943,7 +3943,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
         * Either we are not using DT or ACPI, or their lookup did not return
         * a result. In that case, use platform lookup as a fallback.
         */
-       if (!desc || desc == ERR_PTR(-ENOENT)) {
+       if (!desc || gpiod_not_found(desc)) {
                dev_dbg(dev, "using lookup tables for GPIO lookup\n");
                desc = gpiod_find(dev, con_id, idx, &lookupflags);
        }
@@ -4078,10 +4078,8 @@ struct gpio_desc *__must_check gpiod_get_index_optional(struct device *dev,
        struct gpio_desc *desc;
 
        desc = 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;
 }
@@ -4283,7 +4281,7 @@ struct gpio_descs *__must_check gpiod_get_array_optional(struct device *dev,
        struct gpio_descs *descs;
 
        descs = gpiod_get_array(dev, con_id, flags);
-       if (PTR_ERR(descs) == -ENOENT)
+       if (gpiod_not_found(descs))
                return NULL;
 
        return descs;