aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTin Huynh <tnhuynh@apm.com>2016-12-01 23:39:13 -0500
committerJacek Anaszewski <j.anaszewski@samsung.com>2016-12-02 03:31:50 -0500
commit44b3e31d540e917a4d2292b902ade63fa1748d9a (patch)
treeb5c9a00635483d9ebeaaf9bc95fc029857cc6695
parent825fe38a0976756fba907952d5ac9d4046068fe0 (diff)
leds: pca955x: Add ACPI support
This patch enables ACPI support for leds-pca955x driver. Signed-off-by: Tin Huynh <tnhuynh@apm.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
-rw-r--r--drivers/leds/leds-pca955x.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 840401ae9a4e..78a7ce816a47 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -40,6 +40,7 @@
40 * bits the chip supports. 40 * bits the chip supports.
41 */ 41 */
42 42
43#include <linux/acpi.h>
43#include <linux/module.h> 44#include <linux/module.h>
44#include <linux/delay.h> 45#include <linux/delay.h>
45#include <linux/string.h> 46#include <linux/string.h>
@@ -100,6 +101,15 @@ static const struct i2c_device_id pca955x_id[] = {
100}; 101};
101MODULE_DEVICE_TABLE(i2c, pca955x_id); 102MODULE_DEVICE_TABLE(i2c, pca955x_id);
102 103
104static const struct acpi_device_id pca955x_acpi_ids[] = {
105 { "PCA9550", pca9550 },
106 { "PCA9551", pca9551 },
107 { "PCA9552", pca9552 },
108 { "PCA9553", pca9553 },
109 { }
110};
111MODULE_DEVICE_TABLE(acpi, pca955x_acpi_ids);
112
103struct pca955x { 113struct pca955x {
104 struct mutex lock; 114 struct mutex lock;
105 struct pca955x_led *leds; 115 struct pca955x_led *leds;
@@ -250,7 +260,16 @@ static int pca955x_probe(struct i2c_client *client,
250 struct led_platform_data *pdata; 260 struct led_platform_data *pdata;
251 int i, err; 261 int i, err;
252 262
253 chip = &pca955x_chipdefs[id->driver_data]; 263 if (id) {
264 chip = &pca955x_chipdefs[id->driver_data];
265 } else {
266 const struct acpi_device_id *acpi_id;
267
268 acpi_id = acpi_match_device(pca955x_acpi_ids, &client->dev);
269 if (!acpi_id)
270 return -ENODEV;
271 chip = &pca955x_chipdefs[acpi_id->driver_data];
272 }
254 adapter = to_i2c_adapter(client->dev.parent); 273 adapter = to_i2c_adapter(client->dev.parent);
255 pdata = dev_get_platdata(&client->dev); 274 pdata = dev_get_platdata(&client->dev);
256 275
@@ -264,7 +283,7 @@ static int pca955x_probe(struct i2c_client *client,
264 283
265 dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at " 284 dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at "
266 "slave address 0x%02x\n", 285 "slave address 0x%02x\n",
267 id->name, chip->bits, client->addr); 286 client->name, chip->bits, client->addr);
268 287
269 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) 288 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
270 return -EIO; 289 return -EIO;
@@ -358,6 +377,7 @@ static int pca955x_remove(struct i2c_client *client)
358static struct i2c_driver pca955x_driver = { 377static struct i2c_driver pca955x_driver = {
359 .driver = { 378 .driver = {
360 .name = "leds-pca955x", 379 .name = "leds-pca955x",
380 .acpi_match_table = ACPI_PTR(pca955x_acpi_ids),
361 }, 381 },
362 .probe = pca955x_probe, 382 .probe = pca955x_probe,
363 .remove = pca955x_remove, 383 .remove = pca955x_remove,