aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo(Woogyom) Kim <milo.kim@ti.com>2013-02-05 04:57:36 -0500
committerBryan Wu <cooloney@gmail.com>2013-02-06 18:59:27 -0500
commitffbdccdbbaee814963a09d25b1cc598cfe131366 (patch)
treeed487c6e89fb106fd7de798d166ee4342efac85e /drivers/leds/leds-lp5521.c
parente3a700d8aae190e09fb06abe0ddd2e172a682508 (diff)
leds-lp55xx: use lp55xx common init function - post int
LP5521/5523 chip configuration is replaced with lp55xx common function, lp55xx_post_init_device(). Name change: lp5521/5523_configure() to lp5521/5523_post_init_device() These are called in init function. Register access function Argument type is changed from 'i2c_client' to 'lp55xx_chip'. Use exported R/W functions of lp55xx common driver. Temporary variables in lp5521/5523_init_device() These functions will be removed but temporary variables are needed for blocking build warnings - incompatible pointer. Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 0e27f7eb5d09..faab44900c23 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -238,11 +238,9 @@ static int lp5521_set_led_current(struct lp5521_chip *chip, int led, u8 curr)
238 curr); 238 curr);
239} 239}
240 240
241static int lp5521_configure(struct i2c_client *client) 241static int lp5521_post_init_device(struct lp55xx_chip *chip)
242{ 242{
243 struct lp5521_chip *chip = i2c_get_clientdata(client);
244 int ret; 243 int ret;
245 u8 cfg;
246 u8 val; 244 u8 val;
247 245
248 /* 246 /*
@@ -251,13 +249,13 @@ static int lp5521_configure(struct i2c_client *client)
251 * otherwise further access to the R G B channels in the 249 * otherwise further access to the R G B channels in the
252 * LP5521_REG_ENABLE register will not have any effect - strange! 250 * LP5521_REG_ENABLE register will not have any effect - strange!
253 */ 251 */
254 ret = lp5521_read(client, LP5521_REG_R_CURRENT, &val); 252 ret = lp55xx_read(chip, LP5521_REG_R_CURRENT, &val);
255 if (ret) { 253 if (ret) {
256 dev_err(&client->dev, "error in resetting chip\n"); 254 dev_err(&chip->cl->dev, "error in resetting chip\n");
257 return ret; 255 return ret;
258 } 256 }
259 if (val != LP5521_REG_R_CURR_DEFAULT) { 257 if (val != LP5521_REG_R_CURR_DEFAULT) {
260 dev_err(&client->dev, 258 dev_err(&chip->cl->dev,
261 "unexpected data in register (expected 0x%x got 0x%x)\n", 259 "unexpected data in register (expected 0x%x got 0x%x)\n",
262 LP5521_REG_R_CURR_DEFAULT, val); 260 LP5521_REG_R_CURR_DEFAULT, val);
263 ret = -EINVAL; 261 ret = -EINVAL;
@@ -266,22 +264,21 @@ static int lp5521_configure(struct i2c_client *client)
266 usleep_range(10000, 20000); 264 usleep_range(10000, 20000);
267 265
268 /* Set all PWMs to direct control mode */ 266 /* Set all PWMs to direct control mode */
269 ret = lp5521_write(client, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT); 267 ret = lp55xx_write(chip, LP5521_REG_OP_MODE, LP5521_CMD_DIRECT);
270 268
271 cfg = chip->pdata->update_config ? 269 val = chip->pdata->update_config ?
272 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); 270 : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT);
273 ret = lp5521_write(client, LP5521_REG_CONFIG, cfg); 271 ret = lp55xx_write(chip, LP5521_REG_CONFIG, val);
274 if (ret) 272 if (ret)
275 return ret; 273 return ret;
276 274
277 /* Initialize all channels PWM to zero -> leds off */ 275 /* Initialize all channels PWM to zero -> leds off */
278 lp5521_write(client, LP5521_REG_R_PWM, 0); 276 lp55xx_write(chip, LP5521_REG_R_PWM, 0);
279 lp5521_write(client, LP5521_REG_G_PWM, 0); 277 lp55xx_write(chip, LP5521_REG_G_PWM, 0);
280 lp5521_write(client, LP5521_REG_B_PWM, 0); 278 lp55xx_write(chip, LP5521_REG_B_PWM, 0);
281 279
282 /* Set engines are set to run state when OP_MODE enables engines */ 280 /* Set engines are set to run state when OP_MODE enables engines */
283 ret = lp5521_write(client, LP5521_REG_ENABLE, 281 ret = lp55xx_write(chip, LP5521_REG_ENABLE, LP5521_ENABLE_RUN_PROGRAM);
284 LP5521_ENABLE_RUN_PROGRAM);
285 if (ret) 282 if (ret)
286 return ret; 283 return ret;
287 284
@@ -696,9 +693,10 @@ static void lp5521_deinit_device(struct lp5521_chip *chip);
696static int lp5521_init_device(struct lp5521_chip *chip) 693static int lp5521_init_device(struct lp5521_chip *chip)
697{ 694{
698 struct i2c_client *client = chip->client; 695 struct i2c_client *client = chip->client;
696 struct lp55xx_chip *temp;
699 int ret; 697 int ret;
700 698
701 ret = lp5521_configure(client); 699 ret = lp5521_post_init_device(temp);
702 if (ret < 0) { 700 if (ret < 0) {
703 dev_err(&client->dev, "error configuring chip\n"); 701 dev_err(&client->dev, "error configuring chip\n");
704 goto err_config; 702 goto err_config;
@@ -828,6 +826,7 @@ static struct lp55xx_device_config lp5521_cfg = {
828 .addr = LP5521_REG_ENABLE, 826 .addr = LP5521_REG_ENABLE,
829 .val = LP5521_ENABLE_DEFAULT, 827 .val = LP5521_ENABLE_DEFAULT,
830 }, 828 },
829 .post_init_device = lp5521_post_init_device,
831}; 830};
832 831
833static int lp5521_probe(struct i2c_client *client, 832static int lp5521_probe(struct i2c_client *client,