drivers/leds/leds-lm3530.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-lm3530.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-lm3530.c- Extension
.c- Size
- 12870 bytes
- Lines
- 500
- 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.
- 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/i2c.hlinux/leds.hlinux/slab.hlinux/platform_device.hlinux/input.hlinux/led-lm3530.hlinux/types.hlinux/regulator/consumer.hlinux/module.h
Detected Declarations
struct lm3530_mode_mapstruct lm3530_datastruct lm3530_als_datafunction lm3530_get_mode_from_strfunction lm3530_als_configurefunction lm3530_led_enablefunction lm3530_led_disablefunction lm3530_init_registersfunction lm3530_brightness_setfunction mode_showfunction mode_storefunction lm3530_probefunction lm3530_remove
Annotated Snippet
struct lm3530_mode_map {
const char *mode;
enum lm3530_mode mode_val;
};
static struct lm3530_mode_map mode_map[] = {
{ "man", LM3530_BL_MODE_MANUAL },
{ "als", LM3530_BL_MODE_ALS },
{ "pwm", LM3530_BL_MODE_PWM },
};
/**
* struct lm3530_data
* @led_dev: led class device
* @client: i2c client
* @pdata: LM3530 platform data
* @mode: mode of operation - manual, ALS, PWM
* @regulator: regulator
* @brightness: previous brightness value
* @enable: regulator is enabled
*/
struct lm3530_data {
struct led_classdev led_dev;
struct i2c_client *client;
struct lm3530_platform_data *pdata;
enum lm3530_mode mode;
struct regulator *regulator;
enum led_brightness brightness;
bool enable;
};
/*
* struct lm3530_als_data
* @config : value of ALS configuration register
* @imp_sel : value of ALS resistor select register
* @zone : values of ALS ZB(Zone Boundary) registers
*/
struct lm3530_als_data {
u8 config;
u8 imp_sel;
u8 zones[LM3530_ALS_ZB_MAX];
};
static const u8 lm3530_reg[LM3530_REG_MAX] = {
LM3530_GEN_CONFIG,
LM3530_ALS_CONFIG,
LM3530_BRT_RAMP_RATE,
LM3530_ALS_IMP_SELECT,
LM3530_BRT_CTRL_REG,
LM3530_ALS_ZB0_REG,
LM3530_ALS_ZB1_REG,
LM3530_ALS_ZB2_REG,
LM3530_ALS_ZB3_REG,
LM3530_ALS_Z0T_REG,
LM3530_ALS_Z1T_REG,
LM3530_ALS_Z2T_REG,
LM3530_ALS_Z3T_REG,
LM3530_ALS_Z4T_REG,
};
static int lm3530_get_mode_from_str(const char *str)
{
int i;
for (i = 0; i < ARRAY_SIZE(mode_map); i++)
if (sysfs_streq(str, mode_map[i].mode))
return mode_map[i].mode_val;
return -EINVAL;
}
static void lm3530_als_configure(struct lm3530_platform_data *pdata,
struct lm3530_als_data *als)
{
int i;
u32 als_vmin, als_vmax, als_vstep;
if (pdata->als_vmax == 0) {
pdata->als_vmin = 0;
pdata->als_vmax = LM3530_ALS_WINDOW_mV;
}
als_vmin = pdata->als_vmin;
als_vmax = pdata->als_vmax;
if ((als_vmax - als_vmin) > LM3530_ALS_WINDOW_mV)
pdata->als_vmax = als_vmax = als_vmin + LM3530_ALS_WINDOW_mV;
/* n zone boundary makes n+1 zones */
als_vstep = (als_vmax - als_vmin) / (LM3530_ALS_ZB_MAX + 1);
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/leds.h`, `linux/slab.h`, `linux/platform_device.h`, `linux/input.h`, `linux/led-lm3530.h`, `linux/types.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct lm3530_mode_map`, `struct lm3530_data`, `struct lm3530_als_data`, `function lm3530_get_mode_from_str`, `function lm3530_als_configure`, `function lm3530_led_enable`, `function lm3530_led_disable`, `function lm3530_init_registers`, `function lm3530_brightness_set`, `function mode_show`.
- Atlas domain: Driver Families / drivers/leds.
- Implementation status: source 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.