drm/panel: simple: Use devm_gpiod_get_optional()
authorAlexandre Courbot <acourbot@nvidia.com>
Fri, 25 Jul 2014 14:47:25 +0000 (23:47 +0900)
committerThierry Reding <treding@nvidia.com>
Thu, 7 Aug 2014 07:35:27 +0000 (09:35 +0200)
Use the new devm_gpiod_get_optional() to simplify the probe code.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/panel/panel-simple.c

index 6ae1aada63733ab17ff2eb99029ca4baed3dcb35..4ce1db0a68ff5754c37cb1eace4edccc6d6f03db 100644 (file)
@@ -247,16 +247,14 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
        if (IS_ERR(panel->supply))
                return PTR_ERR(panel->supply);
 
-       panel->enable_gpio = devm_gpiod_get(dev, "enable");
+       panel->enable_gpio = devm_gpiod_get_optional(dev, "enable");
        if (IS_ERR(panel->enable_gpio)) {
                err = PTR_ERR(panel->enable_gpio);
-               if (err != -ENOENT) {
-                       dev_err(dev, "failed to request GPIO: %d\n", err);
-                       return err;
-               }
+               dev_err(dev, "failed to request GPIO: %d\n", err);
+               return err;
+       }
 
-               panel->enable_gpio = NULL;
-       } else {
+       if (panel->enable_gpio) {
                err = gpiod_direction_output(panel->enable_gpio, 0);
                if (err < 0) {
                        dev_err(dev, "failed to setup GPIO: %d\n", err);