Commit 69e73935 authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Benjamin Cabé
Browse files

led: check for valid brightness range at API level

The API specifies that brightness is 0 to 100, no point checking it in
the individual drivers.

Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
parent 551c1363
Loading
Loading
Loading
Loading
+0 −5
Changes for drivers/led/ht16k33.c: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -135,11 +135,6 @@ static int ht16k33_led_set_brightness(const struct device *dev, uint32_t led,
	uint8_t dim;
	uint8_t cmd;

	if (value < dev_data->min_brightness ||
	    value > dev_data->max_brightness) {
		return -EINVAL;
	}

	dim = (value * (HT16K33_DIMMING_LEVELS - 1)) / dev_data->max_brightness;
	cmd = HT16K33_CMD_DIMMING_SET | dim;

+0 −5
Changes for drivers/led/lp3943.c: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -174,11 +174,6 @@ static int lp3943_led_set_brightness(const struct device *dev, uint32_t led,
	int ret;
	uint8_t reg, val, mode;

	if (value < dev_data->min_brightness ||
			value > dev_data->max_brightness) {
		return -EINVAL;
	}

	/* Use DIM0 for LEDs 0 to 7 and DIM1 for LEDs 8 to 15 */
	if (led < 8) {
		mode = LP3943_DIM0;
+0 −10
Changes for drivers/led/lp5562.c: 0 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -613,11 +613,6 @@ static int lp5562_program_set_brightness(const struct device *dev,
	struct led_data *dev_data = &data->dev_data;
	uint8_t val;

	if ((brightness < dev_data->min_brightness) ||
			(brightness > dev_data->max_brightness)) {
		return -EINVAL;
	}

	val = (brightness * 0xFF) / dev_data->max_brightness;

	return lp5562_program_command(dev, engine, command_index,
@@ -848,11 +843,6 @@ static int lp5562_led_set_brightness(const struct device *dev, uint32_t led,
	uint8_t val, reg;
	enum lp5562_led_sources current_source;

	if ((value < dev_data->min_brightness) ||
			(value > dev_data->max_brightness)) {
		return -EINVAL;
	}

	ret = lp5562_get_led_source(dev, led, &current_source);
	if (ret) {
		return ret;
+0 −5
Changes for drivers/led/pca9633.c: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -125,11 +125,6 @@ static int pca9633_led_set_brightness(const struct device *dev, uint32_t led,
	struct led_data *dev_data = &data->dev_data;
	uint8_t val;

	if (value < dev_data->min_brightness ||
	    value > dev_data->max_brightness) {
		return -EINVAL;
	}

	/* Set the LED brightness value */
	val = (value * 255U) / dev_data->max_brightness;
	if (i2c_reg_write_byte_dt(&config->i2c,
+0 −5
Changes for drivers/led/tlc59108.c: 0 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -146,11 +146,6 @@ static int tlc59108_led_set_brightness(const struct device *dev, uint32_t led,
		return -EINVAL;
	}

	if (value < dev_data->min_brightness ||
	    value > dev_data->max_brightness) {
		return -EINVAL;
	}

	/* Set the LED brightness value */
	val = (value * 255U) / dev_data->max_brightness;
	if (i2c_reg_write_byte_dt(&config->i2c, TLC59108_PWM_BASE + led, val)) {
Loading