← Documents Documentation/leds/leds-class.rst GitHub 원문 ↗

Linux 6.18.37 · LEDs

LED Handling under Linux

LED class의 userspace interface, naming, registration, blink와 hardware-trigger control contract입니다.

Source pathDocumentation/leds/leds-class.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

leds-class.rst:1-260

LED class는 brightness와 trigger를 userspace에 제공하고 `devicename:color:function` naming으로 LED의 연결 대상과 역할을 표현합니다.

Driver API는 sleep 여부가 다른 brightness 함수, classdev registration, hardware blink fallback, trigger와 협상하는 hardware control operation을 정의합니다.

LED 제어 계층
Userspace brightness 또는 trigger 선택LED class core가 driver capability 확인Hardware 지원이면 driver operation 호출지원하지 않으면 software trigger·blink fallback`LED_OFF`로 blink·hardware control 정지

Userspace와 trigger 요청이 가능한 hardware 경로를 선택합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ========================
2 LED handling under Linux
3 ========================
4
5 In its simplest form, the LED class just allows control of LEDs from
6 userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
7 LED is defined in max_brightness file. The brightness file will set the brightness
8 of the LED (taking a value 0-max_brightness). Most LEDs don't have hardware
9 brightness support so will just be turned on for non-zero brightness settings.
10
11 The class also introduces the optional concept of an LED trigger. A trigger
12 is a kernel based source of led events. Triggers can either be simple or
13 complex. A simple trigger isn't configurable and is designed to slot into
14 existing subsystems with minimal additional code. Examples are the disk-activity,
15 nand-disk and sharpsl-charge triggers. With led triggers disabled, the code
16 optimises away.
17
18 Complex triggers while available to all LEDs have LED specific
19 parameters and work on a per LED basis. The timer trigger is an example.
20 The timer trigger will periodically change the LED brightness between
21 LED_OFF and the current brightness setting. The "on" and "off" time can
22 be specified via /sys/class/leds/<device>/delay_{on,off} in milliseconds.
23 You can change the brightness value of a LED independently of the timer
24 trigger. However, if you set the brightness value to LED_OFF it will
25 also disable the timer trigger.
26
27 You can change triggers in a similar manner to the way an IO scheduler
28 is chosen (via /sys/class/leds/<device>/trigger). Trigger specific
29 parameters can appear in /sys/class/leds/<device> once a given trigger is
30 selected.
31
32
33 Design Philosophy
34 =================
35
36 The underlying design philosophy is simplicity. LEDs are simple devices
37 and the aim is to keep a small amount of code giving as much functionality
38 as possible. Please keep this in mind when suggesting enhancements.
39
40
41 LED Device Naming
42 =================
43
44 Is currently of the form:
45
46 "devicename:color:function"
47
48 - devicename:
49 it should refer to a unique identifier created by the kernel,
50 like e.g. phyN for network devices or inputN for input devices, rather
51 than to the hardware; the information related to the product and the bus
52 to which given device is hooked is available in sysfs and can be
53 retrieved using get_led_device_info.sh script from tools/leds; generally
54 this section is expected mostly for LEDs that are somehow associated with
55 other devices.
56
57 - color:
58 one of LED_COLOR_ID_* definitions from the header
59 include/dt-bindings/leds/common.h.
60
61 - function:
62 one of LED_FUNCTION_* definitions from the header
63 include/dt-bindings/leds/common.h.
64
65 If required color or function is missing, please submit a patch
66 to linux-leds@vger.kernel.org.
67
68 It is possible that more than one LED with the same color and function will
69 be required for given platform, differing only with an ordinal number.
70 In this case it is preferable to just concatenate the predefined LED_FUNCTION_*
71 name with required "-N" suffix in the driver. fwnode based drivers can use
72 function-enumerator property for that and then the concatenation will be handled
73 automatically by the LED core upon LED class device registration.
74
75 LED subsystem has also a protection against name clash, that may occur
76 when LED class device is created by a driver of hot-pluggable device and
77 it doesn't provide unique devicename section. In this case numerical
78 suffix (e.g. "_1", "_2", "_3" etc.) is added to the requested LED class
79 device name.
80
81 There might be still LED class drivers around using vendor or product name
82 for devicename, but this approach is now deprecated as it doesn't convey
83 any added value. Product information can be found in other places in sysfs
84 (see tools/leds/get_led_device_info.sh).
85
86 Examples of proper LED names:
87
88 - "red:disk"
89 - "white:flash"
90 - "red:indicator"
91 - "phy1:green:wlan"
92 - "phy3::wlan"
93 - ":kbd_backlight"
94 - "input5::kbd_backlight"
95 - "input3::numlock"
96 - "input3::scrolllock"
97 - "input3::capslock"
98 - "mmc1::status"
99 - "white:status"
100
101 get_led_device_info.sh script can be used for verifying if the LED name
102 meets the requirements pointed out here. It performs validation of the LED class
103 devicename sections and gives hints on expected value for a section in case
104 the validation fails for it. So far the script supports validation
105 of associations between LEDs and following types of devices:
106
107 - input devices
108 - ieee80211 compliant USB devices
109
110 The script is open to extensions.
111
112 There have been calls for LED properties such as color to be exported as
113 individual led class attributes. As a solution which doesn't incur as much
114 overhead, I suggest these become part of the device name. The naming scheme
115 above leaves scope for further attributes should they be needed. If sections
116 of the name don't apply, just leave that section blank.
117
118
119 Brightness setting API
120 ======================
121
122 LED subsystem core exposes following API for setting brightness:
123
124 - led_set_brightness:
125 it is guaranteed not to sleep, passing LED_OFF stops
126 blinking,
127
128 - led_set_brightness_sync:
129 for use cases when immediate effect is desired -
130 it can block the caller for the time required for accessing
131 device registers and can sleep, passing LED_OFF stops hardware
132 blinking, returns -EBUSY if software blink fallback is enabled.
133
134
135 LED registration API
136 ====================
137
138 A driver wanting to register a LED classdev for use by other drivers /
139 userspace needs to allocate and fill a led_classdev struct and then call
140 `[devm_]led_classdev_register`. If the non devm version is used the driver
141 must call led_classdev_unregister from its remove function before
142 free-ing the led_classdev struct.
143
144 If the driver can detect hardware initiated brightness changes and thus
145 wants to have a brightness_hw_changed attribute then the LED_BRIGHT_HW_CHANGED
146 flag must be set in flags before registering. Calling
147 led_classdev_notify_brightness_hw_changed on a classdev not registered with
148 the LED_BRIGHT_HW_CHANGED flag is a bug and will trigger a WARN_ON.
149
150 Hardware accelerated blink of LEDs
151 ==================================
152
153 Some LEDs can be programmed to blink without any CPU interaction. To
154 support this feature, a LED driver can optionally implement the
155 blink_set() function (see <linux/leds.h>). To set an LED to blinking,
156 however, it is better to use the API function led_blink_set(), as it
157 will check and implement software fallback if necessary.
158
159 To turn off blinking, use the API function led_brightness_set()
160 with brightness value LED_OFF, which should stop any software
161 timers that may have been required for blinking.
162
163 The blink_set() function should choose a user friendly blinking value
164 if it is called with `*delay_on==0` && `*delay_off==0` parameters. In this
165 case the driver should give back the chosen value through delay_on and
166 delay_off parameters to the leds subsystem.
167
168 Setting the brightness to zero with brightness_set() callback function
169 should completely turn off the LED and cancel the previously programmed
170 hardware blinking function, if any.
171
172 Hardware driven LEDs
173 ====================
174
175 Some LEDs can be programmed to be driven by hardware. This is not
176 limited to blink but also to turn off or on autonomously.
177 To support this feature, a LED needs to implement various additional
178 ops and needs to declare specific support for the supported triggers.
179
180 With hw control we refer to the LED driven by hardware.
181
182 LED driver must define the following value to support hw control:
183
184 - hw_control_trigger:
185 unique trigger name supported by the LED in hw control
186 mode.
187
188 LED driver must implement the following API to support hw control:
189 - hw_control_is_supported:
190 check if the flags passed by the supported trigger can
191 be parsed and activate hw control on the LED.
192
193 Return 0 if the passed flags mask is supported and
194 can be set with hw_control_set().
195
196 If the passed flags mask is not supported -EOPNOTSUPP
197 must be returned, the LED trigger will use software
198 fallback in this case.
199
200 Return a negative error in case of any other error like
201 device not ready or timeouts.
202
203 - hw_control_set:
204 activate hw control. LED driver will use the provided
205 flags passed from the supported trigger, parse them to
206 a set of mode and setup the LED to be driven by hardware
207 following the requested modes.
208
209 Set LED_OFF via the brightness_set to deactivate hw control.
210
211 Return 0 on success, a negative error number on failing to
212 apply flags.
213
214 - hw_control_get:
215 get active modes from a LED already in hw control, parse
216 them and set in flags the current active flags for the
217 supported trigger.
218
219 Return 0 on success, a negative error number on failing
220 parsing the initial mode.
221 Error from this function is NOT FATAL as the device may
222 be in a not supported initial state by the attached LED
223 trigger.
224
225 - hw_control_get_device:
226 return the device associated with the LED driver in
227 hw control. A trigger might use this to match the
228 returned device from this function with a configured
229 device for the trigger as the source for blinking
230 events and correctly enable hw control.
231 (example a netdev trigger configured to blink for a
232 particular dev match the returned dev from get_device
233 to set hw control)
234
235 Returns a pointer to a struct device or NULL if nothing
236 is currently attached.
237
238 LED driver can activate additional modes by default to workaround the
239 impossibility of supporting each different mode on the supported trigger.
240 Examples are hardcoding the blink speed to a set interval, enable special
241 feature like bypassing blink if some requirements are not met.
242
243 A trigger should first check if the hw control API are supported by the LED
244 driver and check if the trigger is supported to verify if hw control is possible,
245 use hw_control_is_supported to check if the flags are supported and only at
246 the end use hw_control_set to activate hw control.
247
248 A trigger can use hw_control_get to check if a LED is already in hw control
249 and init their flags.
250
251 When the LED is in hw control, no software blink is possible and doing so
252 will effectively disable hw control.
253
254 Known Issues
255 ============
256
257 The LED Trigger core cannot be a module as the simple trigger functions
258 would cause nightmare dependency issues. I see this as a minor issue
259 compared to the benefits the simple trigger functionality brings. The
260 rest of the LED subsystem can be modular.
261

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Userspace brightness와 trigger

1-31

가장 단순한 LED class는 userspace가 `/sys/class/leds/` 아래 LED를 제어하게 합니다. `max_brightness`가 최대값을 정의하고 `brightness`에 0부터 최대값까지 씁니다. Hardware brightness 조절이 없는 LED는 0이 아닌 값에서 단순히 켜집니다.

LED trigger는 kernel이 생성하는 LED event source입니다. Simple trigger는 설정할 수 없고 기존 subsystem에 적은 code로 연결되며 disk activity, NAND disk, SharpSL charge 등이 예입니다. Trigger support를 비활성화하면 관련 code는 최적화되어 사라집니다.

Complex trigger는 모든 LED에 사용할 수 있지만 LED별 parameter를 갖습니다. Timer trigger는 `LED_OFF`와 현재 brightness 사이를 주기적으로 전환하고 `/sys/class/leds/<device>/delay_on`, `delay_off`에서 millisecond 단위 시간을 지정합니다.

Timer trigger와 독립적으로 brightness를 바꿀 수 있지만 `LED_OFF`로 설정하면 timer trigger도 비활성화됩니다. Trigger는 `/sys/class/leds/<device>/trigger`에서 IO scheduler를 선택하는 방식과 비슷하게 바꾸며, 선택 후 trigger-specific attribute가 같은 device directory에 나타납니다.

LED trigger 사용
`trigger`에서 event source 선택Trigger-specific attribute 생성예: `delay_on`·`delay_off` 설정Trigger가 brightness event 생성`brightness=LED_OFF`이면 timer trigger 정지

Trigger 선택과 brightness·parameter 관계입니다.

========================
LED handling under Linux
========================

In its simplest form, the LED class just allows control of LEDs from
userspace. LEDs appear in /sys/class/leds/. The maximum brightness of the
LED is defined in max_brightness file. The brightness file will set the brightness
of the LED (taking a value 0-max_brightness). Most LEDs don't have hardware
brightness support so will just be turned on for non-zero brightness settings.

The class also introduces the optional concept of an LED trigger. A trigger
is a kernel based source of led events. Triggers can either be simple or
complex. A simple trigger isn't configurable and is designed to slot into
existing subsystems with minimal additional code. Examples are the disk-activity,
nand-disk and sharpsl-charge triggers. With led triggers disabled, the code
optimises away.

Complex triggers while available to all LEDs have LED specific
parameters and work on a per LED basis. The timer trigger is an example.
The timer trigger will periodically change the LED brightness between
LED_OFF and the current brightness setting. The "on" and "off" time can
be specified via /sys/class/leds/<device>/delay_{on,off} in milliseconds.
You can change the brightness value of a LED independently of the timer
trigger. However, if you set the brightness value to LED_OFF it will
also disable the timer trigger.

You can change triggers in a similar manner to the way an IO scheduler
is chosen (via /sys/class/leds/<device>/trigger). Trigger specific
parameters can appear in /sys/class/leds/<device> once a given trigger is
selected.

설계 철학과 LED device naming

32-122

LED subsystem의 설계 철학은 단순성입니다. LED는 단순한 device이므로 적은 code로 최대 기능을 제공해야 하며 enhancement를 제안할 때도 이를 유지해야 합니다.

LED device 이름은 `devicename:color:function` 형식입니다. `devicename`은 hardware product 이름보다 kernel이 만든 고유 identifier를 사용합니다. Network의 `phyN`, input의 `inputN`이 예이며 product와 bus 정보는 sysfs 또는 `tools/leds/get_led_device_info.sh`로 찾습니다.

`color`는 `include/dt-bindings/leds/common.h`의 `LED_COLOR_ID_*`, `function`은 같은 header의 `LED_FUNCTION_*` definition 중 하나입니다. 필요한 color나 function이 없으면 `linux-leds@vger.kernel.org`로 patch를 제출합니다.

LED 이름 구성
Section
`devicename`Kernel이 만든 연결 device identifier`phy1`, `input5`, `mmc1`
`color``LED_COLOR_ID_*``red`, `green`, `white`
`function``LED_FUNCTION_*``disk`, `wlan`, `kbd_backlight`

비어 있는 section도 colon 위치를 유지합니다.

같은 color와 function의 LED가 여러 개면 predefined function 이름에 `-N` suffix를 붙입니다. Fwnode driver는 `function-enumerator` property를 사용할 수 있고 LED core가 class device 등록 시 자동으로 결합합니다.

Hot-pluggable device driver가 고유 `devicename`을 제공하지 않아 이름이 충돌하면 LED subsystem은 `_1`, `_2`, `_3` 같은 numerical suffix를 추가합니다. Vendor나 product 이름을 `devicename`으로 쓰는 옛 방식은 sysfs의 다른 위치에서 product 정보를 얻을 수 있으므로 deprecated입니다.

적절한 예는 `red:disk`, `white:flash`, `phy1:green:wlan`, `phy3::wlan`, `:kbd_backlight`, `input3::numlock`, `mmc1::status` 등입니다. 적용되지 않는 section은 비워 둡니다.

`get_led_device_info.sh`는 이름의 `devicename` section을 검증하고 실패 시 예상 값을 안내합니다. 현재 input device와 IEEE 802.11 compliant USB device 연관을 지원하며 확장할 수 있습니다.

Color 같은 property를 별도 class attribute로 노출하자는 제안도 있었지만 overhead를 줄이기 위해 device 이름에 포함합니다. 현재 naming scheme은 필요 시 추가 attribute를 확장할 여지를 남깁니다.


Design Philosophy
=================

The underlying design philosophy is simplicity. LEDs are simple devices
and the aim is to keep a small amount of code giving as much functionality
as possible.  Please keep this in mind when suggesting enhancements.


LED Device Naming
=================

Is currently of the form:

        "devicename:color:function"

- devicename:
        it should refer to a unique identifier created by the kernel,
        like e.g. phyN for network devices or inputN for input devices, rather
        than to the hardware; the information related to the product and the bus
        to which given device is hooked is available in sysfs and can be
        retrieved using get_led_device_info.sh script from tools/leds; generally
        this section is expected mostly for LEDs that are somehow associated with
        other devices.

- color:
        one of LED_COLOR_ID_* definitions from the header
        include/dt-bindings/leds/common.h.

- function:
        one of LED_FUNCTION_* definitions from the header
        include/dt-bindings/leds/common.h.

If required color or function is missing, please submit a patch
to linux-leds@vger.kernel.org.

It is possible that more than one LED with the same color and function will
be required for given platform, differing only with an ordinal number.
In this case it is preferable to just concatenate the predefined LED_FUNCTION_*
name with required "-N" suffix in the driver. fwnode based drivers can use
function-enumerator property for that and then the concatenation will be handled
automatically by the LED core upon LED class device registration.

LED subsystem has also a protection against name clash, that may occur
when LED class device is created by a driver of hot-pluggable device and
it doesn't provide unique devicename section. In this case numerical
suffix (e.g. "_1", "_2", "_3" etc.) is added to the requested LED class
device name.

There might be still LED class drivers around using vendor or product name
for devicename, but this approach is now deprecated as it doesn't convey
any added value. Product information can be found in other places in sysfs
(see tools/leds/get_led_device_info.sh).

Examples of proper LED names:

  - "red:disk"
  - "white:flash"
  - "red:indicator"
  - "phy1:green:wlan"
  - "phy3::wlan"
  - ":kbd_backlight"
  - "input5::kbd_backlight"
  - "input3::numlock"
  - "input3::scrolllock"
  - "input3::capslock"
  - "mmc1::status"
  - "white:status"

get_led_device_info.sh script can be used for verifying if the LED name
meets the requirements pointed out here. It performs validation of the LED class
devicename sections and gives hints on expected value for a section in case
the validation fails for it. So far the script supports validation
of associations between LEDs and following types of devices:

        - input devices
        - ieee80211 compliant USB devices

The script is open to extensions.

There have been calls for LED properties such as color to be exported as
individual led class attributes. As a solution which doesn't incur as much
overhead, I suggest these become part of the device name. The naming scheme
above leaves scope for further attributes should they be needed. If sections
of the name don't apply, just leave that section blank.


Brightness setting API
======================

LED subsystem core exposes following API for setting brightness:

Brightness와 registration API

123-156
Brightness 설정 API
API동작
`led_set_brightness`Sleep하지 않음이 보장되며 `LED_OFF` 전달 시 blink 정지
`led_set_brightness_sync`즉시 hardware 반영을 위해 register 접근 동안 block·sleep 가능; software blink fallback이면 `-EBUSY`

Sleep 가능 여부와 blink 중지 동작이 다릅니다.

Driver가 userspace나 다른 driver에 LED class device를 제공하려면 `struct led_classdev`를 allocate·초기화하고 `[devm_]led_classdev_register`를 호출합니다. Non-devm version을 쓰면 remove function에서 struct를 free하기 전에 `led_classdev_unregister`를 호출해야 합니다.

Hardware가 시작한 brightness change를 감지해 `brightness_hw_changed` attribute를 제공하려면 등록 전에 `flags`에 `LED_BRIGHT_HW_CHANGED`를 설정합니다.

이 flag 없이 등록한 classdev에 `led_classdev_notify_brightness_hw_changed`를 호출하는 것은 bug이며 `WARN_ON`을 발생시킵니다.


    - led_set_brightness:
                it is guaranteed not to sleep, passing LED_OFF stops
                blinking,

    - led_set_brightness_sync:
                for use cases when immediate effect is desired -
                it can block the caller for the time required for accessing
                device registers and can sleep, passing LED_OFF stops hardware
                blinking, returns -EBUSY if software blink fallback is enabled.


LED registration API
====================

A driver wanting to register a LED classdev for use by other drivers /
userspace needs to allocate and fill a led_classdev struct and then call
`[devm_]led_classdev_register`. If the non devm version is used the driver
must call led_classdev_unregister from its remove function before
free-ing the led_classdev struct.

If the driver can detect hardware initiated brightness changes and thus
wants to have a brightness_hw_changed attribute then the LED_BRIGHT_HW_CHANGED
flag must be set in flags before registering. Calling
led_classdev_notify_brightness_hw_changed on a classdev not registered with
the LED_BRIGHT_HW_CHANGED flag is a bug and will trigger a WARN_ON.

Hardware accelerated blink of LEDs
==================================

Some LEDs can be programmed to blink without any CPU interaction. To
support this feature, a LED driver can optionally implement the
blink_set() function (see <linux/leds.h>). To set an LED to blinking,
however, it is better to use the API function led_blink_set(), as it

Hardware-driven LED control

187-250

일부 LED는 blink뿐 아니라 hardware가 자율적으로 켜고 끄도록 program할 수 있습니다. 이를 지원하려면 추가 operation을 구현하고 지원 trigger를 명시적으로 선언해야 합니다. 여기서 hw control은 LED가 hardware에 의해 구동되는 상태를 뜻합니다.

Driver는 `hw_control_trigger`에 hw control mode가 지원하는 유일한 trigger 이름을 정의해야 합니다.

Hardware control API
API역할주요 반환
`hw_control_is_supported`Trigger flag mask를 parse·적용할 수 있는지 확인지원 0, 미지원 `-EOPNOTSUPP`, 기타 오류 음수
`hw_control_set`Flag를 mode로 변환해 hardware control 활성화성공 0, 적용 실패 음수
`hw_control_get`현재 hardware mode를 trigger flag로 변환오류는 초기 상태 미지원일 수 있어 fatal이 아님
`hw_control_get_device`Hardware control과 연결된 source device 반환`struct device *` 또는 `NULL`

Trigger capability 확인부터 mode 적용과 상태 조회까지의 contract입니다.

`hw_control_is_supported`가 `-EOPNOTSUPP`를 반환하면 trigger는 software fallback을 사용합니다. Device not ready나 timeout 같은 다른 오류는 별도 negative error로 반환합니다.

`hw_control_set`은 trigger에서 전달된 flag를 parse해 요청 mode로 LED hardware를 설정합니다. `brightness_set`으로 `LED_OFF`를 지정하면 hw control을 비활성화합니다.

`hw_control_get` 오류는 attached trigger가 지원하지 않는 초기 hardware state일 수 있으므로 fatal로 취급하지 않습니다. `hw_control_get_device`는 netdev trigger 같은 trigger가 configured source device와 LED의 device를 비교해 hw control을 올바르게 켜는 데 사용합니다.

Driver는 모든 trigger mode를 hardware가 그대로 지원하지 못하는 경우 기본 추가 mode를 활성화할 수 있습니다. 예를 들면 blink speed를 고정 interval로 hardcode하거나 특정 조건에서 blink를 우회하는 기능입니다.

Trigger의 hardware control 협상
Driver가 hw control API와 `hw_control_trigger` 제공 여부 확인현재 trigger가 driver의 지원 trigger와 일치하는지 확인`hw_control_is_supported`로 requested flag mask 검증지원되면 `hw_control_set`으로 mode 활성화필요하면 `hw_control_get`으로 현재 flag 초기화Hardware control 중 software blink 요청 시 hw control 해제

지원 여부와 flag를 단계적으로 검증한 뒤 hardware mode를 활성화합니다.

Hardware control 상태에서는 software blink를 동시에 사용할 수 없습니다. Software blink를 시작하면 결과적으로 hw control이 비활성화됩니다.


LED driver must implement the following API to support hw control:
    - hw_control_is_supported:
                check if the flags passed by the supported trigger can
                be parsed and activate hw control on the LED.

                Return 0 if the passed flags mask is supported and
                can be set with hw_control_set().

                If the passed flags mask is not supported -EOPNOTSUPP
                must be returned, the LED trigger will use software
                fallback in this case.

                Return a negative error in case of any other error like
                device not ready or timeouts.

     - hw_control_set:
                activate hw control. LED driver will use the provided
                flags passed from the supported trigger, parse them to
                a set of mode and setup the LED to be driven by hardware
                following the requested modes.

                Set LED_OFF via the brightness_set to deactivate hw control.

                Return 0 on success, a negative error number on failing to
                apply flags.

    - hw_control_get:
                get active modes from a LED already in hw control, parse
                them and set in flags the current active flags for the
                supported trigger.

                Return 0 on success, a negative error number on failing
                parsing the initial mode.
                Error from this function is NOT FATAL as the device may
                be in a not supported initial state by the attached LED
                trigger.

    - hw_control_get_device:
                return the device associated with the LED driver in
                hw control. A trigger might use this to match the
                returned device from this function with a configured
                device for the trigger as the source for blinking
                events and correctly enable hw control.
                (example a netdev trigger configured to blink for a
                particular dev match the returned dev from get_device
                to set hw control)

                Returns a pointer to a struct device or NULL if nothing
                is currently attached.

LED driver can activate additional modes by default to workaround the
impossibility of supporting each different mode on the supported trigger.
Examples are hardcoding the blink speed to a set interval, enable special
feature like bypassing blink if some requirements are not met.

A trigger should first check if the hw control API are supported by the LED
driver and check if the trigger is supported to verify if hw control is possible,
use hw_control_is_supported to check if the flags are supported and only at
the end use hw_control_set to activate hw control.

A trigger can use hw_control_get to check if a LED is already in hw control
and init their flags.

Known issues

251-260

LED Trigger core는 module로 만들 수 없습니다. Simple trigger function이 module dependency를 매우 복잡하게 만들기 때문입니다.

문서는 이 제약을 simple trigger가 제공하는 이점에 비하면 작은 문제로 봅니다. LED subsystem의 나머지 부분은 module로 구성할 수 있습니다.

When the LED is in hw control, no software blink is possible and doing so
will effectively disable hw control.

Known Issues
============

The LED Trigger core cannot be a module as the simple trigger functions
would cause nightmare dependency issues. I see this as a minor issue
compared to the benefits the simple trigger functionality brings. The
rest of the LED subsystem can be modular.