diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2020-09-19 20:02:57 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2020-09-26 21:56:43 +0200 |
commit | a448fcf19c9c5d3ddd9066accbd8d28c4950bb9f (patch) | |
tree | abcc2590b9e52a19288b8627c4ad6198e24a8b68 /drivers/leds | |
parent | d3ab963cf980151f5f0ba16d842ddc80b232d9c0 (diff) | |
download | linux-stable-a448fcf19c9c5d3ddd9066accbd8d28c4950bb9f.tar.gz linux-stable-a448fcf19c9c5d3ddd9066accbd8d28c4950bb9f.tar.bz2 linux-stable-a448fcf19c9c5d3ddd9066accbd8d28c4950bb9f.zip |
leds: lm36274: don't iterate through children since there is only one
Do not use device_for_each_child_node. Since this driver works only with
once child node present, use device_get_next_child_node instead.
This also saves one level of indentation.
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Dan Murphy <dmurphy@ti.com>
Tested-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-lm36274.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index 4a9f786bb972..e0fce74a7667 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -72,40 +72,36 @@ static int lm36274_parse_dt(struct lm36274 *chip) char label[LED_MAX_NAME_SIZE]; struct device *dev = &chip->pdev->dev; const char *name; - int child_cnt; - int ret = -EINVAL; + int ret; /* There should only be 1 node */ - child_cnt = device_get_child_node_count(dev); - if (child_cnt != 1) + if (device_get_child_node_count(dev) != 1) return -EINVAL; - device_for_each_child_node(dev, child) { - ret = fwnode_property_read_string(child, "label", &name); - if (ret) - snprintf(label, sizeof(label), "%s::", - chip->pdev->name); - else - snprintf(label, sizeof(label), "%s:%s", - chip->pdev->name, name); - - chip->num_leds = fwnode_property_count_u32(child, "led-sources"); - if (chip->num_leds <= 0) - return -ENODEV; - - ret = fwnode_property_read_u32_array(child, "led-sources", - chip->led_sources, - chip->num_leds); - if (ret) { - dev_err(dev, "led-sources property missing\n"); - return ret; - } - - fwnode_property_read_string(child, "linux,default-trigger", - &chip->led_dev.default_trigger); + child = device_get_next_child_node(dev, NULL); + + ret = fwnode_property_read_string(child, "label", &name); + if (ret) + snprintf(label, sizeof(label), "%s::", chip->pdev->name); + else + snprintf(label, sizeof(label), "%s:%s", chip->pdev->name, name); + chip->num_leds = fwnode_property_count_u32(child, "led-sources"); + if (chip->num_leds <= 0) + return -ENODEV; + + ret = fwnode_property_read_u32_array(child, "led-sources", + chip->led_sources, chip->num_leds); + if (ret) { + dev_err(dev, "led-sources property missing\n"); + return ret; } + fwnode_property_read_string(child, "linux,default-trigger", + &chip->led_dev.default_trigger); + + fwnode_handle_put(child); + chip->lmu_data.regmap = chip->regmap; chip->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT; chip->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB; |