diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 14139c337312c574c82a98bee4c163834cad6bc5..aa84e5b375931825e71b23f6e2d1eefc7c3bea17 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -245,6 +245,8 @@ void led_classdev_unregister(struct led_classdev *led_cdev) up_write(&led_cdev->trigger_lock); #endif + led_cdev->flags |= LED_UNREGISTERING; + /* Stop blinking */ led_stop_software_blink(led_cdev); diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 19e1e60dfaa354585ca01e2ffdc2a47f29c49c3b..ad684b6d0b724bc4b249102879c12202f6e6be50 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -98,7 +98,10 @@ static void set_brightness_delayed(struct work_struct *ws) led_cdev->delayed_set_value); else ret = -ENOTSUPP; - if (ret < 0) + if (ret < 0 && + /* LED HW might have been unplugged, therefore don't warn */ + !(ret == -ENODEV && (led_cdev->flags & LED_UNREGISTERING) && + (led_cdev->flags & LED_HW_PLUGGABLE))) dev_err(led_cdev->dev, "Setting an LED's brightness failed (%d)\n", ret); } diff --git a/include/linux/leds.h b/include/linux/leds.h index e3470e732ede8a99125b8407c06428d97c8a7af6..f203a8f89d30d0f3e214b43d2c72efea1bdad9f9 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -39,6 +39,7 @@ struct led_classdev { /* Lower 16 bits reflect status */ #define LED_SUSPENDED (1 << 0) +#define LED_UNREGISTERING (1 << 1) /* Upper 16 bits reflect control information */ #define LED_CORE_SUSPENDRESUME (1 << 16) #define LED_BLINK_ONESHOT (1 << 17) @@ -48,6 +49,7 @@ struct led_classdev { #define LED_BLINK_DISABLE (1 << 21) #define LED_SYSFS_DISABLE (1 << 22) #define LED_DEV_CAP_FLASH (1 << 23) +#define LED_HW_PLUGGABLE (1 << 24) /* Set LED brightness level * Must not sleep. Use brightness_set_blocking for drivers