drivers/misc/isl29003.c
Source file repositories/reference/linux-study-clean/drivers/misc/isl29003.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/isl29003.c- Extension
.c- Size
- 11105 bytes
- Lines
- 473
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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/slab.hlinux/i2c.hlinux/mutex.hlinux/delay.h
Detected Declarations
struct isl29003_datafunction __isl29003_read_regfunction __isl29003_write_regfunction isl29003_get_rangefunction isl29003_set_rangefunction isl29003_get_resolutionfunction isl29003_set_resolutionfunction isl29003_get_modefunction isl29003_set_modefunction isl29003_set_power_statefunction isl29003_get_power_statefunction isl29003_get_adc_valuefunction isl29003_show_rangefunction isl29003_store_rangefunction isl29003_show_resolutionfunction isl29003_store_resolutionfunction isl29003_show_modefunction isl29003_store_modefunction isl29003_show_power_statefunction isl29003_store_power_statefunction isl29003_show_luxfunction isl29003_init_clientfunction isl29003_probefunction isl29003_removefunction isl29003_suspendfunction isl29003_resume
Annotated Snippet
struct isl29003_data {
struct i2c_client *client;
struct mutex lock;
u8 reg_cache[ISL29003_NUM_CACHABLE_REGS];
u8 power_state_before_suspend;
};
static int gain_range[] = {
1000, 4000, 16000, 64000
};
/*
* register access helpers
*/
static int __isl29003_read_reg(struct i2c_client *client,
u32 reg, u8 mask, u8 shift)
{
struct isl29003_data *data = i2c_get_clientdata(client);
return (data->reg_cache[reg] & mask) >> shift;
}
static int __isl29003_write_reg(struct i2c_client *client,
u32 reg, u8 mask, u8 shift, u8 val)
{
struct isl29003_data *data = i2c_get_clientdata(client);
int ret = 0;
u8 tmp;
if (reg >= ISL29003_NUM_CACHABLE_REGS)
return -EINVAL;
mutex_lock(&data->lock);
tmp = data->reg_cache[reg];
tmp &= ~mask;
tmp |= val << shift;
ret = i2c_smbus_write_byte_data(client, reg, tmp);
if (!ret)
data->reg_cache[reg] = tmp;
mutex_unlock(&data->lock);
return ret;
}
/*
* internally used functions
*/
/* range */
static int isl29003_get_range(struct i2c_client *client)
{
return __isl29003_read_reg(client, ISL29003_REG_CONTROL,
ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT);
}
static int isl29003_set_range(struct i2c_client *client, int range)
{
return __isl29003_write_reg(client, ISL29003_REG_CONTROL,
ISL29003_RANGE_MASK, ISL29003_RANGE_SHIFT, range);
}
/* resolution */
static int isl29003_get_resolution(struct i2c_client *client)
{
return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
ISL29003_RES_MASK, ISL29003_RES_SHIFT);
}
static int isl29003_set_resolution(struct i2c_client *client, int res)
{
return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
ISL29003_RES_MASK, ISL29003_RES_SHIFT, res);
}
/* mode */
static int isl29003_get_mode(struct i2c_client *client)
{
return __isl29003_read_reg(client, ISL29003_REG_COMMAND,
ISL29003_MODE_MASK, ISL29003_MODE_SHIFT);
}
static int isl29003_set_mode(struct i2c_client *client, int mode)
{
return __isl29003_write_reg(client, ISL29003_REG_COMMAND,
ISL29003_MODE_MASK, ISL29003_MODE_SHIFT, mode);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/i2c.h`, `linux/mutex.h`, `linux/delay.h`.
- Detected declarations: `struct isl29003_data`, `function __isl29003_read_reg`, `function __isl29003_write_reg`, `function isl29003_get_range`, `function isl29003_set_range`, `function isl29003_get_resolution`, `function isl29003_set_resolution`, `function isl29003_get_mode`, `function isl29003_set_mode`, `function isl29003_set_power_state`.
- Atlas domain: Driver Families / drivers/misc.
- 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.