Commit 74b69e52 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jacek Anaszewski

leds: gpio: fix and simplify error handling in gpio_leds_create

Simplify the error handling and add a missing call to fwnode_handle_put
when checking led.name.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
parent bc2c0dd8
...@@ -177,16 +177,15 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) ...@@ -177,16 +177,15 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
led.gpiod = devm_get_gpiod_from_child(dev, NULL, child); led.gpiod = devm_get_gpiod_from_child(dev, NULL, child);
if (IS_ERR(led.gpiod)) { if (IS_ERR(led.gpiod)) {
fwnode_handle_put(child); fwnode_handle_put(child);
ret = PTR_ERR(led.gpiod); return ERR_CAST(led.gpiod);
goto err;
} }
ret = fwnode_property_read_string(child, "label", &led.name); ret = fwnode_property_read_string(child, "label", &led.name);
if (ret && IS_ENABLED(CONFIG_OF) && np) if (ret && IS_ENABLED(CONFIG_OF) && np)
led.name = np->name; led.name = np->name;
if (!led.name) { if (!led.name) {
ret = -EINVAL; fwnode_handle_put(child);
goto err; return ERR_PTR(-EINVAL);
} }
fwnode_property_read_string(child, "linux,default-trigger", fwnode_property_read_string(child, "linux,default-trigger",
...@@ -210,16 +209,13 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) ...@@ -210,16 +209,13 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
ret = create_gpio_led(&led, led_dat, dev, NULL); ret = create_gpio_led(&led, led_dat, dev, NULL);
if (ret < 0) { if (ret < 0) {
fwnode_handle_put(child); fwnode_handle_put(child);
goto err; return ERR_PTR(ret);
} }
led_dat->cdev.dev->of_node = np; led_dat->cdev.dev->of_node = np;
priv->num_leds++; priv->num_leds++;
} }
return priv; return priv;
err:
return ERR_PTR(ret);
} }
static const struct of_device_id of_gpio_leds_match[] = { static const struct of_device_id of_gpio_leds_match[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment