drivers: led: lp50xx: fix led index

The led identifer should refer to devicetree ordering, not to the index
used by the controller. This way, it will be possible to deactivate
some leds or to reorganize the indexing if necessary.

Signed-off-by: Mathieu Anquetin <mathieu.anquetin@groupe-cahors.com>
This commit is contained in:
Mathieu Anquetin 2023-07-19 09:29:30 +02:00 committed by Carles Cufí
commit ce674d9098

View file

@ -94,14 +94,11 @@ struct lp50xx_data {
static const struct led_info *lp50xx_led_to_info(
const struct lp50xx_config *config, uint32_t led)
{
const struct led_info *led_info = NULL;
if (led < config->num_leds) {
return &config->leds_info[led];
}
for (uint8_t i = 0; i < config->num_leds; i++) {
if (config->leds_info[i].index == led) {
led_info = &config->leds_info[i];
}
}
return led_info;
return NULL;
}
static int lp50xx_get_info(const struct device *dev, uint32_t led,