]> git.karo-electronics.de Git - linux-beck.git/commitdiff
leds: pca963x: Add ACPI support
authorTin Huynh <tnhuynh@apm.com>
Tue, 29 Nov 2016 04:18:20 +0000 (11:18 +0700)
committerJacek Anaszewski <j.anaszewski@samsung.com>
Wed, 30 Nov 2016 10:10:09 +0000 (11:10 +0100)
This patch enables ACPI support for leds-pca963x driver.

Signed-off-by: Tin Huynh <tnhuynh@apm.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
drivers/leds/leds-pca963x.c

index 46fbf935944ac9d82f483c381ebdcce1097de053..ded1e4dac36af465c9a0dd5833965ae3a3ef6275 100644 (file)
@@ -25,6 +25,7 @@
  * or by adding the 'nxp,hw-blink' property to the DTS.
  */
 
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/string.h>
@@ -96,6 +97,15 @@ static const struct i2c_device_id pca963x_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, pca963x_id);
 
+static const struct acpi_device_id pca963x_acpi_ids[] = {
+       { "PCA9632", pca9633 },
+       { "PCA9633", pca9633 },
+       { "PCA9634", pca9634 },
+       { "PCA9635", pca9635 },
+       { }
+};
+MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
+
 struct pca963x_led;
 
 struct pca963x {
@@ -360,7 +370,16 @@ static int pca963x_probe(struct i2c_client *client,
        struct pca963x_chipdef *chip;
        int i, err;
 
-       chip = &pca963x_chipdefs[id->driver_data];
+       if (id) {
+               chip = &pca963x_chipdefs[id->driver_data];
+       } else {
+               const struct acpi_device_id *acpi_id;
+
+               acpi_id = acpi_match_device(pca963x_acpi_ids, &client->dev);
+               if (!acpi_id)
+                       return -ENODEV;
+               chip = &pca963x_chipdefs[acpi_id->driver_data];
+       }
        pdata = dev_get_platdata(&client->dev);
 
        if (!pdata) {
@@ -464,6 +483,7 @@ static struct i2c_driver pca963x_driver = {
        .driver = {
                .name   = "leds-pca963x",
                .of_match_table = of_match_ptr(of_pca963x_match),
+               .acpi_match_table = ACPI_PTR(pca963x_acpi_ids),
        },
        .probe  = pca963x_probe,
        .remove = pca963x_remove,