drivers/video/backlight/adp8860_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/adp8860_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/adp8860_bl.c- Extension
.c- Size
- 22239 bytes
- Lines
- 815
- Domain
- Driver Families
- Bucket
- drivers/video
- 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/module.hlinux/init.hlinux/errno.hlinux/pm.hlinux/platform_device.hlinux/i2c.hlinux/backlight.hlinux/leds.hlinux/slab.hlinux/workqueue.hlinux/platform_data/adp8860.h
Detected Declarations
struct adp8860_ledstruct adp8860_blfunction adp8860_readfunction adp8860_writefunction adp8860_set_bitsfunction adp8860_clr_bitsfunction adp8860_led_workfunction adp8860_led_setfunction adp8860_led_setupfunction adp8860_led_probefunction adp8860_led_removefunction adp8860_led_probefunction adp8860_led_removefunction adp8860_bl_setfunction adp8860_bl_update_statusfunction adp8860_bl_get_brightnessfunction adp8860_bl_setupfunction adp8860_showfunction adp8860_storefunction adp8860_bl_l3_dark_max_showfunction adp8860_bl_l3_dark_max_storefunction adp8860_bl_l2_office_max_showfunction adp8860_bl_l2_office_max_storefunction adp8860_bl_l1_daylight_max_showfunction adp8860_bl_l1_daylight_max_storefunction adp8860_bl_l3_dark_dim_showfunction adp8860_bl_l3_dark_dim_storefunction adp8860_bl_l2_office_dim_showfunction adp8860_bl_l2_office_dim_storefunction adp8860_bl_l1_daylight_dim_showfunction adp8860_bl_l1_daylight_dim_storefunction adp8860_bl_ambient_light_level_showfunction adp8860_bl_ambient_light_zone_showfunction adp8860_bl_ambient_light_zone_storefunction adp8860_probefunction adp8860_removefunction adp8860_i2c_suspendfunction adp8860_i2c_resume
Annotated Snippet
struct adp8860_led {
struct led_classdev cdev;
struct work_struct work;
struct i2c_client *client;
enum led_brightness new_brightness;
int id;
int flags;
};
struct adp8860_bl {
struct i2c_client *client;
struct backlight_device *bl;
struct adp8860_led *led;
struct adp8860_backlight_platform_data *pdata;
struct mutex lock;
unsigned long cached_daylight_max;
int id;
int revid;
int current_brightness;
unsigned en_ambl_sens:1;
unsigned gdwn_dis:1;
};
static int adp8860_read(struct i2c_client *client, int reg, uint8_t *val)
{
int ret;
ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0) {
dev_err(&client->dev, "failed reading at 0x%02x\n", reg);
return ret;
}
*val = (uint8_t)ret;
return 0;
}
static int adp8860_write(struct i2c_client *client, u8 reg, u8 val)
{
return i2c_smbus_write_byte_data(client, reg, val);
}
static int adp8860_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask)
{
struct adp8860_bl *data = i2c_get_clientdata(client);
uint8_t reg_val;
int ret;
mutex_lock(&data->lock);
ret = adp8860_read(client, reg, ®_val);
if (!ret && ((reg_val & bit_mask) != bit_mask)) {
reg_val |= bit_mask;
ret = adp8860_write(client, reg, reg_val);
}
mutex_unlock(&data->lock);
return ret;
}
static int adp8860_clr_bits(struct i2c_client *client, int reg, uint8_t bit_mask)
{
struct adp8860_bl *data = i2c_get_clientdata(client);
uint8_t reg_val;
int ret;
mutex_lock(&data->lock);
ret = adp8860_read(client, reg, ®_val);
if (!ret && (reg_val & bit_mask)) {
reg_val &= ~bit_mask;
ret = adp8860_write(client, reg, reg_val);
}
mutex_unlock(&data->lock);
return ret;
}
/*
* Independent sink / LED
*/
#if defined(ADP8860_USE_LEDS)
static void adp8860_led_work(struct work_struct *work)
{
struct adp8860_led *led = container_of(work, struct adp8860_led, work);
adp8860_write(led->client, ADP8860_ISC1 - led->id + 1,
led->new_brightness >> 1);
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/errno.h`, `linux/pm.h`, `linux/platform_device.h`, `linux/i2c.h`, `linux/backlight.h`, `linux/leds.h`.
- Detected declarations: `struct adp8860_led`, `struct adp8860_bl`, `function adp8860_read`, `function adp8860_write`, `function adp8860_set_bits`, `function adp8860_clr_bits`, `function adp8860_led_work`, `function adp8860_led_set`, `function adp8860_led_setup`, `function adp8860_led_probe`.
- Atlas domain: Driver Families / drivers/video.
- 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.