Skip to content

Commit 44b3e31

Browse files
Tin Huynhjanaszewski
authored andcommitted
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>
1 parent 825fe38 commit 44b3e31

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/leds/leds-pca955x.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* bits the chip supports.
4141
*/
4242

43+
#include <linux/acpi.h>
4344
#include <linux/module.h>
4445
#include <linux/delay.h>
4546
#include <linux/string.h>
@@ -100,6 +101,15 @@ static const struct i2c_device_id pca955x_id[] = {
100101
};
101102
MODULE_DEVICE_TABLE(i2c, pca955x_id);
102103

104+
static const struct acpi_device_id pca955x_acpi_ids[] = {
105+
{ "PCA9550", pca9550 },
106+
{ "PCA9551", pca9551 },
107+
{ "PCA9552", pca9552 },
108+
{ "PCA9553", pca9553 },
109+
{ }
110+
};
111+
MODULE_DEVICE_TABLE(acpi, pca955x_acpi_ids);
112+
103113
struct pca955x {
104114
struct mutex lock;
105115
struct pca955x_led *leds;
@@ -250,7 +260,16 @@ static int pca955x_probe(struct i2c_client *client,
250260
struct led_platform_data *pdata;
251261
int i, err;
252262

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+
}
254273
adapter = to_i2c_adapter(client->dev.parent);
255274
pdata = dev_get_platdata(&client->dev);
256275

@@ -264,7 +283,7 @@ static int pca955x_probe(struct i2c_client *client,
264283

265284
dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at "
266285
"slave address 0x%02x\n",
267-
id->name, chip->bits, client->addr);
286+
client->name, chip->bits, client->addr);
268287

269288
if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
270289
return -EIO;
@@ -358,6 +377,7 @@ static int pca955x_remove(struct i2c_client *client)
358377
static struct i2c_driver pca955x_driver = {
359378
.driver = {
360379
.name = "leds-pca955x",
380+
.acpi_match_table = ACPI_PTR(pca955x_acpi_ids),
361381
},
362382
.probe = pca955x_probe,
363383
.remove = pca955x_remove,

0 commit comments

Comments
 (0)