[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130919115650.GE10852@ulmo>
Date: Thu, 19 Sep 2013 13:56:53 +0200
From: Thierry Reding <thierry.reding@...il.com>
To: Mike Dunn <mikedunn@...sguy.com>
Cc: Richard Purdie <rpurdie@...ys.net>,
Jingoo Han <jg1.han@...sung.com>,
Jean-Christophe Plagniol-Villard <plagnioj@...osoft.com>,
Tomi Valkeinen <tomi.valkeinen@...com>,
Grant Likely <grant.likely@...aro.org>,
Rob Herring <rob.herring@...xeda.com>,
linux-pwm@...r.kernel.org, linux-fbdev@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
Robert Jarzmik <robert.jarzmik@...e.fr>,
Marek Vasut <marex@...x.de>
Subject: Re: [PATCH] pwm-backlight: allow for non-increasing brightness levels
On Thu, Sep 12, 2013 at 11:35:52AM -0700, Mike Dunn wrote:
> Currently the driver assumes that the values specified in the brightness-levels
> device tree property increase as they are parsed from left to right. But boards
> that invert the signal between the PWM output and the backlight will need to
> specify decreasing brightness-levels. This patch removes the assumption that
> the last element of the array is the max value, and instead searches the array
> for the max value and uses that as the normalizing value when determining the
> duty cycle.
"maximum value", "... and uses that as the scale to normalize the duty
cycle"?
Also please wrap commit messages at 72 characters.
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 1fea627..d66aaa0 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -27,6 +27,7 @@ struct pwm_bl_data {
> unsigned int period;
> unsigned int lth_brightness;
> unsigned int *levels;
> + unsigned int max_level;
Perhaps call this "scale"? Otherwise there some potential to mix it up
with max_brightness.
> @@ -195,7 +196,15 @@ static int pwm_backlight_probe(struct platform_device *pdev)
> }
>
> if (data->levels) {
> - max = data->levels[data->max_brightness];
> + int i, max_value = 0, max_idx = 0;
i should be unsigned int to match the type of data->max_brightness.
> + for (i = 0; i <= data->max_brightness; i++) {
There should be a blank line above this one to increase readability.
> + if (data->levels[i] > max_value) {
> + max_value = data->levels[i];
> + max_idx = i;
> + }
> + }
> + pb->max_level = max_idx;
Some here.
Also I suggest to just drop the max_ prefix from the local variables.
Perhaps also simplify all of it to something like:
for (i = 0; i <= data->max_brightness; i++)
if (data->levels[i] > pb->scale)
pb->scale = data->levels[i];
And get rid of the index altogether. That way you can use pb->scale
directly during the computation of the duty cycle and don't have to
index the levels array over and over again.
Thierry
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists