drivers/iio/chemical/atlas-sensor.c

Source file repositories/reference/linux-study-clean/drivers/iio/chemical/atlas-sensor.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/chemical/atlas-sensor.c
Extension
.c
Size
18525 bytes
Lines
772
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct atlas_data {
	struct i2c_client *client;
	struct iio_trigger *trig;
	const struct atlas_device *chip;
	struct regmap *regmap;
	struct irq_work work;
	unsigned int interrupt_enabled;
	/* 96-bit data + 32-bit pad + 64-bit timestamp */
	__be32 buffer[6] __aligned(8);
};

static const struct regmap_config atlas_regmap_config = {
	.name = "atlas_regmap",
	.reg_bits = 8,
	.val_bits = 8,
};

static int atlas_buffer_num_channels(const struct iio_chan_spec *spec)
{
	int idx = 0;

	for (; spec->type != IIO_TIMESTAMP; spec++)
		idx++;

	return idx;
};

static const struct iio_chan_spec atlas_ph_channels[] = {
	{
		.type = IIO_PH,
		.address = ATLAS_REG_PH_DATA,
		.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_BE,
		},
	},
	IIO_CHAN_SOFT_TIMESTAMP(1),
	{
		.type = IIO_TEMP,
		.address = ATLAS_REG_PH_TEMP_DATA,
		.info_mask_separate =
			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
		.output = 1,
		.scan_index = -1
	},
};

#define ATLAS_CONCENTRATION_CHANNEL(_idx, _addr) \
	{\
		.type = IIO_CONCENTRATION, \
		.indexed = 1, \
		.channel = _idx, \
		.address = _addr, \
		.info_mask_separate = \
			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), \
		.scan_index = _idx + 1, \
		.scan_type = { \
			.sign = 'u', \
			.realbits = 32, \
			.storagebits = 32, \
			.endianness = IIO_BE, \
		}, \
	}

static const struct iio_chan_spec atlas_ec_channels[] = {
	{
		.type = IIO_ELECTRICALCONDUCTIVITY,
		.address = ATLAS_REG_EC_DATA,
		.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_BE,
		},
	},
	ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_TDS_DATA),
	ATLAS_CONCENTRATION_CHANNEL(1, ATLAS_REG_PSS_DATA),
	IIO_CHAN_SOFT_TIMESTAMP(3),
	{
		.type = IIO_TEMP,
		.address = ATLAS_REG_EC_TEMP_DATA,
		.info_mask_separate =

Annotation

Implementation Notes