drivers/leds/leds-lp3952.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-lp3952.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-lp3952.c- Extension
.c- Size
- 6749 bytes
- Lines
- 287
- 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/delay.hlinux/gpio/consumer.hlinux/i2c.hlinux/io.hlinux/kernel.hlinux/leds.hlinux/leds-lp3952.hlinux/module.hlinux/notifier.hlinux/platform_device.hlinux/pm.hlinux/reboot.hlinux/regmap.h
Detected Declarations
function Copyrightfunction lp3952_on_offfunction lp3952_set_brightnessfunction lp3952_get_labelfunction lp3952_register_led_classdevfunction lp3952_set_pattern_gen_cmdfunction lp3952_configurefunction gpio_set_low_actionfunction lp3952_probe
Annotated Snippet
if (ret < 0) {
dev_err(&priv->client->dev,
"couldn't register LED %s\n",
priv->leds[i].cdev.name);
break;
}
}
return ret;
}
static int lp3952_set_pattern_gen_cmd(struct lp3952_led_array *priv,
u8 cmd_index, u8 r, u8 g, u8 b,
enum lp3952_tt tt, enum lp3952_cet cet)
{
int ret;
struct ptrn_gen_cmd line = {
{
{
.r = r,
.g = g,
.b = b,
.cet = cet,
.tt = tt
}
}
};
if (cmd_index >= LP3952_CMD_REG_COUNT)
return -EINVAL;
ret = lp3952_register_write(priv->client,
LP3952_REG_CMD_0 + cmd_index * 2,
line.bytes.msb);
if (ret)
return ret;
return lp3952_register_write(priv->client,
LP3952_REG_CMD_0 + cmd_index * 2 + 1,
line.bytes.lsb);
}
static int lp3952_configure(struct lp3952_led_array *priv)
{
int ret;
/* Disable any LEDs on from any previous conf. */
ret = lp3952_register_write(priv->client, LP3952_REG_LED_CTRL, 0);
if (ret)
return ret;
/* enable rgb patter, loop */
ret = lp3952_register_write(priv->client, LP3952_REG_PAT_GEN_CTRL,
LP3952_PATRN_LOOP | LP3952_PATRN_GEN_EN);
if (ret)
return ret;
/* Update Bit 6 (Active mode), Select both Led sets, Bit [1:0] */
ret = lp3952_register_write(priv->client, LP3952_REG_ENABLES,
LP3952_ACTIVE_MODE | LP3952_INT_B00ST_LDR);
if (ret)
return ret;
/* Set Cmd1 for RGB intensity,cmd and transition time */
return lp3952_set_pattern_gen_cmd(priv, 0, I46, I71, I100, TT0,
CET197);
}
static const struct regmap_config lp3952_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = REG_MAX,
.cache_type = REGCACHE_MAPLE,
};
static void gpio_set_low_action(void *data)
{
struct lp3952_led_array *priv = data;
gpiod_set_value(priv->enable_gpio, 0);
}
static int lp3952_probe(struct i2c_client *client)
{
int status;
struct lp3952_led_array *priv;
priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/i2c.h`, `linux/io.h`, `linux/kernel.h`, `linux/leds.h`, `linux/leds-lp3952.h`, `linux/module.h`.
- Detected declarations: `function Copyright`, `function lp3952_on_off`, `function lp3952_set_brightness`, `function lp3952_get_label`, `function lp3952_register_led_classdev`, `function lp3952_set_pattern_gen_cmd`, `function lp3952_configure`, `function gpio_set_low_action`, `function lp3952_probe`.
- 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.