[PATCH 07/21] drm/omap: panel-nec-nl8048hl11: Convert to the GPIO descriptors API

Sebastian Reichel sre at kernel.org
Mon Jun 11 14:12:48 UTC 2018


Hi,

On Wed, Jun 06, 2018 at 12:36:36PM +0300, Laurent Pinchart wrote:
> 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 at ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>

-- Sebastian

>  .../drm/omapdrm/displays/panel-nec-nl8048hl11.c    | 54 +++++-----------------
>  1 file changed, 11 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> index b4dba55b678b..767ffd2fa0f4 100644
> --- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> +++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
> @@ -11,11 +11,10 @@
>   * (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;
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20180611/c9c378e9/attachment.sig>


More information about the dri-devel mailing list