lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120709051001.GA10108@avionic-0098.mockup.avionic-design.de>
Date:	Mon, 9 Jul 2012 07:10:01 +0200
From:	Thierry Reding <thierry.reding@...onic-design.de>
To:	Alexandre Courbot <acourbot@...dia.com>
Cc:	linux-kernel@...r.kernel.org, linux-fbdev@...r.kernel.org
Subject: Re: [PATCH] pwm_backlight: pass correct brightness to callback

On Mon, Jul 09, 2012 at 01:21:40PM +0900, Alexandre Courbot wrote:
> pwm_backlight_update_status calls two callbacks before and after
> applying the new PWM settings. However, the brightness scale is
> completely changed in between if brightness levels are used. This patch
> ensures that both callbacks are passed brightness values of the same
> meaning.
> 
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> ---
>  drivers/video/backlight/pwm_bl.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

I had to actually read this patch a number of times and then realized I
was completely missing the context. Looking at the whole function makes
it more obvious what you mean.

However I think it'd be much clearer if we just passed the value of
bl->props.brightness into the callbacks, that way we can avoid the
additional variable.

Thierry

> 
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 057389d..dd4d24d 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -39,6 +39,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
>  {
>  	struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
>  	int brightness = bl->props.brightness;
> +	int pwm_brightness;
>  	int max = bl->props.max_brightness;
>  
>  	if (bl->props.power != FB_BLANK_UNBLANK)
> @@ -55,13 +56,14 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
>  		pwm_disable(pb->pwm);
>  	} else {
>  		if (pb->levels) {
> -			brightness = pb->levels[brightness];
> +			pwm_brightness = pb->levels[brightness];
>  			max = pb->levels[max];
> -		}
> +		} else
> +			pwm_brightness = brightness;
>  
> -		brightness = pb->lth_brightness +
> -			(brightness * (pb->period - pb->lth_brightness) / max);
> -		pwm_config(pb->pwm, brightness, pb->period);
> +		pwm_brightness = pb->lth_brightness +
> +		     (pwm_brightness * (pb->period - pb->lth_brightness) / max);
> +		pwm_config(pb->pwm, pwm_brightness, pb->period);
>  		pwm_enable(pb->pwm);
>  	}
>  
> -- 
> 1.7.11.1
> 
> 

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ