From: Lars-Peter Clausen <lars@metafoo.de>
To: "Kim, Milo" <Milo.Kim@ti.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
"shreshthakumar.sahu@stericsson.com"
<shreshthakumar.sahu@stericsson.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"rpurdie@rpsys.net" <rpurdie@rpsys.net>
Subject: Re: [PATCH 7/7] leds-lm3530: enhanced arithmetic operation
Date: Fri, 20 Jan 2012 09:31:56 +0100 [thread overview]
Message-ID: <4F19267C.7010307@metafoo.de> (raw)
In-Reply-To: <B567DBAB974C0544994013492B949F8E3812C6D0D7@EXMAIL03.scwf.nsc.com>
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);
next prev parent reply other threads:[~2012-01-20 8:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-20 1:52 Kim, Milo
2012-01-20 8:31 ` Lars-Peter Clausen [this message]
2012-01-20 11:20 ` Kim, Milo
2012-01-20 11:39 ` Lars-Peter Clausen
2012-01-20 17:30 ` Kim, Milo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F19267C.7010307@metafoo.de \
--to=lars@metafoo.de \
--cc=Milo.Kim@ti.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
--cc=shreshthakumar.sahu@stericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome