Skip to content

Commit

Permalink
Revert "Revert "leds: class: Store the color index in struct led_clas…
Browse files Browse the repository at this point in the history
…sdev""

This reverts commit 7893eca.
  • Loading branch information
jackpot51 committed May 1, 2024
1 parent 1a1c483 commit b57f055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/leds/led-class.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ int led_classdev_register_ext(struct device *parent,
fwnode_property_read_u32(init_data->fwnode,
"max-brightness",
&led_cdev->max_brightness);

if (fwnode_property_present(init_data->fwnode, "color"))
fwnode_property_read_u32(init_data->fwnode, "color",
&led_cdev->color);
}
} else {
proposed_name = led_cdev->name;
Expand All @@ -500,6 +504,9 @@ int led_classdev_register_ext(struct device *parent,
if (ret < 0)
return ret;

if (led_cdev->color >= LED_COLOR_ID_MAX)
dev_warn(parent, "LED %s color identifier out of range\n", final_name);

mutex_init(&led_cdev->led_access);
mutex_lock(&led_cdev->led_access);
led_cdev->dev = device_create_with_groups(&leds_class, parent, 0,
Expand Down
1 change: 1 addition & 0 deletions include/linux/leds.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct led_classdev {
const char *name;
unsigned int brightness;
unsigned int max_brightness;
unsigned int color;
int flags;

/* Lower 16 bits reflect status */
Expand Down

0 comments on commit b57f055

Please sign in to comment.