lkml.org 
[lkml]   [2020]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH leds + devicetree v2 2/2] leds: trigger: netdev: parse `trigger-sources` from device tree
From
Date
Hi Marek,

On 9/15/20 5:26 PM, Marek Behún wrote:
> Allow setting netdev LED trigger as default when given LED DT node has
> the `trigger-sources` property pointing to a node corresponding to a
> network device.
>
> The specific netdev trigger mode is determined from the `function` LED
> property.
>
> Example:
> eth0: ethernet@30000 {
> compatible = "xyz";
> #trigger-source-cells = <0>;
> };
>
> led {
> color = <LED_COLOR_ID_GREEN>;
> function = LED_FUNCTION_LINK;
> trigger-sources = <&eth0>;
> };
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: devicetree@vger.kernel.org
> ---
> drivers/leds/trigger/ledtrig-netdev.c | 80 ++++++++++++++++++++++++++-
> include/dt-bindings/leds/common.h | 1 +
> 2 files changed, 80 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/trigger/ledtrig-netdev.c b/drivers/leds/trigger/ledtrig-netdev.c
> index d5e774d830215..99fc2f0c68e12 100644
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c
> @@ -20,6 +20,7 @@
[...]

> static int netdev_trig_activate(struct led_classdev *led_cdev)
> {
> struct led_netdev_data *trigger_data;
> @@ -414,10 +479,17 @@ static int netdev_trig_activate(struct led_classdev *led_cdev)
> trigger_data->last_activity = 0;
>
> led_set_trigger_data(led_cdev, trigger_data);
> + netdev_trig_of_parse(led_cdev, trigger_data);

Please be aware of LED_INIT_DEFAULT_TRIGGER flag - it would make
sense to use it here so as not to unnecessarily call
netdev_trig_of_parse(), which makes sense only if trigger will be
default, I presume.

See timer_trig_activate() in drivers/leds/trigger/ledtrig-timer.c
for reference.

--
Best regards,
Jacek Anaszewski

\
 
 \ /
  Last update: 2020-09-15 23:39    [W:0.086 / U:9.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site