* problem configuring backlight brightness levels in device tree
@ 2016-07-11 12:24 iw3gtf
0 siblings, 0 replies; 3+ messages in thread
From: iw3gtf @ 2016-07-11 12:24 UTC (permalink / raw)
To: barebox
Hi,
I was trying to configure a pwm backlight on an embedded arm board
and I think I've found a minor problem.
In the source file 'drivers/video/backlight-pwm.c', in the function pwm_backlight_parse_dt()
you set the number of brightness values to:
pwm_backlight->backlight.brightness_max = length / sizeof(u32);
and then loop through the array with:
for (i = 0; i <= pwm_backlight->backlight.brightness_max; i++)
to find the max of the array.
I think the '<=' should be a '<' otherwise you access an uninitialized value
one past the end of the array; this actually does not directly crash barebox
but the whole brightness values are scaled wrong.
giorgio
Giorgio, iw3gtf@arcor.de
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem configuring backlight brightness levels in device tree
2016-07-11 11:51 giorgio.nicole
@ 2016-07-13 5:18 ` Sascha Hauer
0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-07-13 5:18 UTC (permalink / raw)
To: giorgio.nicole; +Cc: barebox
On Mon, Jul 11, 2016 at 01:51:11PM +0200, giorgio.nicole@arcor.de wrote:
> Hi,
>
> I was trying to configure a pwm backlight on an embedded arm board
> and I think I've found a minor problem.
>
> In the source file 'drivers/video/backlight-pwm.c', in the function pwm_backlight_parse_dt()
> you set the number of brightness values to:
>
> pwm_backlight->backlight.brightness_max = length / sizeof(u32);
>
> and then loop through the array with:
>
> for (i = 0; i <= pwm_backlight->backlight.brightness_max; i++)
>
> to find the max of the array.
>
> I think the '<=' should be a '<' otherwise you access an uninitialized value
> one past the end of the array; this actually does not directly crash barebox
> but the whole brightness values are scaled wrong.
Yes, you're right. Can you send a patch for this?
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* problem configuring backlight brightness levels in device tree
@ 2016-07-11 11:51 giorgio.nicole
2016-07-13 5:18 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: giorgio.nicole @ 2016-07-11 11:51 UTC (permalink / raw)
To: barebox
Hi,
I was trying to configure a pwm backlight on an embedded arm board
and I think I've found a minor problem.
In the source file 'drivers/video/backlight-pwm.c', in the function pwm_backlight_parse_dt()
you set the number of brightness values to:
pwm_backlight->backlight.brightness_max = length / sizeof(u32);
and then loop through the array with:
for (i = 0; i <= pwm_backlight->backlight.brightness_max; i++)
to find the max of the array.
I think the '<=' should be a '<' otherwise you access an uninitialized value
one past the end of the array; this actually does not directly crash barebox
but the whole brightness values are scaled wrong.
giorgio
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-13 5:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-11 12:24 problem configuring backlight brightness levels in device tree iw3gtf
-- strict thread matches above, loose matches on Subject: below --
2016-07-11 11:51 giorgio.nicole
2016-07-13 5:18 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox