xref: /OK3568_Linux_fs/kernel/Documentation/leds/ledtrig-oneshot.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun====================
2*4882a593SmuzhiyunOne-shot LED Trigger
3*4882a593Smuzhiyun====================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThis is a LED trigger useful for signaling the user of an event where there are
6*4882a593Smuzhiyunno clear trap points to put standard led-on and led-off settings.  Using this
7*4882a593Smuzhiyuntrigger, the application needs only to signal the trigger when an event has
8*4882a593Smuzhiyunhappened, than the trigger turns the LED on and than keeps it off for a
9*4882a593Smuzhiyunspecified amount of time.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunThis trigger is meant to be usable both for sporadic and dense events.  In the
12*4882a593Smuzhiyunfirst case, the trigger produces a clear single controlled blink for each
13*4882a593Smuzhiyunevent, while in the latter it keeps blinking at constant rate, as to signal
14*4882a593Smuzhiyunthat the events are arriving continuously.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunA one-shot LED only stays in a constant state when there are no events.  An
17*4882a593Smuzhiyunadditional "invert" property specifies if the LED has to stay off (normal) or
18*4882a593Smuzhiyunon (inverted) when not rearmed.
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunThe trigger can be activated from user space on led class devices as shown
21*4882a593Smuzhiyunbelow::
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun  echo oneshot > trigger
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunThis adds sysfs attributes to the LED that are documented in:
26*4882a593SmuzhiyunDocumentation/ABI/testing/sysfs-class-led-trigger-oneshot
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunExample use-case: network devices, initialization::
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun  echo oneshot > trigger # set trigger for this led
31*4882a593Smuzhiyun  echo 33 > delay_on     # blink at 1 / (33 + 33) Hz on continuous traffic
32*4882a593Smuzhiyun  echo 33 > delay_off
33*4882a593Smuzhiyun
34*4882a593Smuzhiyuninterface goes up::
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun  echo 1 > invert # set led as normally-on, turn the led on
37*4882a593Smuzhiyun
38*4882a593Smuzhiyunpacket received/transmitted::
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun  echo 1 > shot # led starts blinking, ignored if already blinking
41*4882a593Smuzhiyun
42*4882a593Smuzhiyuninterface goes down::
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun  echo 0 > invert # set led as normally-off, turn the led off
45