mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 21:51:40 +00:00
leds: core: Introduce led_get_color_name() function
This is similar to the existing led_colors[] array but is safer to use and usable by everyone. Getting string representations of color ids is useful for drivers which are handling color IDs anyways, for example for the multicolor API. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240613-cros_ec-led-v3-1-500b50f41e0f@weissschuh.net Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
1613e604df
commit
5f2e950755
@ -534,6 +534,15 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(led_compose_name);
|
||||
|
||||
const char *led_get_color_name(u8 color_id)
|
||||
{
|
||||
if (color_id >= ARRAY_SIZE(led_colors))
|
||||
return NULL;
|
||||
|
||||
return led_colors[color_id];
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(led_get_color_name);
|
||||
|
||||
enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode)
|
||||
{
|
||||
const char *state = NULL;
|
||||
|
@ -427,6 +427,16 @@ void led_sysfs_enable(struct led_classdev *led_cdev);
|
||||
int led_compose_name(struct device *dev, struct led_init_data *init_data,
|
||||
char *led_classdev_name);
|
||||
|
||||
/**
|
||||
* led_get_color_name - get string representation of color ID
|
||||
* @color_id: The LED_COLOR_ID_* constant
|
||||
*
|
||||
* Get the string name of a LED_COLOR_ID_* constant.
|
||||
*
|
||||
* Returns: A string constant or NULL on an invalid ID.
|
||||
*/
|
||||
const char *led_get_color_name(u8 color_id);
|
||||
|
||||
/**
|
||||
* led_sysfs_is_disabled - check if LED sysfs interface is disabled
|
||||
* @led_cdev: the LED to query
|
||||
|
Loading…
Reference in New Issue
Block a user