Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Milo Kim and committed by
Lee Jones
fe009175 bc0195aa

+12 -13
+12 -11
drivers/video/backlight/lp855x_bl.c
··· 73 73 struct device *dev; 74 74 struct lp855x_platform_data *pdata; 75 75 struct pwm_device *pwm; 76 + struct regulator *supply; /* regulator for VDD input */ 76 77 }; 77 78 78 79 static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data) ··· 379 378 pdata->rom_data = &rom[0]; 380 379 } 381 380 382 - pdata->supply = devm_regulator_get(dev, "power"); 383 - if (IS_ERR(pdata->supply)) { 384 - if (PTR_ERR(pdata->supply) == -EPROBE_DEFER) 385 - return -EPROBE_DEFER; 386 - pdata->supply = NULL; 387 - } 388 - 389 381 lp->pdata = pdata; 390 382 391 383 return 0; ··· 419 425 else 420 426 lp->mode = REGISTER_BASED; 421 427 422 - if (lp->pdata->supply) { 423 - ret = regulator_enable(lp->pdata->supply); 428 + lp->supply = devm_regulator_get(lp->dev, "power"); 429 + if (IS_ERR(lp->supply)) { 430 + if (PTR_ERR(lp->supply) == -EPROBE_DEFER) 431 + return -EPROBE_DEFER; 432 + lp->supply = NULL; 433 + } 434 + 435 + if (lp->supply) { 436 + ret = regulator_enable(lp->supply); 424 437 if (ret < 0) { 425 438 dev_err(&cl->dev, "failed to enable supply: %d\n", ret); 426 439 return ret; ··· 465 464 466 465 lp->bl->props.brightness = 0; 467 466 backlight_update_status(lp->bl); 468 - if (lp->pdata->supply) 469 - regulator_disable(lp->pdata->supply); 467 + if (lp->supply) 468 + regulator_disable(lp->supply); 470 469 sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group); 471 470 472 471 return 0;
-2
include/linux/platform_data/lp855x.h
··· 136 136 Only valid when mode is PWM_BASED. 137 137 * @size_program : total size of lp855x_rom_data 138 138 * @rom_data : list of new eeprom/eprom registers 139 - * @supply : regulator that supplies 3V input 140 139 */ 141 140 struct lp855x_platform_data { 142 141 const char *name; ··· 144 145 unsigned int period_ns; 145 146 int size_program; 146 147 struct lp855x_rom_data *rom_data; 147 - struct regulator *supply; 148 148 }; 149 149 150 150 #endif