drivers/leds/leds-88pm860x.c
Source file repositories/reference/linux-study-clean/drivers/leds/leds-88pm860x.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/leds/leds-88pm860x.c- Extension
.c- Size
- 5778 bytes
- Lines
- 238
- 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/kernel.hlinux/of.hlinux/platform_device.hlinux/i2c.hlinux/leds.hlinux/slab.hlinux/mfd/88pm860x.hlinux/module.h
Detected Declarations
struct pm860x_ledfunction led_power_setfunction pm860x_led_setfunction pm860x_led_dt_initfunction pm860x_led_probefunction pm860x_led_remove
Annotated Snippet
struct pm860x_led {
struct led_classdev cdev;
struct i2c_client *i2c;
struct pm860x_chip *chip;
struct mutex lock;
char name[MFD_NAME_SIZE];
int port;
int iset;
unsigned char brightness;
unsigned char current_brightness;
int reg_control;
int reg_blink;
int blink_mask;
};
static int led_power_set(struct pm860x_chip *chip, int port, int on)
{
int ret = -EINVAL;
switch (port) {
case 0:
case 1:
case 2:
ret = on ? pm8606_osc_enable(chip, RGB1_ENABLE) :
pm8606_osc_disable(chip, RGB1_ENABLE);
break;
case 3:
case 4:
case 5:
ret = on ? pm8606_osc_enable(chip, RGB2_ENABLE) :
pm8606_osc_disable(chip, RGB2_ENABLE);
break;
}
return ret;
}
static int pm860x_led_set(struct led_classdev *cdev,
enum led_brightness value)
{
struct pm860x_led *led = container_of(cdev, struct pm860x_led, cdev);
struct pm860x_chip *chip;
unsigned char buf[3];
int ret;
chip = led->chip;
mutex_lock(&led->lock);
led->brightness = value >> 3;
if ((led->current_brightness == 0) && led->brightness) {
led_power_set(chip, led->port, 1);
if (led->iset) {
pm860x_set_bits(led->i2c, led->reg_control,
LED_CURRENT_MASK, led->iset);
}
pm860x_set_bits(led->i2c, led->reg_blink,
LED_BLINK_MASK, LED_ON_CONTINUOUS);
pm860x_set_bits(led->i2c, PM8606_WLED3B, led->blink_mask,
led->blink_mask);
}
pm860x_set_bits(led->i2c, led->reg_control, LED_PWM_MASK,
led->brightness);
if (led->brightness == 0) {
pm860x_bulk_read(led->i2c, led->reg_control, 3, buf);
ret = buf[0] & LED_PWM_MASK;
ret |= buf[1] & LED_PWM_MASK;
ret |= buf[2] & LED_PWM_MASK;
if (ret == 0) {
/* unset current since no led is lighting */
pm860x_set_bits(led->i2c, led->reg_control,
LED_CURRENT_MASK, 0);
pm860x_set_bits(led->i2c, PM8606_WLED3B,
led->blink_mask, 0);
led_power_set(chip, led->port, 0);
}
}
led->current_brightness = led->brightness;
dev_dbg(chip->dev, "Update LED. (reg:%d, brightness:%d)\n",
led->reg_control, led->brightness);
mutex_unlock(&led->lock);
return 0;
}
#ifdef CONFIG_OF
static int pm860x_led_dt_init(struct platform_device *pdev,
struct pm860x_led *data)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/of.h`, `linux/platform_device.h`, `linux/i2c.h`, `linux/leds.h`, `linux/slab.h`, `linux/mfd/88pm860x.h`, `linux/module.h`.
- Detected declarations: `struct pm860x_led`, `function led_power_set`, `function pm860x_led_set`, `function pm860x_led_dt_init`, `function pm860x_led_probe`, `function pm860x_led_remove`.
- 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.