diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2016-09-14 14:55:43 -0400 |
---|---|---|
committer | Jacek Anaszewski <j.anaszewski@samsung.com> | 2016-09-15 10:49:43 -0400 |
commit | 74b69e5246d13840963b7b23e21dbab541cb26d2 (patch) | |
tree | 1b1d3c6db1a207331486d1e8bc4452ffcfa9bf24 /drivers/leds/leds-gpio.c | |
parent | bc2c0dd85a0a31505ca2f92bef891ddac9126725 (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/leds-gpio.c')
-rw-r--r-- | drivers/leds/leds-gpio.c | 12 |
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) | |||
177 | led.gpiod = devm_get_gpiod_from_child(dev, NULL, child); | 177 | led.gpiod = devm_get_gpiod_from_child(dev, NULL, child); |
178 | if (IS_ERR(led.gpiod)) { | 178 | if (IS_ERR(led.gpiod)) { |
179 | fwnode_handle_put(child); | 179 | fwnode_handle_put(child); |
180 | ret = PTR_ERR(led.gpiod); | 180 | return ERR_CAST(led.gpiod); |
181 | goto err; | ||
182 | } | 181 | } |
183 | 182 | ||
184 | ret = fwnode_property_read_string(child, "label", &led.name); | 183 | ret = fwnode_property_read_string(child, "label", &led.name); |
185 | if (ret && IS_ENABLED(CONFIG_OF) && np) | 184 | if (ret && IS_ENABLED(CONFIG_OF) && np) |
186 | led.name = np->name; | 185 | led.name = np->name; |
187 | if (!led.name) { | 186 | if (!led.name) { |
188 | ret = -EINVAL; | 187 | fwnode_handle_put(child); |
189 | goto err; | 188 | return ERR_PTR(-EINVAL); |
190 | } | 189 | } |
191 | 190 | ||
192 | fwnode_property_read_string(child, "linux,default-trigger", | 191 | 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 | ret = create_gpio_led(&led, led_dat, dev, NULL); | 209 | ret = create_gpio_led(&led, led_dat, dev, NULL); |
211 | if (ret < 0) { | 210 | if (ret < 0) { |
212 | fwnode_handle_put(child); | 211 | fwnode_handle_put(child); |
213 | goto err; | 212 | return ERR_PTR(ret); |
214 | } | 213 | } |
215 | led_dat->cdev.dev->of_node = np; | 214 | led_dat->cdev.dev->of_node = np; |
216 | priv->num_leds++; | 215 | priv->num_leds++; |
217 | } | 216 | } |
218 | 217 | ||
219 | return priv; | 218 | return priv; |
220 | |||
221 | err: | ||
222 | return ERR_PTR(ret); | ||
223 | } | 219 | } |
224 | 220 | ||
225 | static const struct of_device_id of_gpio_leds_match[] = { | 221 | static const struct of_device_id of_gpio_leds_match[] = { |