drivers/iio/chemical/atlas-ezo-sensor.c
Source file repositories/reference/linux-study-clean/drivers/iio/chemical/atlas-ezo-sensor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/chemical/atlas-ezo-sensor.c- Extension
.c- Size
- 5497 bytes
- Lines
- 245
- 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/init.hlinux/delay.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/property.hlinux/err.hlinux/i2c.hlinux/iio/iio.h
Detected Declarations
struct atlas_ezo_devicestruct atlas_ezo_datafunction atlas_ezo_sanitizefunction atlas_ezo_read_rawfunction atlas_ezo_probe
Annotated Snippet
struct atlas_ezo_device {
const struct iio_chan_spec *channels;
int num_channels;
int delay;
};
struct atlas_ezo_data {
struct i2c_client *client;
const struct atlas_ezo_device *chip;
/* lock to avoid multiple concurrent read calls */
struct mutex lock;
u8 buffer[8];
};
#define ATLAS_CONCENTRATION_CHANNEL(_modifier) \
{ \
.type = IIO_CONCENTRATION, \
.modified = 1,\
.channel2 = _modifier, \
.info_mask_separate = \
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), \
.scan_index = 0, \
.scan_type = { \
.sign = 'u', \
.realbits = 32, \
.storagebits = 32, \
.endianness = IIO_CPU, \
}, \
}
static const struct iio_chan_spec atlas_co2_ezo_channels[] = {
ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_CO2),
};
static const struct iio_chan_spec atlas_o2_ezo_channels[] = {
ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_O2),
};
static const struct iio_chan_spec atlas_hum_ezo_channels[] = {
{
.type = IIO_HUMIDITYRELATIVE,
.info_mask_separate =
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
.scan_index = 0,
.scan_type = {
.sign = 'u',
.realbits = 32,
.storagebits = 32,
.endianness = IIO_CPU,
},
},
};
static const struct atlas_ezo_device atlas_ezo_devices[] = {
[ATLAS_CO2_EZO] = {
.channels = atlas_co2_ezo_channels,
.num_channels = 1,
.delay = ATLAS_INT_TIME_IN_MS,
},
[ATLAS_O2_EZO] = {
.channels = atlas_o2_ezo_channels,
.num_channels = 1,
.delay = ATLAS_INT_TIME_IN_MS,
},
[ATLAS_HUM_EZO] = {
.channels = atlas_hum_ezo_channels,
.num_channels = 1,
.delay = ATLAS_INT_HUM_TIME_IN_MS,
},
};
static void atlas_ezo_sanitize(char *buf)
{
char *ptr = strchr(buf, '.');
if (!ptr)
return;
memmove(ptr, ptr + 1, strlen(ptr));
}
static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
struct atlas_ezo_data *data = iio_priv(indio_dev);
struct i2c_client *client = data->client;
Annotation
- Immediate include surface: `linux/init.h`, `linux/delay.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/mutex.h`, `linux/property.h`, `linux/err.h`, `linux/i2c.h`.
- Detected declarations: `struct atlas_ezo_device`, `struct atlas_ezo_data`, `function atlas_ezo_sanitize`, `function atlas_ezo_read_raw`, `function atlas_ezo_probe`.
- 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.