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:
parent
d6c98db2cf
commit
ce674d9098
1 changed files with 4 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue