]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
leds: class: Add flag to avoid automatic renaming of LED devices
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 26 May 2024 18:17:16 +0000 (20:17 +0200)
committerLee Jones <lee@kernel.org>
Fri, 14 Jun 2024 09:09:40 +0000 (10:09 +0100)
Add a mechanism for drivers to opt-out of the automatic device renaming
on conflicts.
Those drivers will provide their own conflict resolution.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20240526-cros_ec-kbd-led-framework-v3-2-ee577415a521@weissschuh.net
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/led-class.c
include/linux/leds.h

index c298355d5b7d7fd34ec6d422079e9609ba83f8fc..2f08c20702f3f7a078431b6fef47661bd42705cf 100644 (file)
@@ -503,6 +503,8 @@ int led_classdev_register_ext(struct device *parent,
        ret = led_classdev_next_name(proposed_name, final_name, sizeof(final_name));
        if (ret < 0)
                return ret;
+       else if (ret && led_cdev->flags & LED_REJECT_NAME_CONFLICT)
+               return -EEXIST;
        else if (ret)
                dev_warn(parent, "Led %s renamed to %s due to name collision\n",
                         proposed_name, final_name);
index 6300313c46b79957a2febfc5a312eab8d7fd9a05..36663ac6c58a1a0539d8b0231023152c7fbc9da5 100644 (file)
@@ -107,6 +107,7 @@ struct led_classdev {
 #define LED_BRIGHT_HW_CHANGED  BIT(21)
 #define LED_RETAIN_AT_SHUTDOWN BIT(22)
 #define LED_INIT_DEFAULT_TRIGGER BIT(23)
+#define LED_REJECT_NAME_CONFLICT BIT(24)
 
        /* set_brightness_work / blink_timer flags, atomic, private. */
        unsigned long           work_flags;