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>
This commit is contained in:
Denis Osterland-Heim 2020-04-21 13:09:14 +00:00 коммит произвёл Pavel Machek
Родитель ba50e011b1
Коммит 44c606b005
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -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)