backlight: lp855x: Use private data for regulator control
authorMilo Kim <milo.kim@ti.com>
Mon, 20 Jul 2015 06:45:38 +0000 (15:45 +0900)
committerLee Jones <lee.jones@linaro.org>
Tue, 25 Aug 2015 07:40:44 +0000 (08:40 +0100)
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>
drivers/video/backlight/lp855x_bl.c
include/linux/platform_data/lp855x.h

index 88116b493f3ba9d3177c22866df061d7fd449ef7..f88df9ec08d044091d7c1b531499a46309012904 100644 (file)
@@ -73,6 +73,7 @@ struct lp855x {
        struct device *dev;
        struct lp855x_platform_data *pdata;
        struct pwm_device *pwm;
+       struct regulator *supply;       /* regulator for VDD input */
 };
 
 static int lp855x_write_byte(struct lp855x *lp, u8 reg, u8 data)
@@ -378,13 +379,6 @@ static int lp855x_parse_dt(struct lp855x *lp)
                pdata->rom_data = &rom[0];
        }
 
-       pdata->supply = devm_regulator_get(dev, "power");
-       if (IS_ERR(pdata->supply)) {
-               if (PTR_ERR(pdata->supply) == -EPROBE_DEFER)
-                       return -EPROBE_DEFER;
-               pdata->supply = NULL;
-       }
-
        lp->pdata = pdata;
 
        return 0;
@@ -425,8 +419,15 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
        else
                lp->mode = REGISTER_BASED;
 
-       if (lp->pdata->supply) {
-               ret = regulator_enable(lp->pdata->supply);
+       lp->supply = devm_regulator_get(lp->dev, "power");
+       if (IS_ERR(lp->supply)) {
+               if (PTR_ERR(lp->supply) == -EPROBE_DEFER)
+                       return -EPROBE_DEFER;
+               lp->supply = NULL;
+       }
+
+       if (lp->supply) {
+               ret = regulator_enable(lp->supply);
                if (ret < 0) {
                        dev_err(&cl->dev, "failed to enable supply: %d\n", ret);
                        return ret;
@@ -464,8 +465,8 @@ static int lp855x_remove(struct i2c_client *cl)
 
        lp->bl->props.brightness = 0;
        backlight_update_status(lp->bl);
-       if (lp->pdata->supply)
-               regulator_disable(lp->pdata->supply);
+       if (lp->supply)
+               regulator_disable(lp->supply);
        sysfs_remove_group(&lp->dev->kobj, &lp855x_attr_group);
 
        return 0;
index 9c7fd1efe4952cfe5d17bdc26679c80421257435..1b2ba24e4e03bf98ac35d990c634e1a08ae19e15 100644 (file)
@@ -136,7 +136,6 @@ struct lp855x_rom_data {
                Only valid when mode is PWM_BASED.
  * @size_program : total size of lp855x_rom_data
  * @rom_data : list of new eeprom/eprom registers
- * @supply : regulator that supplies 3V input
  */
 struct lp855x_platform_data {
        const char *name;
@@ -145,7 +144,6 @@ struct lp855x_platform_data {
        unsigned int period_ns;
        int size_program;
        struct lp855x_rom_data *rom_data;
-       struct regulator *supply;
 };
 
 #endif
This page took 0.02791 seconds and 5 git commands to generate.