aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorMilo Kim <milo.kim@ti.com>2015-08-24 03:09:55 -0400
committerJacek Anaszewski <j.anaszewski@samsung.com>2015-08-28 08:06:28 -0400
commited133352047e46687afd98c299ec8ce7f6ea07bd (patch)
tree6b35cca71f5451782c5979106336d1321a03cc71 /drivers/leds/leds-lp5521.c
parent991a3f61fa93c1752a47ae157a8238395850c730 (diff)
leds:lp55xx: use the private data instead of updating I2C device platform data
Currently, lp55xx_of_populate_pdata() allocates lp55xx_platform_data if it's null. And it parses the DT and copies values into the 'client->dev.platform_data'. This may have architectural issue. Platform data is configurable through the DT or I2C board info inside the platform area. However, lp55xx common driver changes this configuration when it is loaded. So 'client->dev.platform_data' is not null anymore. Eventually, the driver initialization is not identical when it's unloaded and loaded again. The lp55xx common driver should use the private data, 'lp55xx_chip->pdata' instead of changing the original platform data. So, lp55xx_of_populate_pdata() is modified as follows. * Do not update 'dev->platform_data'. Return the pointer of new allocated lp55xx_platform_data. Then the driver points it to private data, 'lp55xx_chip->pdata'. * Each lp55xx driver checks the pointer and handles an error case. Then, original platform data configuration will be kept regardless of loading or unloading the driver. The driver allocates the memory and copies them from the DT if it's NULL. After the driver is loaded again, 'client->dev.platform_data' is same as initial load, so the driver is initialized identically. Cc: Toshi Kikuchi <toshik@chromium.org> Cc: linux-leds@vger.kernel.org Signed-off-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 8ca197af2864..63a92542c8cb 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -514,20 +514,19 @@ static int lp5521_probe(struct i2c_client *client,
514 int ret; 514 int ret;
515 struct lp55xx_chip *chip; 515 struct lp55xx_chip *chip;
516 struct lp55xx_led *led; 516 struct lp55xx_led *led;
517 struct lp55xx_platform_data *pdata; 517 struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
518 struct device_node *np = client->dev.of_node; 518 struct device_node *np = client->dev.of_node;
519 519
520 if (!dev_get_platdata(&client->dev)) { 520 if (!pdata) {
521 if (np) { 521 if (np) {
522 ret = lp55xx_of_populate_pdata(&client->dev, np); 522 pdata = lp55xx_of_populate_pdata(&client->dev, np);
523 if (ret < 0) 523 if (IS_ERR(pdata))
524 return ret; 524 return PTR_ERR(pdata);
525 } else { 525 } else {
526 dev_err(&client->dev, "no platform data\n"); 526 dev_err(&client->dev, "no platform data\n");
527 return -EINVAL; 527 return -EINVAL;
528 } 528 }
529 } 529 }
530 pdata = dev_get_platdata(&client->dev);
531 530
532 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); 531 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
533 if (!chip) 532 if (!chip)