aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2014-12-02 20:39:11 -0500
committerLee Jones <lee.jones@linaro.org>2014-12-09 04:24:42 -0500
commit47726656dd67a2487bd7fafec1a73472da1db956 (patch)
treed454df17fd723c3f767a8fed410434915e6b8428 /drivers/video/backlight
parentedf387b6d1a6993103ec95ed934a6daf559535f4 (diff)
backlight: lp855x: Refactor DT parsing code
This patch refactors the dt parsing code to avoid setting platform_data, instead just setting lp->pdata directly. This facilitates easier probe deferral since the current scheme would require us to clear out dev->platform_data before deferring. Cc: Stéphane Marchesin <marcheu@chromium.org> Signed-off-by: Sean Paul <seanpaul@chromium.org> Acked-by: Milo Kim <milo.kim@ti.com> Acked-by: Bryan Wu <cooloney@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r--drivers/video/backlight/lp855x_bl.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 25fb8e3d75b1..257b3badd8e4 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -341,8 +341,10 @@ static const struct attribute_group lp855x_attr_group = {
341}; 341};
342 342
343#ifdef CONFIG_OF 343#ifdef CONFIG_OF
344static int lp855x_parse_dt(struct device *dev, struct device_node *node) 344static int lp855x_parse_dt(struct lp855x *lp)
345{ 345{
346 struct device *dev = lp->dev;
347 struct device_node *node = dev->of_node;
346 struct lp855x_platform_data *pdata; 348 struct lp855x_platform_data *pdata;
347 int rom_length; 349 int rom_length;
348 350
@@ -381,12 +383,12 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node)
381 pdata->rom_data = &rom[0]; 383 pdata->rom_data = &rom[0];
382 } 384 }
383 385
384 dev->platform_data = pdata; 386 lp->pdata = pdata;
385 387
386 return 0; 388 return 0;
387} 389}
388#else 390#else
389static int lp855x_parse_dt(struct device *dev, struct device_node *node) 391static int lp855x_parse_dt(struct lp855x *lp)
390{ 392{
391 return -EINVAL; 393 return -EINVAL;
392} 394}
@@ -395,18 +397,8 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node)
395static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) 397static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
396{ 398{
397 struct lp855x *lp; 399 struct lp855x *lp;
398 struct lp855x_platform_data *pdata = dev_get_platdata(&cl->dev);
399 struct device_node *node = cl->dev.of_node;
400 int ret; 400 int ret;
401 401
402 if (!pdata) {
403 ret = lp855x_parse_dt(&cl->dev, node);
404 if (ret < 0)
405 return ret;
406
407 pdata = dev_get_platdata(&cl->dev);
408 }
409
410 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) 402 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
411 return -EIO; 403 return -EIO;
412 404
@@ -414,16 +406,23 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
414 if (!lp) 406 if (!lp)
415 return -ENOMEM; 407 return -ENOMEM;
416 408
417 if (pdata->period_ns > 0)
418 lp->mode = PWM_BASED;
419 else
420 lp->mode = REGISTER_BASED;
421
422 lp->client = cl; 409 lp->client = cl;
423 lp->dev = &cl->dev; 410 lp->dev = &cl->dev;
424 lp->pdata = pdata;
425 lp->chipname = id->name; 411 lp->chipname = id->name;
426 lp->chip_id = id->driver_data; 412 lp->chip_id = id->driver_data;
413 lp->pdata = dev_get_platdata(&cl->dev);
414
415 if (!lp->pdata) {
416 ret = lp855x_parse_dt(lp);
417 if (ret < 0)
418 return ret;
419 }
420
421 if (lp->pdata->period_ns > 0)
422 lp->mode = PWM_BASED;
423 else
424 lp->mode = REGISTER_BASED;
425
427 i2c_set_clientdata(cl, lp); 426 i2c_set_clientdata(cl, lp);
428 427
429 ret = lp855x_configure(lp); 428 ret = lp855x_configure(lp);