]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/leds/leds-lp5562.c
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[karo-tx-linux.git] / drivers / leds / leds-lp5562.c
index 513f2390ca2d8d279079c2939c109dae06c05f45..cbd856dac15041c3c6396741aa7913bfee85ab34 100644 (file)
@@ -515,12 +515,20 @@ static int lp5562_probe(struct i2c_client *client,
        int ret;
        struct lp55xx_chip *chip;
        struct lp55xx_led *led;
-       struct lp55xx_platform_data *pdata = client->dev.platform_data;
-
-       if (!pdata) {
-               dev_err(&client->dev, "no platform data\n");
-               return -EINVAL;
+       struct lp55xx_platform_data *pdata;
+       struct device_node *np = client->dev.of_node;
+
+       if (!client->dev.platform_data) {
+               if (np) {
+                       ret = lp55xx_of_populate_pdata(&client->dev, np);
+                       if (ret < 0)
+                               return ret;
+               } else {
+                       dev_err(&client->dev, "no platform data\n");
+                       return -EINVAL;
+               }
        }
+       pdata = client->dev.platform_data;
 
        chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
@@ -583,9 +591,19 @@ static const struct i2c_device_id lp5562_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, lp5562_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id of_lp5562_leds_match[] = {
+       { .compatible = "ti,lp5562", },
+       {},
+};
+
+MODULE_DEVICE_TABLE(of, of_lp5562_leds_match);
+#endif
+
 static struct i2c_driver lp5562_driver = {
        .driver = {
                .name   = "lp5562",
+               .of_match_table = of_match_ptr(of_lp5562_leds_match),
        },
        .probe          = lp5562_probe,
        .remove         = lp5562_remove,