linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Marek Behun <marek.behun@nic.cz>
Cc: linux-leds@vger.kernel.org, "Pavel Machek" <pavel@ucw.cz>,
	"Dan Murphy" <dmurphy@ti.com>,
	"Ondřej Jirman" <megous@megous.com>,
	"Russell King" <linux@armlinux.org.uk>,
	"Andrew Lunn" <andrew@lunn.ch>,
	linux-kernel@vger.kernel.org,
	"Matthias Schiffer" <matthias.schiffer@ew.tq-group.com>,
	"Rob Herring" <robh+dt@kernel.org>,
	devicetree@vger.kernel.org
Subject: Re: [PATCH leds + devicetree v2 2/2] leds: trigger: netdev: parse `trigger-sources` from device tree
Date: Wed, 16 Sep 2020 23:46:12 +0200	[thread overview]
Message-ID: <16947964-1185-ca1b-38b6-f9829bde4105@gmail.com> (raw)
In-Reply-To: <20200916021537.106a29e5@nic.cz>

On 9/16/20 2:15 AM, Marek Behun wrote:
> On Tue, 15 Sep 2020 23:35:25 +0200
> Jacek Anaszewski <jacek.anaszewski@gmail.com> wrote:
> 
>> 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.
>>
> 
> Hmmm. Jacek, all the triggers that work with the macro
> LED_INIT_DEFAULT_TRIGGER are oneshot, timer and pattern.
> If this macro is set, they all call pattern_init function where they
> read led-pattern from fwnode.

The fact that they all call pattern_init() does not mean that
the use of flag is limited only to this type of triggers.

It has been introduced to allow initialization of default trigger
with required parameters, but in the same time, not to enforce
the same initial parameters each next time the trigger is set
for the LED.

> 
> But there is no device tree in Linux sources using this property.
> In fact the command
>    git grep led-pattern
> yields only 2 files:
>    Documentation/devicetree/bindings/leds/common.yaml
>    drivers/leds/led-core.c
> 
> What is the purpose if no device tree uses this property? Is this used
> from other fwnode sources, like acpi or efi?

This is mainly useful for debugging purposes, probably that's why
it is not present in official dts files yet.

> The reason why I am asking this is that the `led-pattern` property in
> device tree goes against the principle of device tree, that it
> shouldn't set settings settable from userspace, only describe the
> devices on the system and how they are connected to each other.

If that was a hard principle then we wouldn't have properties like
linux,default-trigger. I have once asked Rob about that - see the reply
at the and of message [0].

[0] https://lore.kernel.org/linux-leds/20181025195444.GA12737@bogus/

-- 
Best regards,
Jacek Anaszewski

  reply	other threads:[~2020-09-16 22:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 15:26 [PATCH leds + devicetree v2 0/2] Parse DT property `trigger-sources` for netdev LED trigger Marek Behún
2020-09-15 15:26 ` [PATCH leds + devicetree v2 1/2] leds: trigger: add trigger sources validating method and helper functions Marek Behún
2020-09-15 16:24   ` Marek Behun
2020-11-25 10:32   ` Pavel Machek
2020-09-15 15:26 ` [PATCH leds + devicetree v2 2/2] leds: trigger: netdev: parse `trigger-sources` from device tree Marek Behún
2020-09-15 21:35   ` Jacek Anaszewski
2020-09-16  0:15     ` Marek Behun
2020-09-16 21:46       ` Jacek Anaszewski [this message]
2020-11-25 10:42   ` Pavel Machek
2020-11-25 12:19     ` Marek Behun
2020-11-25 10:38 ` [PATCH leds + devicetree v2 0/2] Parse DT property `trigger-sources` for netdev LED trigger Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16947964-1185-ca1b-38b6-f9829bde4105@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marek.behun@nic.cz \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=megous@megous.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).