summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-pwm.c
diff options
context:
space:
mode:
authorDenis Osterland-Heim <denis.osterland@diehl.com>2020-04-21 15:09:14 +0200
committerPavel Machek <pavel@ucw.cz>2020-04-27 11:35:11 +0200
commit44c606b0058b6670226af15229a56403d77d32dd (patch)
tree3ebd78077a8b1a7cdef5ae7c190d3d11608b2cf9 /drivers/leds/leds-pwm.c
parentleds: tlc591xxt: hide error on EPROBE_DEFER (diff)
downloadlinux-44c606b0058b6670226af15229a56403d77d32dd.tar.xz
linux-44c606b0058b6670226af15229a56403d77d32dd.zip
leds: pwm: check result of led_pwm_set() in led_pwm_add()
led_pwm_set() now returns an error when setting the PWM fails. Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com> Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers/leds/leds-pwm.c')
-rw-r--r--drivers/leds/leds-pwm.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 6c8a724aac51..ef7b91bd2064 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -91,15 +91,21 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
pwm_init_state(led_data->pwm, &led_data->pwmstate);
ret = devm_led_classdev_register(dev, &led_data->cdev);
- if (ret == 0) {
- priv->num_leds++;
- led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
- } else {
+ if (ret) {
dev_err(dev, "failed to register PWM led for %s: %d\n",
led->name, ret);
+ return ret;
}
- return ret;
+ ret = led_pwm_set(&led_data->cdev, led_data->cdev.brightness);
+ if (ret) {
+ dev_err(dev, "failed to set led PWM value for %s: %d",
+ led->name, ret);
+ return ret;
+ }
+
+ priv->num_leds++;
+ return 0;
}
static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)