Commit 39e56e9a authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Benjamin Cabé
Browse files

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: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent 6f474668
Loading
Loading
Loading
Loading
+0 −4
Changes for drivers/led/is31fl3194.c: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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;

+1 −1
Changes for drivers/led/is31fl3216a.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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;
	}

+1 −1
Changes for drivers/led/led_gpio.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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;
	}

+1 −1
Changes for drivers/led/led_pwm.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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;
	}

+0 −6
Changes for drivers/led/lp50xx.c: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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;

Loading