drivers/video/backlight/adp8870_bl.c
Source file repositories/reference/linux-study-clean/drivers/video/backlight/adp8870_bl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/video/backlight/adp8870_bl.c- Extension
.c- Size
- 26651 bytes
- Lines
- 985
- 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/workqueue.hlinux/slab.hlinux/platform_data/adp8870.h
Detected Declarations
struct adp8870_blstruct adp8870_ledfunction adp8870_readfunction adp8870_writefunction adp8870_set_bitsfunction adp8870_clr_bitsfunction adp8870_led_workfunction adp8870_led_setfunction adp8870_led_setupfunction adp8870_led_probefunction adp8870_led_removefunction adp8870_led_probefunction adp8870_led_removefunction adp8870_bl_setfunction adp8870_bl_update_statusfunction adp8870_bl_get_brightnessfunction adp8870_bl_setupfunction adp8870_showfunction adp8870_storefunction adp8870_bl_l5_dark_max_showfunction adp8870_bl_l5_dark_max_storefunction adp8870_bl_l4_indoor_max_showfunction adp8870_bl_l4_indoor_max_storefunction adp8870_bl_l3_office_max_showfunction adp8870_bl_l3_office_max_storefunction adp8870_bl_l2_bright_max_showfunction adp8870_bl_l2_bright_max_storefunction adp8870_bl_l1_daylight_max_showfunction adp8870_bl_l1_daylight_max_storefunction adp8870_bl_l5_dark_dim_showfunction adp8870_bl_l5_dark_dim_storefunction adp8870_bl_l4_indoor_dim_showfunction adp8870_bl_l4_indoor_dim_storefunction adp8870_bl_l3_office_dim_showfunction adp8870_bl_l3_office_dim_storefunction adp8870_bl_l2_bright_dim_showfunction adp8870_bl_l2_bright_dim_storefunction adp8870_bl_l1_daylight_dim_showfunction adp8870_bl_l1_daylight_dim_storefunction adp8870_bl_ambient_light_level_showfunction adp8870_bl_ambient_light_zone_showfunction adp8870_bl_ambient_light_zone_storefunction adp8870_probefunction adp8870_removefunction adp8870_i2c_suspendfunction adp8870_i2c_resume
Annotated Snippet
struct adp8870_bl {
struct i2c_client *client;
struct backlight_device *bl;
struct adp8870_led *led;
struct adp8870_backlight_platform_data *pdata;
struct mutex lock;
unsigned long cached_daylight_max;
int id;
int revid;
int current_brightness;
};
struct adp8870_led {
struct led_classdev cdev;
struct work_struct work;
struct i2c_client *client;
enum led_brightness new_brightness;
int id;
int flags;
};
static int adp8870_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 = ret;
return 0;
}
static int adp8870_write(struct i2c_client *client, u8 reg, u8 val)
{
int ret = i2c_smbus_write_byte_data(client, reg, val);
if (ret)
dev_err(&client->dev, "failed to write\n");
return ret;
}
static int adp8870_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask)
{
struct adp8870_bl *data = i2c_get_clientdata(client);
uint8_t reg_val;
int ret;
mutex_lock(&data->lock);
ret = adp8870_read(client, reg, ®_val);
if (!ret && ((reg_val & bit_mask) != bit_mask)) {
reg_val |= bit_mask;
ret = adp8870_write(client, reg, reg_val);
}
mutex_unlock(&data->lock);
return ret;
}
static int adp8870_clr_bits(struct i2c_client *client, int reg, uint8_t bit_mask)
{
struct adp8870_bl *data = i2c_get_clientdata(client);
uint8_t reg_val;
int ret;
mutex_lock(&data->lock);
ret = adp8870_read(client, reg, ®_val);
if (!ret && (reg_val & bit_mask)) {
reg_val &= ~bit_mask;
ret = adp8870_write(client, reg, reg_val);
}
mutex_unlock(&data->lock);
return ret;
}
/*
* Independent sink / LED
*/
#if defined(ADP8870_USE_LEDS)
static void adp8870_led_work(struct work_struct *work)
{
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 adp8870_bl`, `struct adp8870_led`, `function adp8870_read`, `function adp8870_write`, `function adp8870_set_bits`, `function adp8870_clr_bits`, `function adp8870_led_work`, `function adp8870_led_set`, `function adp8870_led_setup`, `function adp8870_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.