drivers/iio/light/al3000a.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/al3000a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/al3000a.c- Extension
.c- Size
- 5318 bytes
- Lines
- 211
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/bitfield.hlinux/device.hlinux/err.hlinux/i2c.hlinux/mod_devicetable.hlinux/module.hlinux/pm.hlinux/regmap.hlinux/regulator/consumer.hlinux/types.hlinux/iio/iio.h
Detected Declarations
struct al3000a_datafunction al3000a_set_pwr_onfunction al3000a_set_pwr_offfunction al3000a_initfunction al3000a_read_rawfunction al3000a_probefunction al3000a_suspendfunction al3000a_resume
Annotated Snippet
struct al3000a_data {
struct regmap *regmap;
struct regulator *vdd_supply;
};
static const struct iio_chan_spec al3000a_channels[] = {
{
.type = IIO_LIGHT,
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
},
};
static int al3000a_set_pwr_on(struct al3000a_data *data)
{
struct device *dev = regmap_get_device(data->regmap);
int ret;
ret = regulator_enable(data->vdd_supply);
if (ret) {
dev_err(dev, "failed to enable vdd power supply\n");
return ret;
}
return regmap_write(data->regmap, AL3000A_REG_SYSTEM, AL3000A_CONFIG_ENABLE);
}
static void al3000a_set_pwr_off(void *_data)
{
struct al3000a_data *data = _data;
struct device *dev = regmap_get_device(data->regmap);
int ret;
ret = regmap_write(data->regmap, AL3000A_REG_SYSTEM, AL3000A_CONFIG_DISABLE);
if (ret)
dev_err(dev, "failed to write system register\n");
ret = regulator_disable(data->vdd_supply);
if (ret)
dev_err(dev, "failed to disable vdd power supply\n");
}
static int al3000a_init(struct al3000a_data *data)
{
struct device *dev = regmap_get_device(data->regmap);
int ret;
ret = al3000a_set_pwr_on(data);
if (ret)
return ret;
ret = devm_add_action_or_reset(dev, al3000a_set_pwr_off, data);
if (ret)
return ret;
ret = regmap_write(data->regmap, AL3000A_REG_SYSTEM, AL3000A_CONFIG_RESET);
if (ret)
return ret;
return regmap_write(data->regmap, AL3000A_REG_SYSTEM, AL3000A_CONFIG_ENABLE);
}
static int al3000a_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
{
struct al3000a_data *data = iio_priv(indio_dev);
int ret, gain;
switch (mask) {
case IIO_CHAN_INFO_PROCESSED:
ret = regmap_read(data->regmap, AL3000A_REG_DATA, &gain);
if (ret)
return ret;
*val = lux_table[gain & AL3000A_GAIN_MASK];
return IIO_VAL_INT;
default:
return -EINVAL;
}
}
static const struct iio_info al3000a_info = {
.read_raw = al3000a_read_raw,
};
static int al3000a_probe(struct i2c_client *client)
{
struct al3000a_data *data;
struct device *dev = &client->dev;
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/device.h`, `linux/err.h`, `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pm.h`.
- Detected declarations: `struct al3000a_data`, `function al3000a_set_pwr_on`, `function al3000a_set_pwr_off`, `function al3000a_init`, `function al3000a_read_raw`, `function al3000a_probe`, `function al3000a_suspend`, `function al3000a_resume`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
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.