aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-lp5521.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-04-23 07:52:59 -0400
committerBryan Wu <cooloney@gmail.com>2013-06-20 19:21:31 -0400
commit7542a04b1515f0f878b267beb233c4ef067243fb (patch)
treef5516bc2113773391893cbbd2b309feb45829f18 /drivers/leds/leds-lp5521.c
parent7d132055814ef17a6c7b69f342244c410a5e000f (diff)
leds: lp55xx: add support for Device Tree bindings
This patch allows the lp5521 driver to be successfully probed and initialised when Device Tree support is enabled. Based on a patch by Gabriel Fernandez, rewritten in accordance with review feedback. Cc: Gabriel Fernandez <gabriel.fernandez@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Milo Kim <milo.kim@ti.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds/leds-lp5521.c')
-rw-r--r--drivers/leds/leds-lp5521.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 19752c928aa2..d461e2664b09 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -31,6 +31,7 @@
31#include <linux/mutex.h> 31#include <linux/mutex.h>
32#include <linux/platform_data/leds-lp55xx.h> 32#include <linux/platform_data/leds-lp55xx.h>
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/of.h>
34 35
35#include "leds-lp55xx-common.h" 36#include "leds-lp55xx-common.h"
36 37
@@ -416,12 +417,20 @@ static int lp5521_probe(struct i2c_client *client,
416 int ret; 417 int ret;
417 struct lp55xx_chip *chip; 418 struct lp55xx_chip *chip;
418 struct lp55xx_led *led; 419 struct lp55xx_led *led;
419 struct lp55xx_platform_data *pdata = client->dev.platform_data; 420 struct lp55xx_platform_data *pdata;
420 421 struct device_node *np = client->dev.of_node;
421 if (!pdata) { 422
422 dev_err(&client->dev, "no platform data\n"); 423 if (!client->dev.platform_data) {
423 return -EINVAL; 424 if (np) {
425 ret = lp55xx_of_populate_pdata(&client->dev, np);
426 if (ret < 0)
427 return ret;
428 } else {
429 dev_err(&client->dev, "no platform data\n");
430 return -EINVAL;
431 }
424 } 432 }
433 pdata = client->dev.platform_data;
425 434
426 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); 435 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
427 if (!chip) 436 if (!chip)
@@ -481,6 +490,7 @@ static int lp5521_remove(struct i2c_client *client)
481 490
482static const struct i2c_device_id lp5521_id[] = { 491static const struct i2c_device_id lp5521_id[] = {
483 { "lp5521", 0 }, /* Three channel chip */ 492 { "lp5521", 0 }, /* Three channel chip */
493 { "national,lp5521", 0 }, /* OF compatible */
484 { } 494 { }
485}; 495};
486MODULE_DEVICE_TABLE(i2c, lp5521_id); 496MODULE_DEVICE_TABLE(i2c, lp5521_id);