diff options
author | Denis Osterland-Heim <denis.osterland@diehl.com> | 2020-04-21 16:09:14 +0300 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2020-04-27 12:35:11 +0300 |
commit | 44c606b0058b6670226af15229a56403d77d32dd (patch) | |
tree | 3ebd78077a8b1a7cdef5ae7c190d3d11608b2cf9 /drivers/leds/leds-pwm.c | |
parent | ba50e011b142cfe739ff2c64957dbba95797a912 (diff) | |
download | linux-44c606b0058b6670226af15229a56403d77d32dd.tar.xz |
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.c | 16 |
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) |