summaryrefslogtreecommitdiff
path: root/drivers/leds
diff options
context:
space:
mode:
authorHeiner Kallweit <hkallweit1@gmail.com>2016-09-14 20:55:43 +0200
committerJacek Anaszewski <j.anaszewski@samsung.com>2016-09-15 16:49:43 +0200
commit74b69e5246d13840963b7b23e21dbab541cb26d2 (patch)
tree1b1d3c6db1a207331486d1e8bc4452ffcfa9bf24 /drivers/leds
parentbc2c0dd85a0a31505ca2f92bef891ddac9126725 (diff)
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: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-gpio.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index ab273f85ac3c..d400dcaf4d29 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -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);
if (IS_ERR(led.gpiod)) {
fwnode_handle_put(child);
- ret = PTR_ERR(led.gpiod);
- goto err;
+ return ERR_CAST(led.gpiod);
}
ret = fwnode_property_read_string(child, "label", &led.name);
if (ret && IS_ENABLED(CONFIG_OF) && np)
led.name = np->name;
if (!led.name) {
- ret = -EINVAL;
- goto err;
+ fwnode_handle_put(child);
+ return ERR_PTR(-EINVAL);
}
fwnode_property_read_string(child, "linux,default-trigger",
@@ -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);
if (ret < 0) {
fwnode_handle_put(child);
- goto err;
+ return ERR_PTR(ret);
}
led_dat->cdev.dev->of_node = np;
priv->num_leds++;
}
return priv;
-
-err:
- return ERR_PTR(ret);
}
static const struct of_device_id of_gpio_leds_match[] = {