summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-tlc591xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-tlc591xx.c')
-rw-r--r--drivers/leds/leds-tlc591xx.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index cb7bd1353f9f..6605e08a042a 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -8,7 +8,6 @@
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
@@ -135,7 +134,7 @@ static const struct regmap_config tlc591xx_regmap = {
.max_register = 0x1e,
};
-static const struct of_device_id of_tlc591xx_leds_match[] = {
+static const struct of_device_id of_tlc591xx_leds_match[] __maybe_unused = {
{ .compatible = "ti,tlc59116",
.data = &tlc59116 },
{ .compatible = "ti,tlc59108",
@@ -145,10 +144,9 @@ static const struct of_device_id of_tlc591xx_leds_match[] = {
MODULE_DEVICE_TABLE(of, of_tlc591xx_leds_match);
static int
-tlc591xx_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+tlc591xx_probe(struct i2c_client *client)
{
- struct device_node *np, *child;
+ struct device_node *np;
struct device *dev = &client->dev;
const struct tlc591xx *tlc591xx;
struct tlc591xx_priv *priv;
@@ -184,22 +182,20 @@ tlc591xx_probe(struct i2c_client *client,
if (err < 0)
return err;
- for_each_available_child_of_node(np, child) {
+ for_each_available_child_of_node_scoped(np, child) {
struct tlc591xx_led *led;
struct led_init_data init_data = {};
init_data.fwnode = of_fwnode_handle(child);
err = of_property_read_u32(child, "reg", &reg);
- if (err) {
- of_node_put(child);
+ if (err)
return err;
- }
+
if (reg < 0 || reg >= tlc591xx->max_leds ||
- priv->leds[reg].active) {
- of_node_put(child);
+ priv->leds[reg].active)
return -EINVAL;
- }
+
led = &priv->leds[reg];
led->active = true;
@@ -209,12 +205,10 @@ tlc591xx_probe(struct i2c_client *client,
led->ldev.max_brightness = TLC591XX_MAX_BRIGHTNESS;
err = devm_led_classdev_register_ext(dev, &led->ldev,
&init_data);
- if (err < 0) {
- of_node_put(child);
+ if (err < 0)
return dev_err_probe(dev, err,
"couldn't register LED %s\n",
led->ldev.name);
- }
}
return 0;
}