* [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
@ 2023-12-17 18:46 Heiner Kallweit
2023-12-17 19:16 ` Heiner Kallweit
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Heiner Kallweit @ 2023-12-17 18:46 UTC (permalink / raw)
To: Pavel Machek, Lee Jones
Cc: linux-leds@vger.kernel.org, netdev@vger.kernel.org, Andrew Lunn
If hw doesn't support sw control of the LED and we switch to a mode
not supported by hw, currently we get lots of errors because neither
brigthness_set() nor brithness_set_blocking() is set.
Deal with this by not falling back to sw control, and return
-EOPNOTSUPP to the user. Note that we still store the new mode.
This is needed in case an intermediate unsupported mode is necessary
to switch from one supported mode to another.
Add a comment explaining how a driver for such hw is supposed to behave.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/leds/trigger/ledtrig-netdev.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
index d76214fa9..27f090bc8 100644
--- a/drivers/leds/trigger/ledtrig-netdev.c
+++ b/drivers/leds/trigger/ledtrig-netdev.c
@@ -38,6 +38,16 @@
* tx - LED blinks on transmitted data
* rx - LED blinks on receive data
*
+ * Note: If the user selects a mode that is not supported by hw, default
+ * behavior is to fall back to software control of the LED. However not every
+ * hw supports software control. LED callbacks brightness_set() and
+ * brightness_set_blocking() are NULL in this case. hw_control_is_supported()
+ * should use available means supported by hw to inform the user that selected
+ * mode isn't supported by hw. This could be switching off the LED or any
+ * hw blink mode. If software control fallback isn't possible, we return
+ * -EOPNOTSUPP to the user, but still store the selected mode. This is needed
+ * in case an intermediate unsupported mode is necessary to switch from one
+ * supported mode to another.
*/
struct led_netdev_data {
@@ -306,6 +316,7 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
size_t size, enum led_trigger_netdev_modes attr)
{
struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
+ struct led_classdev *led_cdev = trigger_data->led_cdev;
unsigned long state, mode = trigger_data->mode;
int ret;
int bit;
@@ -345,6 +356,10 @@ static ssize_t netdev_led_attr_store(struct device *dev, const char *buf,
trigger_data->mode = mode;
trigger_data->hw_control = can_hw_control(trigger_data);
+ if (!led_cdev->brightness_set && !led_cdev->brightness_set_blocking &&
+ !trigger_data->hw_control)
+ return -EOPNOTSUPP;
+
set_baseline_state(trigger_data);
return size;
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2023-12-17 18:46 [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control Heiner Kallweit
@ 2023-12-17 19:16 ` Heiner Kallweit
2024-01-11 8:44 ` Lee Jones
2023-12-18 9:45 ` Andrew Lunn
2023-12-21 15:05 ` (subset) " Lee Jones
2 siblings, 1 reply; 8+ messages in thread
From: Heiner Kallweit @ 2023-12-17 19:16 UTC (permalink / raw)
To: Pavel Machek, Lee Jones
Cc: linux-leds@vger.kernel.org, netdev@vger.kernel.org, Andrew Lunn
On 17.12.2023 19:46, Heiner Kallweit wrote:
> If hw doesn't support sw control of the LED and we switch to a mode
> not supported by hw, currently we get lots of errors because neither
> brigthness_set() nor brithness_set_blocking() is set.
> Deal with this by not falling back to sw control, and return
> -EOPNOTSUPP to the user. Note that we still store the new mode.
> This is needed in case an intermediate unsupported mode is necessary
> to switch from one supported mode to another.
>
> Add a comment explaining how a driver for such hw is supposed to behave.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
For whatever reason this patch (original version and resubmit) doesn't
show up on linux-leds patchwork. In netdev patchwork it's visible.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2023-12-17 19:16 ` Heiner Kallweit
@ 2024-01-11 8:44 ` Lee Jones
2024-01-11 10:24 ` Heiner Kallweit
0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2024-01-11 8:44 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Pavel Machek, linux-leds@vger.kernel.org, netdev@vger.kernel.org,
Andrew Lunn
On Sun, 17 Dec 2023, Heiner Kallweit wrote:
> On 17.12.2023 19:46, Heiner Kallweit wrote:
> > If hw doesn't support sw control of the LED and we switch to a mode
> > not supported by hw, currently we get lots of errors because neither
> > brigthness_set() nor brithness_set_blocking() is set.
> > Deal with this by not falling back to sw control, and return
> > -EOPNOTSUPP to the user. Note that we still store the new mode.
> > This is needed in case an intermediate unsupported mode is necessary
> > to switch from one supported mode to another.
> >
> > Add a comment explaining how a driver for such hw is supposed to behave.
> >
> > Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> > ---
>
> For whatever reason this patch (original version and resubmit) doesn't
> show up on linux-leds patchwork. In netdev patchwork it's visible.
Never used it. Do you have a link?
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2024-01-11 8:44 ` Lee Jones
@ 2024-01-11 10:24 ` Heiner Kallweit
2024-01-11 10:32 ` Lee Jones
0 siblings, 1 reply; 8+ messages in thread
From: Heiner Kallweit @ 2024-01-11 10:24 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds@vger.kernel.org, netdev@vger.kernel.org,
Andrew Lunn
On 11.01.2024 09:44, Lee Jones wrote:
> On Sun, 17 Dec 2023, Heiner Kallweit wrote:
>
>> On 17.12.2023 19:46, Heiner Kallweit wrote:
>>> If hw doesn't support sw control of the LED and we switch to a mode
>>> not supported by hw, currently we get lots of errors because neither
>>> brigthness_set() nor brithness_set_blocking() is set.
>>> Deal with this by not falling back to sw control, and return
>>> -EOPNOTSUPP to the user. Note that we still store the new mode.
>>> This is needed in case an intermediate unsupported mode is necessary
>>> to switch from one supported mode to another.
>>>
>>> Add a comment explaining how a driver for such hw is supposed to behave.
>>>
>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>> ---
>>
>> For whatever reason this patch (original version and resubmit) doesn't
>> show up on linux-leds patchwork. In netdev patchwork it's visible.
>
> Never used it. Do you have a link?
>
This is the original patch in netdev patchwork
https://patchwork.kernel.org/project/netdevbpf/patch/91e9f4c6-d869-45be-be72-ac49a3c3b818@gmail.com/
This is my patches in linux-leds patchwork. The one from Dec 6th is missing here.
https://patches.linaro.org/project/linux-leds/list/?series=&submitter=6702&state=*&q=&archive=&delegate=
However the resubmitted one showed up later.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2024-01-11 10:24 ` Heiner Kallweit
@ 2024-01-11 10:32 ` Lee Jones
2024-01-11 11:19 ` Heiner Kallweit
0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2024-01-11 10:32 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Pavel Machek, linux-leds@vger.kernel.org, netdev@vger.kernel.org,
Andrew Lunn
On Thu, 11 Jan 2024, Heiner Kallweit wrote:
> On 11.01.2024 09:44, Lee Jones wrote:
> > On Sun, 17 Dec 2023, Heiner Kallweit wrote:
> >
> >> On 17.12.2023 19:46, Heiner Kallweit wrote:
> >>> If hw doesn't support sw control of the LED and we switch to a mode
> >>> not supported by hw, currently we get lots of errors because neither
> >>> brigthness_set() nor brithness_set_blocking() is set.
> >>> Deal with this by not falling back to sw control, and return
> >>> -EOPNOTSUPP to the user. Note that we still store the new mode.
> >>> This is needed in case an intermediate unsupported mode is necessary
> >>> to switch from one supported mode to another.
> >>>
> >>> Add a comment explaining how a driver for such hw is supposed to behave.
> >>>
> >>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> >>> ---
> >>
> >> For whatever reason this patch (original version and resubmit) doesn't
> >> show up on linux-leds patchwork. In netdev patchwork it's visible.
> >
> > Never used it. Do you have a link?
> >
> This is the original patch in netdev patchwork
> https://patchwork.kernel.org/project/netdevbpf/patch/91e9f4c6-d869-45be-be72-ac49a3c3b818@gmail.com/
>
> This is my patches in linux-leds patchwork. The one from Dec 6th is missing here.
> https://patches.linaro.org/project/linux-leds/list/?series=&submitter=6702&state=*&q=&archive=&delegate=
> However the resubmitted one showed up later.
AFAIW, that's not the official Patchwork for LEDs.
And as I say, I don't use it, so I'm not really in a position to comment.
Do we still have something outstanding?
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2024-01-11 10:32 ` Lee Jones
@ 2024-01-11 11:19 ` Heiner Kallweit
0 siblings, 0 replies; 8+ messages in thread
From: Heiner Kallweit @ 2024-01-11 11:19 UTC (permalink / raw)
To: Lee Jones
Cc: Pavel Machek, linux-leds@vger.kernel.org, netdev@vger.kernel.org,
Andrew Lunn
On 11.01.2024 11:32, Lee Jones wrote:
> On Thu, 11 Jan 2024, Heiner Kallweit wrote:
>
>> On 11.01.2024 09:44, Lee Jones wrote:
>>> On Sun, 17 Dec 2023, Heiner Kallweit wrote:
>>>
>>>> On 17.12.2023 19:46, Heiner Kallweit wrote:
>>>>> If hw doesn't support sw control of the LED and we switch to a mode
>>>>> not supported by hw, currently we get lots of errors because neither
>>>>> brigthness_set() nor brithness_set_blocking() is set.
>>>>> Deal with this by not falling back to sw control, and return
>>>>> -EOPNOTSUPP to the user. Note that we still store the new mode.
>>>>> This is needed in case an intermediate unsupported mode is necessary
>>>>> to switch from one supported mode to another.
>>>>>
>>>>> Add a comment explaining how a driver for such hw is supposed to behave.
>>>>>
>>>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>>>> ---
>>>>
>>>> For whatever reason this patch (original version and resubmit) doesn't
>>>> show up on linux-leds patchwork. In netdev patchwork it's visible.
>>>
>>> Never used it. Do you have a link?
>>>
>> This is the original patch in netdev patchwork
>> https://patchwork.kernel.org/project/netdevbpf/patch/91e9f4c6-d869-45be-be72-ac49a3c3b818@gmail.com/
>>
>> This is my patches in linux-leds patchwork. The one from Dec 6th is missing here.
>> https://patches.linaro.org/project/linux-leds/list/?series=&submitter=6702&state=*&q=&archive=&delegate=
>> However the resubmitted one showed up later.
>
> AFAIW, that's not the official Patchwork for LEDs.
>
> And as I say, I don't use it, so I'm not really in a position to comment.
>
> Do we still have something outstanding?
>
Thanks for asking. No, that's it for now.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2023-12-17 18:46 [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control Heiner Kallweit
2023-12-17 19:16 ` Heiner Kallweit
@ 2023-12-18 9:45 ` Andrew Lunn
2023-12-21 15:05 ` (subset) " Lee Jones
2 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2023-12-18 9:45 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Pavel Machek, Lee Jones, linux-leds@vger.kernel.org,
netdev@vger.kernel.org
On Sun, Dec 17, 2023 at 07:46:42PM +0100, Heiner Kallweit wrote:
> If hw doesn't support sw control of the LED and we switch to a mode
> not supported by hw, currently we get lots of errors because neither
> brigthness_set() nor brithness_set_blocking() is set.
> Deal with this by not falling back to sw control, and return
> -EOPNOTSUPP to the user. Note that we still store the new mode.
> This is needed in case an intermediate unsupported mode is necessary
> to switch from one supported mode to another.
>
> Add a comment explaining how a driver for such hw is supposed to behave.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: (subset) [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
2023-12-17 18:46 [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control Heiner Kallweit
2023-12-17 19:16 ` Heiner Kallweit
2023-12-18 9:45 ` Andrew Lunn
@ 2023-12-21 15:05 ` Lee Jones
2 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2023-12-21 15:05 UTC (permalink / raw)
To: Pavel Machek, Lee Jones, Heiner Kallweit; +Cc: linux-leds, netdev, Andrew Lunn
On Sun, 17 Dec 2023 19:46:42 +0100, Heiner Kallweit wrote:
> If hw doesn't support sw control of the LED and we switch to a mode
> not supported by hw, currently we get lots of errors because neither
> brigthness_set() nor brithness_set_blocking() is set.
> Deal with this by not falling back to sw control, and return
> -EOPNOTSUPP to the user. Note that we still store the new mode.
> This is needed in case an intermediate unsupported mode is necessary
> to switch from one supported mode to another.
>
> [...]
Applied, thanks!
[1/1] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control
commit: cb2ab62ae08af6a5ef1e3aaf954a8eaadd6ce17a
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-01-11 11:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-17 18:46 [PATCH RESUBMIT] leds: trigger: netdev: add core support for hw not supporting fallback to LED sw control Heiner Kallweit
2023-12-17 19:16 ` Heiner Kallweit
2024-01-11 8:44 ` Lee Jones
2024-01-11 10:24 ` Heiner Kallweit
2024-01-11 10:32 ` Lee Jones
2024-01-11 11:19 ` Heiner Kallweit
2023-12-18 9:45 ` Andrew Lunn
2023-12-21 15:05 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).