This patch enables ACPI support for leds-pca955x driver.
Unified · Split
| @@ -40,6 +40,7 @@ · 39 unmodified lines | ||
| 40 | 40 | * bits the chip supports. |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | +#include <linux/acpi.h> | |
| 43 | 44 | #include <linux/module.h> |
| 44 | 45 | #include <linux/delay.h> |
| 45 | 46 | #include <linux/string.h> |
| @@ -100,6 +101,15 @@ static const struct i2c_device_id pca955x_id[] = { · 54 unmodified lines | ||
| 100 | 101 | }; |
| 101 | 102 | MODULE_DEVICE_TABLE(i2c, pca955x_id); |
| 102 | 103 | |
| 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 | + | |
| 103 | 113 | struct pca955x { |
| 104 | 114 | struct mutex lock; |
| 105 | 115 | struct pca955x_led *leds; |
| @@ -250,7 +260,16 @@ static int pca955x_probe(struct i2c_client *client, · 144 unmodified lines | ||
| 250 | 260 | struct led_platform_data *pdata; |
| 251 | 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 | 273 | adapter = to_i2c_adapter(client->dev.parent); |
| 255 | 274 | pdata = dev_get_platdata(&client->dev); |
| 256 | 275 | |
| @@ -264,7 +283,7 @@ static int pca955x_probe(struct i2c_client *client, · 7 unmodified lines | ||
| 264 | 283 | |
| 265 | 284 | dev_info(&client->dev, "leds-pca955x: Using %s %d-bit LED driver at " |
| 266 | 285 | "slave address 0x%02x\n", |
| 267 | − id->name, chip->bits, client->addr); | |
| 286 | + client->name, chip->bits, client->addr); | |
| 268 | 287 | |
| 269 | 288 | if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) |
| 270 | 289 | return -EIO; |
| @@ -358,6 +377,7 @@ static int pca955x_remove(struct i2c_client *client) · 87 unmodified lines | ||
| 358 | 377 | static struct i2c_driver pca955x_driver = { |
| 359 | 378 | .driver = { |
| 360 | 379 | .name = "leds-pca955x", |
| 380 | + .acpi_match_table = ACPI_PTR(pca955x_acpi_ids), | |
| 361 | 381 | }, |
| 362 | 382 | .probe = pca955x_probe, |
| 363 | 383 | .remove = pca955x_remove, |