Re: [PATCH v2 04/24] backlight: gpio: Introduce backlight_{enable,disable}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 23, 2020 at 12:45:12PM +0200, Sam Ravnborg wrote:
> Use backlight_{enable,disable} in the probe function to
> avoid hardcoding power handling in the driver.
> 
> Move platform_set_drvdata() up as the enable/disable call
> will trigger a callback to the driver.
> 
> Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
> Cc: Lee Jones <lee.jones@xxxxxxxxxx>
> Cc: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
> Cc: Jingoo Han <jingoohan1@xxxxxxxxx>

Reviewed-by: Daniel Thompson <daniel.thompson@xxxxxxxxxx>


> ---
>  drivers/video/backlight/gpio_backlight.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index 6f78d928f054..dc9354dc5e6a 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -53,6 +53,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
>  	struct backlight_device *bl;
>  	struct gpio_backlight *gbl;
>  	int ret, init_brightness, def_value;
> +	bool enable = false;
>  
>  	gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
>  	if (gbl == NULL)
> @@ -82,16 +83,22 @@ static int gpio_backlight_probe(struct platform_device *pdev)
>  		return PTR_ERR(bl);
>  	}
>  
> -	/* Set the initial power state */
> -	if (!of_node || !of_node->phandle)
> +	platform_set_drvdata(pdev, bl);
> +
> +	/* Set the initial state */
> +	if (!of_node || !of_node->phandle) {
>  		/* Not booted with device tree or no phandle link to the node */
> -		bl->props.power = def_value ? FB_BLANK_UNBLANK
> -					    : FB_BLANK_POWERDOWN;
> -	else if (gpiod_get_direction(gbl->gpiod) == 0 &&
> -		 gpiod_get_value_cansleep(gbl->gpiod) == 0)
> -		bl->props.power = FB_BLANK_POWERDOWN;
> +		if (def_value)
> +			enable = true;
> +	} else if (!(gpiod_get_direction(gbl->gpiod) == 0 &&
> +		   gpiod_get_value_cansleep(gbl->gpiod) == 0)) {
> +		enable = true;
> +	}
> +
> +	if (enable)
> +		backlight_enable(bl);
>  	else
> -		bl->props.power = FB_BLANK_UNBLANK;
> +		backlight_disable(bl);
>  
>  	bl->props.brightness = 1;
>  
> @@ -102,7 +109,6 @@ static int gpio_backlight_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	platform_set_drvdata(pdev, bl);
>  	return 0;
>  }
>  
> -- 
> 2.25.1
> 
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux