From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Rafał Miłecki" <zajec5@gmail.com>,
"Greg KH" <gregkh@linuxfoundation.org>,
"Richard Purdie" <rpurdie@rpsys.net>,
"Felipe Balbi" <balbi@kernel.org>,
"Peter Chen" <hzpeterchen@gmail.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"Rafał Miłecki" <rafal@milecki.pl>,
"Jonathan Corbet" <corbet@lwn.net>,
"Ezequiel Garcia" <ezequiel@vanguardiasur.com.ar>,
"Boris Brezillon" <boris.brezillon@free-electrons.com>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Stephan Linz" <linz@li-pro.net>,
"open list" <linux-kernel@vger.kernel.org>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
"open list:LED SUBSYSTEM" <linux-leds@vger.kernel.org>
Subject: Re: [PATCH V4] leds: trigger: Introduce an USB port trigger
Date: Fri, 02 Sep 2016 08:54:47 +0200 [thread overview]
Message-ID: <caccb909-bf51-8f67-cd57-de407e576afc@samsung.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1609011032040.1386-100000@iolanthe.rowland.org>
On 09/01/2016 04:36 PM, Alan Stern wrote:
> On Thu, 1 Sep 2016, Jacek Anaszewski wrote:
>
>> On 09/01/2016 07:25 AM, Rafał Miłecki wrote:
>>> On 31 August 2016 at 21:00, Rafał Miłecki <zajec5@gmail.com> wrote:
>>>> On 31 August 2016 at 20:23, Alan Stern <stern@rowland.harvard.edu> wrote:
>>>>> On Tue, 30 Aug 2016, Rafał Miłecki wrote:
>>>>>> Not really as it won't cover some pretty common use cases. Many home
>>>>>> routers have few USB ports (2-5) and only 1 USB LED. It has to be
>>>>>> possible to assign few USB ports to a single LED (trigger). That way
>>>>>> LED should be turned on (and kept on) if there is at least 1 USB
>>>>>> device connected. You obviously can't do:
>>>>>> echo "usb1-1 usb1-2 usb2-1" > /sys/class/leds/foo/trigger
>>>>>>
>>>>>> This was already brought up by Rob (who mentioned CPU trigger) and I
>>>>>> replied him pretty much the same way in:
>>>>>> https://lkml.org/lkml/2016/7/29/38
>>>>>> (reply starts with "Anyway, the serious limitation I see").
>>>>>
>>>>> The code for a bunch of triggers must already be written. What would
>>>>> the user do if he wanted to flash a single LED in response to both
>>>>> CPU activity and MTD activity? If not
>>>>>
>>>>> echo "cpu mtd" >/sys/class/leds/foo/trigger
>>>>>
>>>>> then what?
>>>>
>>>> Well, it sounds like a new feature then. Shall we add an extra API
>>>> with a request function for turning LED on? It could internally count
>>>> how many requests were raised and keep LED on as long as there is at
>>>> least 1 left. I guess we should implement it in trigger "subsystem"
>>>> (if I can call it so). Does it sound like a good plan?
>>>
>>> I'm pretty sure noone ever planned to have more than 1 trigger
>>> assigned to a single LED. I just realized there will be a problem with
>>> proposed solution: sysfs files conflict.
>>>
>>> Consider 2 existing triggers for a moment:
>>> 1) oneshot: it creates following sysfs files:
>>> /sys/class/leds/foo/delay_on
>>> /sys/class/leds/foo/delay_off
>>> /sys/class/leds/foo/invert
>>> /sys/class/leds/foo/shot
>>> 2) timer: it creates following sysfs files:
>>> /sys/class/leds/foo/delay_on
>>> /sys/class/leds/foo/delay_off
>>>
>>> Activating both of them will probably cause a WARNING in sysfs. They
>>> can't coexist :(
>>>
>>> We should probably have per-trigger subdirs, e.g.:
>>> /sys/class/leds/foo/trigger-oneshot/delay_on
>>> /sys/class/leds/foo/trigger-oneshot/delay_off
>>> /sys/class/leds/foo/trigger-oneshot/invert
>>> /sys/class/leds/foo/trigger-oneshot/shot
>>> /sys/class/leds/foo/trigger-timer/delay_on
>>> /sys/class/leds/foo/trigger-timer/delay_off
>>> but implementing it now would break the ABI.
>>>
>>> One workaround I can see is doing triggers V2, they:
>>> 1) Would put sysfs files in /sys/class/leds/foo/trigger-bar/
>>> 2) Use new API for *requesting* LED to be on/off
>>> 3) There would be a counter of requests in V2 API
>>> 4) Multiple triggers V2 would be allowed to be used (assigned) at the same time
>>
>> Currently we support only triggers dedicated to specific type of
>> devices. Even in case of triggers that don't expose custom sysfs
>> attributes, registered with led_trigger_register_simple(), device
>> drivers have to generate trigger event with dedicated function, e.g:
>>
>> - ledtrig-cpu: void ledtrig_cpu(enum cpu_led_event ledevt)
>> - ledtrig-disk: void ledtrig_disk_activity(void)
>> - ledtrig-mtd: void ledtrig_mtd_activity(void)
>>
>> If one wanted to have the LED notified by different type of devices,
>> then they would have to implement a trigger that would exposed all
>> required types of API.
>>
>> Unfortunately, there are many possible combinations of
>> triggers and that doesn't sound sane to add a new one when someone
>> will find it useful. Of course it would entail adding a call to the
>> new trigger API in the drivers, which doesn't seem like something
>> acceptable in the mainline.
>
> Maybe it would make more sense, in this case, to allow only three
> possibilities for a USB port activity trigger. Toggle the LED
> whenever:
>
> There is activity on the specified port, or
>
> There is any activity on any port on the specified hub, or
>
> There is any USB activity on any port.
>
> That ought to cover most of the normal use cases, and it would be
> simple enough to implement.
What would be the benefit of having a USB port activity trigger,
for which we would be specifying the port to observe, but in the same
time we would react on any activity on any port (cases 1 and 3)?
--
Best regards,
Jacek Anaszewski
next prev parent reply other threads:[~2016-09-02 6:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-25 8:03 Rafał Miłecki
2016-08-25 12:49 ` Greg KH
2016-08-26 15:38 ` Rafał Miłecki
2016-08-30 12:05 ` Greg KH
2016-08-30 20:28 ` Rafał Miłecki
2016-08-30 20:54 ` Alan Stern
2016-08-30 21:14 ` Rafał Miłecki
2016-08-31 18:23 ` Alan Stern
2016-08-31 19:00 ` Rafał Miłecki
2016-09-01 5:25 ` Rafał Miłecki
2016-09-01 7:26 ` Jacek Anaszewski
2016-09-01 14:36 ` Alan Stern
2016-09-02 6:54 ` Jacek Anaszewski [this message]
2016-09-02 14:33 ` Alan Stern
2016-09-03 15:06 ` Jacek Anaszewski
2016-09-03 15:17 ` Alan Stern
2016-09-03 19:12 ` Jacek Anaszewski
2016-09-04 0:24 ` Alan Stern
2016-09-05 9:28 ` Rafał Miłecki
2016-10-10 14:25 ` Pavel Machek
2016-10-10 14:25 ` 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=caccb909-bf51-8f67-cd57-de407e576afc@samsung.com \
--to=j.anaszewski@samsung.com \
--cc=balbi@kernel.org \
--cc=boris.brezillon@free-electrons.com \
--cc=corbet@lwn.net \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=hzpeterchen@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linz@li-pro.net \
--cc=rafal@milecki.pl \
--cc=rpurdie@rpsys.net \
--cc=stern@rowland.harvard.edu \
--cc=zajec5@gmail.com \
/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
all inboxes | Powered by JetHome®