summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-pca963x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-pca963x.c')
-rw-r--r--drivers/leds/leds-pca963x.c66
1 files changed, 22 insertions, 44 deletions
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 5c0908113e38..9b4ef070d956 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -25,7 +25,6 @@
* 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>
@@ -33,6 +32,7 @@
#include <linux/leds.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/platform_data/leds-pca963x.h>
@@ -97,15 +97,6 @@ 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 {
@@ -287,16 +278,15 @@ static int pca963x_blink_set(struct led_classdev *led_cdev,
return 0;
}
-#if IS_ENABLED(CONFIG_OF)
static struct pca963x_platform_data *
-pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
+pca963x_get_pdata(struct i2c_client *client, struct pca963x_chipdef *chip)
{
- struct device_node *np = client->dev.of_node, *child;
struct pca963x_platform_data *pdata;
struct led_info *pca963x_leds;
+ struct fwnode_handle *child;
int count;
- count = of_get_child_count(np);
+ count = device_get_child_node_count(&client->dev);
if (!count || count > chip->n_leds)
return ERR_PTR(-ENODEV);
@@ -305,18 +295,22 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
if (!pca963x_leds)
return ERR_PTR(-ENOMEM);
- for_each_child_of_node(np, child) {
+ device_for_each_child_node(&client->dev, child) {
struct led_info led = {};
u32 reg;
int res;
- res = of_property_read_u32(child, "reg", &reg);
+ res = fwnode_property_read_u32(child, "reg", &reg);
if ((res != 0) || (reg >= chip->n_leds))
continue;
- led.name =
- of_get_property(child, "label", NULL) ? : child->name;
- led.default_trigger =
- of_get_property(child, "linux,default-trigger", NULL);
+
+ res = fwnode_property_read_string(child, "label", &led.name);
+ if ((res != 0) && is_of_node(child))
+ led.name = to_of_node(child)->name;
+
+ fwnode_property_read_string(child, "linux,default-trigger",
+ &led.default_trigger);
+
pca963x_leds[reg] = led;
}
pdata = devm_kzalloc(&client->dev,
@@ -328,22 +322,23 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
pdata->leds.num_leds = chip->n_leds;
/* default to open-drain unless totem pole (push-pull) is specified */
- if (of_property_read_bool(np, "nxp,totem-pole"))
+ if (device_property_read_bool(&client->dev, "nxp,totem-pole"))
pdata->outdrv = PCA963X_TOTEM_POLE;
else
pdata->outdrv = PCA963X_OPEN_DRAIN;
/* default to software blinking unless hardware blinking is specified */
- if (of_property_read_bool(np, "nxp,hw-blink"))
+ if (device_property_read_bool(&client->dev, "nxp,hw-blink"))
pdata->blink_type = PCA963X_HW_BLINK;
else
pdata->blink_type = PCA963X_SW_BLINK;
- if (of_property_read_u32(np, "nxp,period-scale", &chip->scaling))
+ if (device_property_read_u32(&client->dev, "nxp,period-scale",
+ &chip->scaling))
chip->scaling = 1000;
/* default to non-inverted output, unless inverted is specified */
- if (of_property_read_bool(np, "nxp,inverted-out"))
+ if (device_property_read_bool(&client->dev, "nxp,inverted-out"))
pdata->dir = PCA963X_INVERTED;
else
pdata->dir = PCA963X_NORMAL;
@@ -359,13 +354,6 @@ static const struct of_device_id of_pca963x_match[] = {
{},
};
MODULE_DEVICE_TABLE(of, of_pca963x_match);
-#else
-static struct pca963x_platform_data *
-pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
-{
- return ERR_PTR(-ENODEV);
-}
-#endif
static int pca963x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@@ -376,20 +364,11 @@ static int pca963x_probe(struct i2c_client *client,
struct pca963x_chipdef *chip;
int i, err;
- 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];
- }
+ chip = &pca963x_chipdefs[id->driver_data];
pdata = dev_get_platdata(&client->dev);
if (!pdata) {
- pdata = pca963x_dt_init(client, chip);
+ pdata = pca963x_get_pdata(client, chip);
if (IS_ERR(pdata)) {
dev_warn(&client->dev, "could not parse configuration\n");
pdata = NULL;
@@ -495,8 +474,7 @@ static int pca963x_remove(struct i2c_client *client)
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),
+ .of_match_table = of_pca963x_match,
},
.probe = pca963x_probe,
.remove = pca963x_remove,