lkml.org 
[lkml]   [2012]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 7/7] leds-lm3530: enhanced arithmetic operation
On 01/20/2012 02:52 AM, Kim, Milo wrote:
> Use shift operation rather than 'divide-by-2'.

The compiler will already take of this for you.

But why is the divide by two necessary anyway? This sort of looks like
max_brightness is not set properly and the code compensates for it by
ignoring the lsb.

>
> Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
>
> diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c
> index 51c1f6c..e0b1ba8 100644
> --- a/drivers/leds/leds-lm3530.c
> +++ b/drivers/leds/leds-lm3530.c
> @@ -249,12 +249,12 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
>
> /* set the brightness in brightness control register*/
> err = i2c_smbus_write_byte_data(drvdata->client,
> - LM3530_BRT_CTRL_REG, brt_val / 2);
> + LM3530_BRT_CTRL_REG, brt_val >> 1);
> if (err)
> dev_err(&drvdata->client->dev,
> "Unable to set brightness: %d\n", err);
> else
> - drvdata->brightness = brt_val / 2;
> + drvdata->brightness = brt_val >> 1;
>
> if (brt_val == 0 && !pdata->is_vin_always_on) {
> err = regulator_disable(drvdata->regulator);



\
 
 \ /
  Last update: 2012-01-20 09:33    [W:0.056 / U:2.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site