drivers/leds/leds-bd2606mvv.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-bd2606mvv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-bd2606mvv.c- Extension
.c- Size
- 3960 bytes
- Lines
- 158
- 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/module.hlinux/mod_devicetable.hlinux/property.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct bd2606mvv_ledstruct bd2606mvv_privfunction bd2606mvv_brightness_setfunction bd2606mvv_probefunction device_for_each_child_node_scoped
Annotated Snippet
struct bd2606mvv_led {
unsigned int led_no;
struct led_classdev ldev;
struct bd2606mvv_priv *priv;
};
struct bd2606mvv_priv {
struct bd2606mvv_led leds[BD2606_MAX_LEDS];
struct regmap *regmap;
};
static int
bd2606mvv_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
struct bd2606mvv_led *led = ldev_to_led(led_cdev);
struct bd2606mvv_priv *priv = led->priv;
int err;
if (brightness == 0)
return regmap_update_bits(priv->regmap,
BD2606_REG_PWRCNT,
1 << led->led_no,
0);
/* shared brightness register */
err = regmap_write(priv->regmap, led->led_no / 2,
led_cdev->max_brightness == 1 ?
BD2606_MAX_BRIGHTNESS : brightness);
if (err)
return err;
return regmap_update_bits(priv->regmap,
BD2606_REG_PWRCNT,
1 << led->led_no,
1 << led->led_no);
}
static const struct regmap_config bd2606mvv_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x3,
};
static int bd2606mvv_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct bd2606mvv_priv *priv;
struct fwnode_handle *led_fwnodes[BD2606_MAX_LEDS] = { 0 };
int active_pairs[BD2606_MAX_LEDS / 2] = { 0 };
int err, reg;
int i, j;
if (!dev_fwnode(dev))
return -ENODEV;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->regmap = devm_regmap_init_i2c(client, &bd2606mvv_regmap);
if (IS_ERR(priv->regmap)) {
err = PTR_ERR(priv->regmap);
dev_err(dev, "Failed to allocate register map: %d\n", err);
return err;
}
i2c_set_clientdata(client, priv);
device_for_each_child_node_scoped(dev, child) {
struct bd2606mvv_led *led;
err = fwnode_property_read_u32(child, "reg", ®);
if (err)
return err;
if (reg < 0 || reg >= BD2606_MAX_LEDS || led_fwnodes[reg])
return -EINVAL;
led = &priv->leds[reg];
led_fwnodes[reg] = fwnode_handle_get(child);
active_pairs[reg / 2]++;
led->priv = priv;
led->led_no = reg;
led->ldev.brightness_set_blocking = bd2606mvv_brightness_set;
led->ldev.max_brightness = BD2606_MAX_BRIGHTNESS;
}
for (i = 0; i < BD2606_MAX_LEDS; i++) {
struct led_init_data init_data = {};
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/leds.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/property.h`, `linux/regmap.h`, `linux/slab.h`.
- Detected declarations: `struct bd2606mvv_led`, `struct bd2606mvv_priv`, `function bd2606mvv_brightness_set`, `function bd2606mvv_probe`, `function device_for_each_child_node_scoped`.
- 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.