drivers/leds/uleds.c
Source file repositories/reference/linux-study-clean/drivers/leds/uleds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/uleds.c- Extension
.c- Size
- 4713 bytes
- Lines
- 220
- Domain
- Driver Families
- Bucket
- drivers/leds
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/init.hlinux/leds.hlinux/miscdevice.hlinux/module.hlinux/poll.hlinux/sched.hlinux/slab.huapi/linux/uleds.h
Detected Declarations
struct uleds_deviceenum uleds_statefunction uleds_brightness_setfunction uleds_openfunction uleds_writefunction strnchrfunction uleds_readfunction uleds_pollfunction uleds_release
Annotated Snippet
static const struct file_operations uleds_fops = {
.owner = THIS_MODULE,
.open = uleds_open,
.release = uleds_release,
.read = uleds_read,
.write = uleds_write,
.poll = uleds_poll,
};
static struct miscdevice uleds_misc = {
.fops = &uleds_fops,
.minor = MISC_DYNAMIC_MINOR,
.name = ULEDS_NAME,
};
module_misc_device(uleds_misc);
MODULE_AUTHOR("David Lechner <david@lechnology.com>");
MODULE_DESCRIPTION("Userspace driver for the LED subsystem");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/fs.h`, `linux/init.h`, `linux/leds.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/poll.h`, `linux/sched.h`, `linux/slab.h`.
- Detected declarations: `struct uleds_device`, `enum uleds_state`, `function uleds_brightness_set`, `function uleds_open`, `function uleds_write`, `function strnchr`, `function uleds_read`, `function uleds_poll`, `function uleds_release`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.