aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilo Kim <milo.kim@ti.com>2015-07-20 02:45:38 -0400
committerLee Jones <lee.jones@linaro.org>2015-08-25 03:40:44 -0400
commitfe009175ae3ec3724c1414440e22a1d32d806ec5 (patch)
treef8d85f662cfe1001ef4409718f4fe4b3634c504b
parentbc0195aad0daa2ad5b0d76cce22b167bc3435590 (diff)
backlight: lp855x: Use private data for regulator control
LP855x backlight device can be enabled by external VDD input. The 'supply' data is used for this purpose. It's kind of private data which runs internally, so there is no reason to expose to the platform data. And devm_regulator_get() is moved from _parse_dt() to _probe(). Regulator consumer(lp855x) can control regulator not only from DT but also from platform data configuration in a source file such like board-*.c. Signed-off-by: Milo Kim <milo.kim@ti.com> Acked-by: Sean Paul <seanpaul@chromium.org> Acked-by: Jingoo Han <jingoohan1@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/video/backlight/lp855x_bl.c23
-rw-r--r--include/linux/platform_data/lp855x.h2
2 files changed, 12 insertions, 13 deletions
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 88116b493f3b..f88df9ec08d0 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -73,6 +73,7 @@ struct lp855x {
73 struct device *dev; 73 struct device *dev;
74 struct lp855x_platform_data *pdata; 74 struct lp855x_platform_data *pdata;
75 struct pwm_device *pwm; 75 struct pwm_device *pwm;
76 struct regulator *supply; /* regulator for VDD input */
76}; 77};
77 78
78static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data) 79static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
@@ -378,13 +379,6 @@ static int lp855x_parse_dt(struct lp855x *lp)
378 pdata->rom_data = &rom[0]; 379 pdata->rom_data = &rom[0];
379 } 380 }
380 381
381 pdata->supply = devm_regulator_get(dev, "power");
382 if (IS_ERR(pdata->supply)) {
383 if (PTR_ERR(pdata->supply) == -EPROBE_DEFER)
384 return -EPROBE_DEFER;
385 pdata->supply = NULL;
386 }
387
388 lp->pdata = pdata; 382 lp->pdata = pdata;
389 383
390 return 0; 384 return 0;
@@ -425,8 +419,15 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
425 else 419 else
426 lp->mode = REGISTER_BASED; 420 lp->mode = REGISTER_BASED;
427 421
428 if (lp->pdata->supply) { 422 lp->supply = devm_regulator_get(lp->dev, "power");
429 ret = regulator_enable(lp->pdata->supply); 423 if (IS_ERR(lp->supply)) {
424 if (PTR_ERR(lp->supply) == -EPROBE_DEFER)
425 return -EPROBE_DEFER;
426 lp->supply = NULL;
427 }
428
429 if (lp->supply) {
430 ret = regulator_enable(lp->supply);
430 if (ret < 0) { 431 if (ret < 0) {
431 dev_err(&cl->dev, "failed to enable supply: %d\n", ret); 432 dev_err(&cl->dev, "failed to enable supply: %d\n", ret);
432 return ret; 433 return ret;
@@ -464,8 +465,8 @@ static int lp855x_remove(struct i2c_client *cl)
464 465
465 lp->bl->props.brightness = 0; 466 lp->bl->props.brightness = 0;
466 backlight_update_status(lp->bl); 467 backlight_update_status(lp->bl);
467 if (lp->pdata->supply) 468 if (lp->supply)
468 regulator_disable(lp->pdata->supply); 469 regulator_disable(lp->supply);
469 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); 470 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
470 471
471 return 0; 472 return 0;
diff --git a/include/linux/platform_data/lp855x.h b/include/linux/platform_data/lp855x.h
index 9c7fd1efe495..1b2ba24e4e03 100644
--- a/include/linux/platform_data/lp855x.h
+++ b/include/linux/platform_data/lp855x.h
@@ -136,7 +136,6 @@ struct lp855x_rom_data {
136 Only valid when mode is PWM_BASED. 136 Only valid when mode is PWM_BASED.
137 * @size_program : total size of lp855x_rom_data 137 * @size_program : total size of lp855x_rom_data
138 * @rom_data : list of new eeprom/eprom registers 138 * @rom_data : list of new eeprom/eprom registers
139 * @supply : regulator that supplies 3V input
140 */ 139 */
141struct lp855x_platform_data { 140struct lp855x_platform_data {
142 const char *name; 141 const char *name;
@@ -145,7 +144,6 @@ struct lp855x_platform_data {
145 unsigned int period_ns; 144 unsigned int period_ns;
146 int size_program; 145 int size_program;
147 struct lp855x_rom_data *rom_data; 146 struct lp855x_rom_data *rom_data;
148 struct regulator *supply;
149}; 147};
150 148
151#endif 149#endif