led: drop a bunch of now redundant brightness validations
This check is now part of the API, individual drivers don't need to do it. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
6f47466899
commit
39e56e9a71
7 changed files with 4 additions and 18 deletions
|
@ -145,10 +145,6 @@ static int is31fl3194_set_brightness(const struct device *dev, uint32_t led, uin
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (value > LED_BRIGTHNESS_MAX) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Rescale 0..100 to 0..255 */
|
||||
value = value * 255 / LED_BRIGTHNESS_MAX;
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ static int is31fl3216a_led_set_brightness(const struct device *dev,
|
|||
int status;
|
||||
uint8_t pwm_value;
|
||||
|
||||
if (led > IS31FL3216A_MAX_LEDS - 1 || value > LED_BRIGTHNESS_MAX) {
|
||||
if (led > IS31FL3216A_MAX_LEDS - 1) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ static int led_gpio_set_brightness(const struct device *dev, uint32_t led, uint8
|
|||
const struct led_gpio_config *config = dev->config;
|
||||
const struct gpio_dt_spec *led_gpio;
|
||||
|
||||
if ((led >= config->num_leds) || (value > LED_BRIGTHNESS_MAX)) {
|
||||
if (led >= config->num_leds) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ static int led_pwm_set_brightness(const struct device *dev,
|
|||
const struct led_pwm_config *config = dev->config;
|
||||
const struct pwm_dt_spec *dt_led;
|
||||
|
||||
if (led >= config->num_leds || value > LED_BRIGTHNESS_MAX) {
|
||||
if (led >= config->num_leds) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,12 +124,6 @@ static int lp50xx_set_brightness(const struct device *dev,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (value > LED_BRIGTHNESS_MAX) {
|
||||
LOG_ERR("%s: brightness value out of bounds: val=%d, max=%d",
|
||||
dev->name, value, LED_BRIGTHNESS_MAX);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf[0] = LP50XX_LED0_BRIGHTNESS(config->num_modules) + led_info->index;
|
||||
buf[1] = (value * 0xff) / LED_BRIGTHNESS_MAX;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ static int lp5569_led_set_brightness(const struct device *dev, uint32_t led, uin
|
|||
uint8_t val;
|
||||
int ret;
|
||||
|
||||
if (led >= LP5569_NUM_LEDS || brightness > LED_BRIGTHNESS_MAX) {
|
||||
if (led >= LP5569_NUM_LEDS) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,10 +100,6 @@ static int ncp5623_set_brightness(const struct device *dev, uint32_t led, uint8_
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (value > LED_BRIGTHNESS_MAX) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (led_info->num_colors != 1) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue