drivers/leds/leds-lm3533.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-lm3533.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-lm3533.c- Extension
.c- Size
- 17855 bytes
- Lines
- 756
- Domain
- Driver Families
- Bucket
- drivers/leds
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/module.hlinux/leds.hlinux/mfd/core.hlinux/mutex.hlinux/platform_device.hlinux/slab.hlinux/mfd/lm3533.h
Detected Declarations
struct lm3533_ledfunction lm3533_led_get_ctrlbank_idfunction lm3533_led_get_lv_regfunction lm3533_led_get_patternfunction lm3533_led_get_pattern_regfunction lm3533_led_pattern_enablefunction lm3533_led_setfunction lm3533_led_getfunction time_to_valfunction lm3533_led_get_hw_delayfunction lm3533_led_delay_setfunction lm3533_led_delay_on_setfunction lm3533_led_delay_off_setfunction lm3533_led_blink_setfunction show_idfunction show_risefalltimefunction show_risetimefunction show_falltimefunction store_risefalltimefunction store_risetimefunction store_falltimefunction show_als_channelfunction store_als_channelfunction show_als_enfunction store_als_enfunction show_linearfunction store_linearfunction show_pwmfunction store_pwmfunction lm3533_led_attr_is_visiblefunction lm3533_led_setupfunction lm3533_led_probefunction lm3533_led_removefunction lm3533_led_shutdown
Annotated Snippet
struct lm3533_led {
struct lm3533 *lm3533;
struct lm3533_ctrlbank cb;
struct led_classdev cdev;
int id;
struct mutex mutex;
unsigned long flags;
};
static inline struct lm3533_led *to_lm3533_led(struct led_classdev *cdev)
{
return container_of(cdev, struct lm3533_led, cdev);
}
static inline int lm3533_led_get_ctrlbank_id(struct lm3533_led *led)
{
return led->id + 2;
}
static inline u8 lm3533_led_get_lv_reg(struct lm3533_led *led, u8 base)
{
return base + led->id;
}
static inline u8 lm3533_led_get_pattern(struct lm3533_led *led)
{
return led->id;
}
static inline u8 lm3533_led_get_pattern_reg(struct lm3533_led *led,
u8 base)
{
return base + lm3533_led_get_pattern(led) * LM3533_REG_PATTERN_STEP;
}
static int lm3533_led_pattern_enable(struct lm3533_led *led, int enable)
{
u8 mask;
u8 val;
int pattern;
int state;
int ret = 0;
dev_dbg(led->cdev.dev, "%s - %d\n", __func__, enable);
mutex_lock(&led->mutex);
state = test_bit(LM3533_LED_FLAG_PATTERN_ENABLE, &led->flags);
if ((enable && state) || (!enable && !state))
goto out;
pattern = lm3533_led_get_pattern(led);
mask = 1 << (2 * pattern);
if (enable)
val = mask;
else
val = 0;
ret = lm3533_update(led->lm3533, LM3533_REG_PATTERN_ENABLE, val, mask);
if (ret) {
dev_err(led->cdev.dev, "failed to enable pattern %d (%d)\n",
pattern, enable);
goto out;
}
__change_bit(LM3533_LED_FLAG_PATTERN_ENABLE, &led->flags);
out:
mutex_unlock(&led->mutex);
return ret;
}
static int lm3533_led_set(struct led_classdev *cdev,
enum led_brightness value)
{
struct lm3533_led *led = to_lm3533_led(cdev);
dev_dbg(led->cdev.dev, "%s - %d\n", __func__, value);
if (value == 0)
lm3533_led_pattern_enable(led, 0); /* disable blink */
return lm3533_ctrlbank_set_brightness(&led->cb, value);
}
static enum led_brightness lm3533_led_get(struct led_classdev *cdev)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/leds.h`, `linux/mfd/core.h`, `linux/mutex.h`, `linux/platform_device.h`, `linux/slab.h`, `linux/mfd/lm3533.h`.
- Detected declarations: `struct lm3533_led`, `function lm3533_led_get_ctrlbank_id`, `function lm3533_led_get_lv_reg`, `function lm3533_led_get_pattern`, `function lm3533_led_get_pattern_reg`, `function lm3533_led_pattern_enable`, `function lm3533_led_set`, `function lm3533_led_get`, `function time_to_val`, `function lm3533_led_get_hw_delay`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: source implementation candidate.
- 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.