drivers/iio/light/opt3001.c

Source file repositories/reference/linux-study-clean/drivers/iio/light/opt3001.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/light/opt3001.c
Extension
.c
Size
22289 bytes
Lines
980
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 opt3001_scale {
	int	val;
	int	val2;
};

struct opt3001_chip_info {
	const struct iio_chan_spec (*channels)[2];
	enum iio_chan_type chan_type;
	int num_channels;

	const struct opt3001_scale (*scales)[12];
	/*
	 * Factor as specified by conversion equation in datasheet.
	 * eg. 0.01 (scaled to integer 10) for opt3001.
	 */
	int factor_whole;
	/*
	 * Factor to compensate for potentially scaled factor_whole.
	 */
	int factor_integer;
	/*
	 * Factor used to align decimal part of processed value to six decimal
	 * places.
	 */
	int factor_decimal;

	bool has_id;
};

struct opt3001 {
	struct i2c_client	*client;
	struct device		*dev;

	struct mutex		lock;
	bool			ok_to_ignore_lock;
	bool			result_ready;
	wait_queue_head_t	result_ready_queue;
	u16			result;
	const struct opt3001_chip_info *chip_info;

	u32			int_time;
	u32			mode;

	u16			high_thresh_mantissa;
	u16			low_thresh_mantissa;

	u8			high_thresh_exp;
	u8			low_thresh_exp;

	bool			use_irq;
};

static const struct opt3001_scale opt3001_scales[] = {
	{
		.val = 40,
		.val2 = 950000,
	},
	{
		.val = 81,
		.val2 = 900000,
	},
	{
		.val = 163,
		.val2 = 800000,
	},
	{
		.val = 327,
		.val2 = 600000,
	},
	{
		.val = 655,
		.val2 = 200000,
	},
	{
		.val = 1310,
		.val2 = 400000,
	},
	{
		.val = 2620,
		.val2 = 800000,
	},
	{
		.val = 5241,
		.val2 = 600000,
	},
	{
		.val = 10483,
		.val2 = 200000,
	},
	{

Annotation

Implementation Notes