Skip to content

Commit b57f055

Browse files
committed
Revert "Revert "leds: class: Store the color index in struct led_classdev""
This reverts commit 7893eca.
1 parent 1a1c483 commit b57f055

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/leds/led-class.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ int led_classdev_register_ext(struct device *parent,
491491
fwnode_property_read_u32(init_data->fwnode,
492492
"max-brightness",
493493
&led_cdev->max_brightness);
494+
495+
if (fwnode_property_present(init_data->fwnode, "color"))
496+
fwnode_property_read_u32(init_data->fwnode, "color",
497+
&led_cdev->color);
494498
}
495499
} else {
496500
proposed_name = led_cdev->name;
@@ -500,6 +504,9 @@ int led_classdev_register_ext(struct device *parent,
500504
if (ret < 0)
501505
return ret;
502506

507+
if (led_cdev->color >= LED_COLOR_ID_MAX)
508+
dev_warn(parent, "LED %s color identifier out of range\n", final_name);
509+
503510
mutex_init(&led_cdev->led_access);
504511
mutex_lock(&led_cdev->led_access);
505512
led_cdev->dev = device_create_with_groups(&leds_class, parent, 0,

include/linux/leds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct led_classdev {
100100
const char *name;
101101
unsigned int brightness;
102102
unsigned int max_brightness;
103+
unsigned int color;
103104
int flags;
104105

105106
/* Lower 16 bits reflect status */

0 commit comments

Comments
 (0)