drm/omap: panel-nec-nl8048hl11: Convert to the GPIO descriptors API
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 28 May 2018 14:18:26 +0000 (17:18 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Mon, 3 Sep 2018 13:13:28 +0000 (16:13 +0300)
The GPIO descriptor API is favoured over the plain GPIO API for consumer
drivers. Using it simplifies the driver code.

The reset GPIO is mandatory, so drop conditional tests through the
driver. The qvga GPIO is unused, so drop it completely.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c

index b4dba55b678bed1dd937ac256e773997b2579bec..767ffd2fa0f45077ec818f69d46c7e0813d8f785 100644 (file)
  * (at your option) any later version.
  */
 
-#include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/spi/spi.h>
 #include <linux/gpio/consumer.h>
-#include <linux/of_gpio.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
 
 #include "../dss/omapdss.h"
 
@@ -24,8 +23,7 @@ struct panel_drv_data {
 
        struct videomode vm;
 
-       int res_gpio;
-       int qvga_gpio;
+       struct gpio_desc *res_gpio;
 
        struct spi_device *spi;
 };
@@ -140,8 +138,7 @@ static int nec_8048_enable(struct omap_dss_device *dssdev)
        if (r)
                return r;
 
-       if (gpio_is_valid(ddata->res_gpio))
-               gpio_set_value_cansleep(ddata->res_gpio, 1);
+       gpiod_set_value_cansleep(ddata->res_gpio, 1);
 
        dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
 
@@ -156,8 +153,7 @@ static void nec_8048_disable(struct omap_dss_device *dssdev)
        if (!omapdss_device_is_enabled(dssdev))
                return;
 
-       if (gpio_is_valid(ddata->res_gpio))
-               gpio_set_value_cansleep(ddata->res_gpio, 0);
+       gpiod_set_value_cansleep(ddata->res_gpio, 0);
 
        src->ops->disable(src);
 
@@ -203,29 +199,11 @@ static const struct omap_dss_driver nec_8048_ops = {
        .check_timings  = nec_8048_check_timings,
 };
 
-static int nec_8048_probe_of(struct spi_device *spi)
-{
-       struct device_node *node = spi->dev.of_node;
-       struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-       int gpio;
-
-       gpio = of_get_named_gpio(node, "reset-gpios", 0);
-       if (!gpio_is_valid(gpio)) {
-               dev_err(&spi->dev, "failed to parse enable gpio\n");
-               return gpio;
-       }
-       ddata->res_gpio = gpio;
-
-       /* XXX the panel spec doesn't mention any QVGA pin?? */
-       ddata->qvga_gpio = -ENOENT;
-
-       return 0;
-}
-
 static int nec_8048_probe(struct spi_device *spi)
 {
        struct panel_drv_data *ddata;
        struct omap_dss_device *dssdev;
+       struct gpio_desc *gpio;
        int r;
 
        dev_dbg(&spi->dev, "%s\n", __func__);
@@ -249,23 +227,13 @@ static int nec_8048_probe(struct spi_device *spi)
 
        ddata->spi = spi;
 
-       r = nec_8048_probe_of(spi);
-       if (r)
-               return r;
-
-       if (gpio_is_valid(ddata->qvga_gpio)) {
-               r = devm_gpio_request_one(&spi->dev, ddata->qvga_gpio,
-                               GPIOF_OUT_INIT_HIGH, "lcd QVGA");
-               if (r)
-                       return r;
+       gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
+       if (IS_ERR(gpio)) {
+               dev_err(&spi->dev, "failed to get reset gpio\n");
+               return PTR_ERR(gpio);
        }
 
-       if (gpio_is_valid(ddata->res_gpio)) {
-               r = devm_gpio_request_one(&spi->dev, ddata->res_gpio,
-                               GPIOF_OUT_INIT_LOW, "lcd RES");
-               if (r)
-                       return r;
-       }
+       ddata->res_gpio = gpio;
 
        ddata->vm = nec_8048_panel_vm;