diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2012-03-23 18:02:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 19:58:35 -0400 |
commit | bbe6453204c568723679212f6d0653b92b3d6244 (patch) | |
tree | d4aac20b7d66d26186b52d35c5dd9dbb9f5e01ef /drivers/leds/leds-lm3530.c | |
parent | 16db7f9095bf6bb394c9ddb64e738e64a0fea733 (diff) |
leds-lm3530: set the max_brightness to 127
Only 7 bits are used for updating the brightness. (register address :
A0h) So the max_brightness property of lm3530 should be set to 127.
On initializing registers, maximum initial brightness is limited to
'max_brightness'.
Division-by-two is removed on updating the brightness. This arithmetic is
not necessary because the range of brightness is 0 ~ 127= .
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds/leds-lm3530.c')
-rw-r--r-- | drivers/leds/leds-lm3530.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index e59c166a0ce2..2c32a8c45f89 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c | |||
@@ -80,6 +80,9 @@ | |||
80 | #define LM3530_DEF_ZT_3 (0x33) | 80 | #define LM3530_DEF_ZT_3 (0x33) |
81 | #define LM3530_DEF_ZT_4 (0x19) | 81 | #define LM3530_DEF_ZT_4 (0x19) |
82 | 82 | ||
83 | /* 7 bits are used for the brightness : LM3530_BRT_CTRL_REG */ | ||
84 | #define MAX_BRIGHTNESS (127) | ||
85 | |||
83 | struct lm3530_mode_map { | 86 | struct lm3530_mode_map { |
84 | const char *mode; | 87 | const char *mode; |
85 | enum lm3530_mode mode_val; | 88 | enum lm3530_mode mode_val; |
@@ -207,6 +210,9 @@ static int lm3530_init_registers(struct lm3530_data *drvdata) | |||
207 | else | 210 | else |
208 | brightness = drvdata->brightness = pltfm->brt_val; | 211 | brightness = drvdata->brightness = pltfm->brt_val; |
209 | 212 | ||
213 | if (brightness > drvdata->led_dev.max_brightness) | ||
214 | brightness = drvdata->led_dev.max_brightness; | ||
215 | |||
210 | reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */ | 216 | reg_val[0] = gen_config; /* LM3530_GEN_CONFIG */ |
211 | reg_val[1] = als_config; /* LM3530_ALS_CONFIG */ | 217 | reg_val[1] = als_config; /* LM3530_ALS_CONFIG */ |
212 | reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */ | 218 | reg_val[2] = brt_ramp; /* LM3530_BRT_RAMP_RATE */ |
@@ -264,12 +270,12 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev, | |||
264 | 270 | ||
265 | /* set the brightness in brightness control register*/ | 271 | /* set the brightness in brightness control register*/ |
266 | err = i2c_smbus_write_byte_data(drvdata->client, | 272 | err = i2c_smbus_write_byte_data(drvdata->client, |
267 | LM3530_BRT_CTRL_REG, brt_val / 2); | 273 | LM3530_BRT_CTRL_REG, brt_val); |
268 | if (err) | 274 | if (err) |
269 | dev_err(&drvdata->client->dev, | 275 | dev_err(&drvdata->client->dev, |
270 | "Unable to set brightness: %d\n", err); | 276 | "Unable to set brightness: %d\n", err); |
271 | else | 277 | else |
272 | drvdata->brightness = brt_val / 2; | 278 | drvdata->brightness = brt_val; |
273 | 279 | ||
274 | if (brt_val == 0) { | 280 | if (brt_val == 0) { |
275 | err = regulator_disable(drvdata->regulator); | 281 | err = regulator_disable(drvdata->regulator); |
@@ -380,6 +386,7 @@ static int __devinit lm3530_probe(struct i2c_client *client, | |||
380 | drvdata->enable = false; | 386 | drvdata->enable = false; |
381 | drvdata->led_dev.name = LM3530_LED_DEV; | 387 | drvdata->led_dev.name = LM3530_LED_DEV; |
382 | drvdata->led_dev.brightness_set = lm3530_brightness_set; | 388 | drvdata->led_dev.brightness_set = lm3530_brightness_set; |
389 | drvdata->led_dev.max_brightness = MAX_BRIGHTNESS; | ||
383 | 390 | ||
384 | i2c_set_clientdata(client, drvdata); | 391 | i2c_set_clientdata(client, drvdata); |
385 | 392 | ||