drivers/leds/leds-lp55xx-common.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-lp55xx-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-lp55xx-common.c- Extension
.c- Size
- 33899 bytes
- Lines
- 1349
- Domain
- Driver Families
- Bucket
- drivers/leds
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/cleanup.hlinux/clk.hlinux/delay.hlinux/firmware.hlinux/i2c.hlinux/iopoll.hlinux/leds.hlinux/module.hlinux/platform_data/leds-lp55xx.hlinux/slab.hlinux/gpio/consumer.hdt-bindings/leds/leds-lp55xx.hleds-lp55xx-common.h
Detected Declarations
function GENMASKfunction lp55xx_wait_opmode_donefunction lp55xx_stop_all_enginefunction lp55xx_load_enginefunction lp55xx_run_engine_commonfunction lp55xx_update_program_memoryfunction lp55xx_firmware_loaded_cbfunction lp55xx_led_brightnessfunction lp55xx_multicolor_brightnessfunction lp55xx_set_led_currentfunction lp55xx_turn_off_channelsfunction lp55xx_stop_enginefunction lp55xx_reset_devicefunction lp55xx_detect_devicefunction lp55xx_post_init_devicefunction led_current_showfunction led_current_storefunction max_current_showfunction lp55xx_set_mc_brightnessfunction lp55xx_set_brightnessfunction lp55xx_init_ledfunction lp55xx_firmware_loadedfunction lp55xx_request_firmwarefunction select_engine_showfunction select_engine_storefunction lp55xx_run_enginefunction run_engine_storefunction lp55xx_show_engine_modefunction lp55xx_store_engine_modefunction lp55xx_store_engine_loadfunction lp55xx_mux_parsefunction lp55xx_show_engine_ledsfunction lp55xx_load_muxfunction lp55xx_store_engine_ledsfunction lp55xx_show_master_faderfunction lp55xx_store_master_faderfunction lp55xx_show_master_fader_ledsfunction lp55xx_store_master_fader_ledsfunction lp55xx_writefunction lp55xx_readfunction lp55xx_update_bitsfunction lp55xx_is_extclk_usedfunction lp55xx_deinit_devicefunction lp55xx_init_devicefunction lp55xx_register_ledsfunction lp55xx_register_sysfsfunction lp55xx_unregister_sysfsfunction lp55xx_parse_common_child
Annotated Snippet
scoped_guard(mutex, &chip->lock) {
chip->engine_idx = val;
ret = lp55xx_request_firmware(chip);
}
break;
default:
dev_err(dev, "%lu: invalid engine index. (1, 2, 3)\n", val);
return -EINVAL;
}
if (ret) {
dev_err(dev, "request firmware err: %d\n", ret);
return ret;
}
return len;
}
static inline void lp55xx_run_engine(struct lp55xx_chip *chip, bool start)
{
if (chip->cfg->run_engine)
chip->cfg->run_engine(chip, start);
}
static ssize_t run_engine_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
unsigned long val;
if (kstrtoul(buf, 0, &val))
return -EINVAL;
/* run or stop the selected engine */
if (val <= 0) {
lp55xx_run_engine(chip, false);
return len;
}
guard(mutex)(&chip->lock);
lp55xx_run_engine(chip, true);
return len;
}
static DEVICE_ATTR_RW(select_engine);
static DEVICE_ATTR_WO(run_engine);
ssize_t lp55xx_show_engine_mode(struct device *dev,
struct device_attribute *attr,
char *buf, int nr)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
enum lp55xx_engine_mode mode = chip->engines[nr - 1].mode;
switch (mode) {
case LP55XX_ENGINE_RUN:
return sysfs_emit(buf, "run\n");
case LP55XX_ENGINE_LOAD:
return sysfs_emit(buf, "load\n");
case LP55XX_ENGINE_DISABLED:
default:
return sysfs_emit(buf, "disabled\n");
}
}
EXPORT_SYMBOL_GPL(lp55xx_show_engine_mode);
ssize_t lp55xx_store_engine_mode(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len, int nr)
{
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip;
const struct lp55xx_device_config *cfg = chip->cfg;
struct lp55xx_engine *engine = &chip->engines[nr - 1];
guard(mutex)(&chip->lock);
chip->engine_idx = nr;
if (!strncmp(buf, "run", 3)) {
cfg->run_engine(chip, true);
engine->mode = LP55XX_ENGINE_RUN;
} else if (!strncmp(buf, "load", 4)) {
lp55xx_stop_engine(chip);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/delay.h`, `linux/firmware.h`, `linux/i2c.h`, `linux/iopoll.h`, `linux/leds.h`.
- Detected declarations: `function GENMASK`, `function lp55xx_wait_opmode_done`, `function lp55xx_stop_all_engine`, `function lp55xx_load_engine`, `function lp55xx_run_engine_common`, `function lp55xx_update_program_memory`, `function lp55xx_firmware_loaded_cb`, `function lp55xx_led_brightness`, `function lp55xx_multicolor_brightness`, `function lp55xx_set_led_current`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: integration implementation candidate.
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.