drivers/iio/light/isl29028.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/isl29028.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/isl29028.c- Extension
.c- Size
- 16740 bytes
- Lines
- 706
- Domain
- Driver Families
- Bucket
- drivers/iio
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/i2c.hlinux/err.hlinux/mutex.hlinux/delay.hlinux/slab.hlinux/regmap.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/pm_runtime.h
Detected Declarations
struct isl29028_prox_datastruct isl29028_chipenum isl29028_als_ir_modefunction isl29028_find_prox_sleep_indexfunction isl29028_set_proxim_samplingfunction isl29028_enable_proximityfunction isl29028_set_als_scalefunction isl29028_set_als_ir_modefunction isl29028_read_als_irfunction isl29028_read_proximfunction isl29028_als_getfunction isl29028_ir_getfunction isl29028_set_pm_runtime_busyfunction isl29028_write_rawfunction isl29028_read_rawfunction isl29028_clear_configure_regfunction isl29028_is_volatile_regfunction isl29028_probefunction isl29028_removefunction isl29028_suspendfunction isl29028_resume
Annotated Snippet
struct isl29028_prox_data {
int sampling_int;
int sampling_fract;
int sleep_time;
};
static const struct isl29028_prox_data isl29028_prox_data[] = {
{ 1, 250000, 800 },
{ 2, 500000, 400 },
{ 5, 0, 200 },
{ 10, 0, 100 },
{ 13, 300000, 75 },
{ 20, 0, 50 },
{ 80, 0, 13 }, /*
* Note: Data sheet lists 12.5 ms sleep time.
* Round up a half millisecond for msleep().
*/
{ 100, 0, 0 }
};
enum isl29028_als_ir_mode {
ISL29028_MODE_NONE = 0,
ISL29028_MODE_ALS,
ISL29028_MODE_IR,
};
struct isl29028_chip {
struct mutex lock;
struct regmap *regmap;
int prox_sampling_int;
int prox_sampling_frac;
bool enable_prox;
int lux_scale;
enum isl29028_als_ir_mode als_ir_mode;
};
static int isl29028_find_prox_sleep_index(int sampling_int, int sampling_fract)
{
int i;
for (i = 0; i < ARRAY_SIZE(isl29028_prox_data); ++i) {
if (isl29028_prox_data[i].sampling_int == sampling_int &&
isl29028_prox_data[i].sampling_fract == sampling_fract)
return i;
}
return -EINVAL;
}
static int isl29028_set_proxim_sampling(struct isl29028_chip *chip,
int sampling_int, int sampling_fract)
{
struct device *dev = regmap_get_device(chip->regmap);
int sleep_index, ret;
sleep_index = isl29028_find_prox_sleep_index(sampling_int,
sampling_fract);
if (sleep_index < 0)
return sleep_index;
ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
ISL29028_CONF_PROX_SLP_MASK,
sleep_index << ISL29028_CONF_PROX_SLP_SH);
if (ret < 0) {
dev_err(dev, "%s(): Error %d setting the proximity sampling\n",
__func__, ret);
return ret;
}
chip->prox_sampling_int = sampling_int;
chip->prox_sampling_frac = sampling_fract;
return ret;
}
static int isl29028_enable_proximity(struct isl29028_chip *chip)
{
int prox_index, ret;
ret = isl29028_set_proxim_sampling(chip, chip->prox_sampling_int,
chip->prox_sampling_frac);
if (ret < 0)
return ret;
ret = regmap_update_bits(chip->regmap, ISL29028_REG_CONFIGURE,
ISL29028_CONF_PROX_EN_MASK,
ISL29028_CONF_PROX_EN);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/i2c.h`, `linux/err.h`, `linux/mutex.h`, `linux/delay.h`, `linux/slab.h`, `linux/regmap.h`, `linux/iio/iio.h`.
- Detected declarations: `struct isl29028_prox_data`, `struct isl29028_chip`, `enum isl29028_als_ir_mode`, `function isl29028_find_prox_sleep_index`, `function isl29028_set_proxim_sampling`, `function isl29028_enable_proximity`, `function isl29028_set_als_scale`, `function isl29028_set_als_ir_mode`, `function isl29028_read_als_ir`, `function isl29028_read_proxim`.
- Atlas domain: Driver Families / drivers/iio.
- 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.