Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

/sys/class/leds

FieldValue
SubsystemLED class, drivers/leds/led-class.c (core attributes); triggers in drivers/leds/trigger/
Config gateCONFIG_LEDS_CLASS (obj-$(CONFIG_LEDS_CLASS) += led-class.o in drivers/leds/Makefile, torvalds/linux master; flash and multicolor extensions gated by CONFIG_LEDS_CLASS_FLASH and CONFIG_LEDS_CLASS_MULTICOLOR)
ABI documentationDocumentation/ABI/testing/sysfs-class-led (core); sysfs-class-led-flash, sysfs-class-led-multicolor, sysfs-class-led-trigger-* for extensions
Since2.6.17 (brightness, max_brightness, trigger); 2.6.38 (inverted); 4.11 (brightness_hw_changed); 5.9 (multi_intensity, multi_index)
Live (5.10.134 host)class absent: no LED device registered in the container
Ledger IDSYSC-leds

What it represents

One directory per LED, named devicename:color:function per Documentation/leds/leds-class.rst (for example input0::numlock). Userspace sets brightness, or attaches a trigger so the kernel drives the LED from events (disk activity, heartbeat, network). Most LEDs have no hardware dimming: any non-zero value is simply on, which the ABI states for brightness.

Relationship to the device model

/sys/class/leds/<led> is a class view of a device under /sys/devices/... (platform, i2c, USB, or virtual device). No bus of its own and no char/block node; an LED is not a /dev object. Trigger-specific parameter files appear inside the LED directory once a trigger is selected (ABI trigger entry).

Attributes

The core ABI file sysfs-class-led carries 5 What: entries; counting every path spelled /sys/class/leds/... across the ABI tree (flash, multicolor, triggers, per-driver files) gives 96, the number recorded in the ledger. The table below is representative.

AttributeR/WUnit/formatConditional?Source
<led>/brightnessRW0..max_brightness, decimal; 0 clears the active triggeralwaysABI What brightness (2.6.17)
<led>/max_brightnessROinteger; default 255 (LED_FULL), 1 if no levelsalwaysABI What max_brightness (2.6.17)
<led>/triggerRWtrigger name list; none removes, default selects the default triggeralwaysABI What trigger (2.6.17)
<led>/invertedRW0/1; gpio and backlight triggers onlytrigger-dependentABI What inverted (2.6.38)
<led>/brightness_hw_changedROlast hardware-set level; supports poll(); ENODATA before first changeonly if driver detects hardware changesABI What brightness_hw_changed (4.11)
<led>/multi_intensityRWarray of per-color intensitiesmulticolor LEDs onlyABI sysfs-class-led-multicolor (5.9)
<led>/multi_indexROcolor order array matching multi_intensitymulticolor LEDs onlyABI sysfs-class-led-multicolor (5.9)
<led>/flash_*, <led>/pattern, <led> trigger paramsRWsee per-family ABI filesdriver/trigger-dependentsysfs-class-led-flash, sysfs-class-led-trigger-*

Everything beyond the first five rows is conditional on driver, trigger, or class extension; none of it appears on a plain on/off LED.

Safety and writes

Reads are always safe. Writing brightness needs write access to the file (typically root on a pre-udev-rule system; udev often grants the video or input group). Writing a trigger or a multicolor intensity changes what the LED indicates; a wrong heartbeat or panic trigger assignment is cosmetic, but patterns on embedded boards can double as status signalling (for example modem or panic LEDs), so treat writes as device policy.

References

  • Documentation/ABI/testing/sysfs-class-led (cached copy: 89 lines, 5 What: entries)
  • drivers/leds/led-class.c, drivers/leds/Makefile (torvalds/linux master)
  • Documentation/leds/leds-class.rst (naming scheme, per worklog 2-b)
  • Ledger row SYSC-leds; worklog Task 2-b