All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: core: avoid error message when a USB LED device is unplugged
@ 2016-01-19 20:42 Heiner Kallweit
  2016-01-22  8:45 ` Jacek Anaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2016-01-19 20:42 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds

When a USB LED device is unplugged the remove call chain calls
led_classdev_unregister which tries to switch the LED off.
As the device has been removed already this results in a ENODEV
error message in dmesg.
Avoid this error message by ignoring ENODEV in calls from
led_classdev_unregister if the LED device is flagged as pluggable.

Therefore a new flag LED_HW_PLUGGABLE was introduced which should be set by
all LED drivers handling pluggable LED devices (mainly USB LED devices).

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/leds/led-class.c | 2 ++
 drivers/leds/led-core.c  | 5 ++++-
 include/linux/leds.h     | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 14139c3..aa84e5b 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 19e1e60..ad684b6 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 4429887..24413a8 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. If no non-blocking version can be provided
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] leds: core: avoid error message when a USB LED device is unplugged
  2016-01-19 20:42 [PATCH] leds: core: avoid error message when a USB LED device is unplugged Heiner Kallweit
@ 2016-01-22  8:45 ` Jacek Anaszewski
  2016-01-22 20:40   ` Heiner Kallweit
  0 siblings, 1 reply; 4+ messages in thread
From: Jacek Anaszewski @ 2016-01-22  8:45 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: linux-leds

Hi Heiner,

Could you rebase this patch on the top of devel branch
of LED git, please?

I am getting an error while applying it:

error: short SHA1 19e1e60 is ambiguous.
fatal: sha1 information is lacking or useless (drivers/leds/led-core.c).
Repository lacks necessary blobs to fall back on 3-way merge.

It may have happened that you had some patches that are not in mainline
kernel in the repository you produced the patch from. It is also
possible that this is an issue with the git version I am using, so this
would clarify the situation.

Thanks in advance.

Best Regards,
Jacek Anaszewski

On 01/19/2016 09:42 PM, Heiner Kallweit wrote:
> When a USB LED device is unplugged the remove call chain calls
> led_classdev_unregister which tries to switch the LED off.
> As the device has been removed already this results in a ENODEV
> error message in dmesg.
> Avoid this error message by ignoring ENODEV in calls from
> led_classdev_unregister if the LED device is flagged as pluggable.
>
> Therefore a new flag LED_HW_PLUGGABLE was introduced which should be set by
> all LED drivers handling pluggable LED devices (mainly USB LED devices).
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>   drivers/leds/led-class.c | 2 ++
>   drivers/leds/led-core.c  | 5 ++++-
>   include/linux/leds.h     | 2 ++
>   3 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index 14139c3..aa84e5b 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 19e1e60..ad684b6 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 4429887..24413a8 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. If no non-blocking version can be provided
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] leds: core: avoid error message when a USB LED device is unplugged
  2016-01-22  8:45 ` Jacek Anaszewski
@ 2016-01-22 20:40   ` Heiner Kallweit
  2016-01-22 22:03     ` Jacek Anaszewski
  0 siblings, 1 reply; 4+ messages in thread
From: Heiner Kallweit @ 2016-01-22 20:40 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds

Am 22.01.2016 um 09:45 schrieb Jacek Anaszewski:
> Hi Heiner,
> 
> Could you rebase this patch on the top of devel branch
> of LED git, please?
> 
> I am getting an error while applying it:
> 
> error: short SHA1 19e1e60 is ambiguous.
> fatal: sha1 information is lacking or useless (drivers/leds/led-core.c).
> Repository lacks necessary blobs to fall back on 3-way merge.
> 
> It may have happened that you had some patches that are not in mainline
> kernel in the repository you produced the patch from. It is also
> possible that this is an issue with the git version I am using, so this
> would clarify the situation.
> 
Reason is the changed comment as it affects the context of this patch.
Will rebase it and resend.

Regards, Heiner

> Thanks in advance.
> 
> Best Regards,
> Jacek Anaszewski
> 
> On 01/19/2016 09:42 PM, Heiner Kallweit wrote:
>> When a USB LED device is unplugged the remove call chain calls
>> led_classdev_unregister which tries to switch the LED off.
>> As the device has been removed already this results in a ENODEV
>> error message in dmesg.
>> Avoid this error message by ignoring ENODEV in calls from
>> led_classdev_unregister if the LED device is flagged as pluggable.
>>
>> Therefore a new flag LED_HW_PLUGGABLE was introduced which should be set by
>> all LED drivers handling pluggable LED devices (mainly USB LED devices).
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>   drivers/leds/led-class.c | 2 ++
>>   drivers/leds/led-core.c  | 5 ++++-
>>   include/linux/leds.h     | 2 ++
>>   3 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
>> index 14139c3..aa84e5b 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 19e1e60..ad684b6 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 4429887..24413a8 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. If no non-blocking version can be provided
>>
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] leds: core: avoid error message when a USB LED device is unplugged
  2016-01-22 20:40   ` Heiner Kallweit
@ 2016-01-22 22:03     ` Jacek Anaszewski
  0 siblings, 0 replies; 4+ messages in thread
From: Jacek Anaszewski @ 2016-01-22 22:03 UTC (permalink / raw)
  To: Heiner Kallweit, Jacek Anaszewski; +Cc: linux-leds

On 01/22/2016 09:40 PM, Heiner Kallweit wrote:
> Am 22.01.2016 um 09:45 schrieb Jacek Anaszewski:
>> Hi Heiner,
>>
>> Could you rebase this patch on the top of devel branch
>> of LED git, please?
>>
>> I am getting an error while applying it:
>>
>> error: short SHA1 19e1e60 is ambiguous.
>> fatal: sha1 information is lacking or useless (drivers/leds/led-core.c).
>> Repository lacks necessary blobs to fall back on 3-way merge.
>>
>> It may have happened that you had some patches that are not in mainline
>> kernel in the repository you produced the patch from. It is also
>> possible that this is an issue with the git version I am using, so this
>> would clarify the situation.
>>
> Reason is the changed comment as it affects the context of this patch.
> Will rebase it and resend.

Changed comment should only result in a conflict. This was not
the case, the crucial line was:

error: short SHA1 19e1e60 is ambiguous

It occurs also with git 2.1.4. Nevertheless, version 2 applies
smoothly.

Thanks,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-22 22:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-19 20:42 [PATCH] leds: core: avoid error message when a USB LED device is unplugged Heiner Kallweit
2016-01-22  8:45 ` Jacek Anaszewski
2016-01-22 20:40   ` Heiner Kallweit
2016-01-22 22:03     ` Jacek Anaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.