Skip to content

Commit 39e56e9

Browse files
fabiobaltierikartben
authored andcommitted
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 <[email protected]>
1 parent 6f47466 commit 39e56e9

File tree

7 files changed

+4
-18
lines changed

7 files changed

+4
-18
lines changed

drivers/led/is31fl3194.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ static int is31fl3194_set_brightness(const struct device *dev, uint32_t led, uin
145145
return -ENOTSUP;
146146
}
147147

148-
if (value > LED_BRIGTHNESS_MAX) {
149-
return -EINVAL;
150-
}
151-
152148
/* Rescale 0..100 to 0..255 */
153149
value = value * 255 / LED_BRIGTHNESS_MAX;
154150

drivers/led/is31fl3216a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int is31fl3216a_led_set_brightness(const struct device *dev,
111111
int status;
112112
uint8_t pwm_value;
113113

114-
if (led > IS31FL3216A_MAX_LEDS - 1 || value > LED_BRIGTHNESS_MAX) {
114+
if (led > IS31FL3216A_MAX_LEDS - 1) {
115115
return -EINVAL;
116116
}
117117

drivers/led/led_gpio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int led_gpio_set_brightness(const struct device *dev, uint32_t led, uint8
3030
const struct led_gpio_config *config = dev->config;
3131
const struct gpio_dt_spec *led_gpio;
3232

33-
if ((led >= config->num_leds) || (value > LED_BRIGTHNESS_MAX)) {
33+
if (led >= config->num_leds) {
3434
return -EINVAL;
3535
}
3636

drivers/led/led_pwm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int led_pwm_set_brightness(const struct device *dev,
5858
const struct led_pwm_config *config = dev->config;
5959
const struct pwm_dt_spec *dt_led;
6060

61-
if (led >= config->num_leds || value > LED_BRIGTHNESS_MAX) {
61+
if (led >= config->num_leds) {
6262
return -EINVAL;
6363
}
6464

drivers/led/lp50xx.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ static int lp50xx_set_brightness(const struct device *dev,
124124
return -ENODEV;
125125
}
126126

127-
if (value > LED_BRIGTHNESS_MAX) {
128-
LOG_ERR("%s: brightness value out of bounds: val=%d, max=%d",
129-
dev->name, value, LED_BRIGTHNESS_MAX);
130-
return -EINVAL;
131-
}
132-
133127
buf[0] = LP50XX_LED0_BRIGHTNESS(config->num_modules) + led_info->index;
134128
buf[1] = (value * 0xff) / LED_BRIGTHNESS_MAX;
135129

drivers/led/lp5569.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int lp5569_led_set_brightness(const struct device *dev, uint32_t led, uin
4949
uint8_t val;
5050
int ret;
5151

52-
if (led >= LP5569_NUM_LEDS || brightness > LED_BRIGTHNESS_MAX) {
52+
if (led >= LP5569_NUM_LEDS) {
5353
return -EINVAL;
5454
}
5555

drivers/led/ncp5623.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ static int ncp5623_set_brightness(const struct device *dev, uint32_t led, uint8_
100100
return -ENODEV;
101101
}
102102

103-
if (value > LED_BRIGTHNESS_MAX) {
104-
return -EINVAL;
105-
}
106-
107103
if (led_info->num_colors != 1) {
108104
return -ENOTSUP;
109105
}

0 commit comments

Comments
 (0)