← Documents Documentation/leds/uleds.rst GitHub 원문 ↗

Linux 6.18.37 · LEDs

Userspace LEDs

Character device file handle로 virtual LED를 만들고 brightness를 수신하는 uleds interface입니다.

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

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

1. 요약·해설

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

요약·해설

uleds.rst:1-37

열린 `/dev/uleds` handle 하나가 LED class device 하나의 생성과 제거 수명을 소유합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 ==============
2 Userspace LEDs
3 ==============
4
5 The uleds driver supports userspace LEDs. This can be useful for testing
6 triggers and can also be used to implement virtual LEDs.
7
8
9 Usage
10 =====
11
12 When the driver is loaded, a character device is created at /dev/uleds. To
13 create a new LED class device, open /dev/uleds and write a uleds_user_dev
14 structure to it (found in kernel public header file linux/uleds.h)::
15
16 #define LED_MAX_NAME_SIZE 64
17
18 struct uleds_user_dev {
19 char name[LED_MAX_NAME_SIZE];
20 };
21
22 A new LED class device will be created with the name given. The name can be
23 any valid sysfs device node name, but consider using the LED class naming
24 convention of "devicename:color:function".
25
26 The current brightness is found by reading a single byte from the character
27 device. Values are unsigned: 0 to 255. Reading will block until the brightness
28 changes. The device node can also be polled to notify when the brightness value
29 changes.
30
31 The LED class device will be removed when the open file handle to /dev/uleds
32 is closed.
33
34 Multiple LED class devices are created by opening additional file handles to
35 /dev/uleds.
36
37 See tools/leds/uledmon.c for an example userspace program.
38

3. 한국어 전문 번역

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

Userspace LED 생성

1-19

`uleds` driver는 userspace LED를 지원합니다. Trigger 시험과 virtual LED 구현에 사용할 수 있습니다.

Driver를 load하면 `/dev/uleds` character device가 생깁니다. 새 LED class device를 만들려면 `/dev/uleds`를 열고 kernel public header `linux/uleds.h`의 `uleds_user_dev` 구조체를 씁니다.

구조체는 `LED_MAX_NAME_SIZE` 64-byte 크기의 `name` 배열 하나를 갖습니다.

uleds 생성 계약
항목정의
Device node`/dev/uleds`
Header`linux/uleds.h`
구조체`struct uleds_user_dev`
이름 크기`LED_MAX_NAME_SIZE = 64`

Character device에 쓰는 public 구조체입니다.

==============
Userspace LEDs
==============

The uleds driver supports userspace LEDs. This can be useful for testing
triggers and can also be used to implement virtual LEDs.


Usage
=====

When the driver is loaded, a character device is created at /dev/uleds. To
create a new LED class device, open /dev/uleds and write a uleds_user_dev
structure to it (found in kernel public header file linux/uleds.h)::

    #define LED_MAX_NAME_SIZE 64

    struct uleds_user_dev {
        char name[LED_MAX_NAME_SIZE];

Brightness와 file handle 수명

20-37

새 LED class device는 구조체의 name으로 생성됩니다. 유효한 sysfs device node 이름이면 무엇이든 가능하지만 `devicename:color:function` LED class naming convention을 권장합니다.

Character device에서 한 byte를 읽으면 현재 brightness를 얻습니다. 값은 unsigned 0~255이며 brightness가 바뀔 때까지 read가 block됩니다. Poll로 brightness 변경 notification을 받을 수도 있습니다.

열려 있는 `/dev/uleds` file handle을 닫으면 대응 LED class device가 제거됩니다. 추가 file handle을 열 때마다 별도 LED class device를 만들 수 있습니다.

Userspace 예제 program은 `tools/leds/uledmon.c`에 있습니다.

uleds device lifecycle
`/dev/uleds` open`uleds_user_dev`에 이름을 넣어 writeLED class device 생성Read 또는 poll로 0~255 brightness 변경 수신File handle closeLED class device 제거

File handle 하나가 virtual LED 하나의 수명을 소유합니다.

    };

A new LED class device will be created with the name given. The name can be
any valid sysfs device node name, but consider using the LED class naming
convention of "devicename:color:function".

The current brightness is found by reading a single byte from the character
device. Values are unsigned: 0 to 255. Reading will block until the brightness
changes. The device node can also be polled to notify when the brightness value
changes.

The LED class device will be removed when the open file handle to /dev/uleds
is closed.

Multiple LED class devices are created by opening additional file handles to
/dev/uleds.

See tools/leds/uledmon.c for an example userspace program.