drivers/iio/light/as73211.c
Source file repositories/reference/linux-study-clean/drivers/iio/light/as73211.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/light/as73211.c- Extension
.c- Size
- 24680 bytes
- Lines
- 898
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/cleanup.hlinux/completion.hlinux/delay.hlinux/i2c.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/module.hlinux/mutex.hlinux/pm.hlinux/units.h
Detected Declarations
struct as73211_datastruct as73211_spec_dev_datastruct as73211_datafunction as73211_integration_time_1024cycfunction as73211_integration_time_usfunction as73211_integration_time_calc_availfunction as73211_gainfunction as73211_req_datafunction as73211_intensity_scalefunction as7331_intensity_scalefunction as73211_read_rawfunction as73211_read_availfunction _as73211_write_rawfunction as73211_write_rawfunction as73211_ready_handlerfunction as73211_trigger_handlerfunction as73211_powerfunction as73211_power_disablefunction as73211_probefunction as73211_suspendfunction as73211_resume
Annotated Snippet
struct as73211_spec_dev_data {
int (*intensity_scale)(struct as73211_data *data, int chan, int *val, int *val2);
struct iio_chan_spec const *channels;
int num_channels;
};
/**
* struct as73211_data - Instance data for one AS73211
* @client: I2C client.
* @osr: Cached Operational State Register.
* @creg1: Cached Configuration Register 1.
* @creg2: Cached Configuration Register 2.
* @creg3: Cached Configuration Register 3.
* @mutex: Keeps cached registers in sync with the device.
* @completion: Completion to wait for interrupt.
* @int_time_avail: Available integration times (depend on sampling frequency).
* @spec_dev: device-specific configuration.
*/
struct as73211_data {
struct i2c_client *client;
u8 osr;
u8 creg1;
u8 creg2;
u8 creg3;
struct mutex mutex;
struct completion completion;
int int_time_avail[AS73211_SAMPLE_TIME_NUM * 2];
const struct as73211_spec_dev_data *spec_dev;
};
#define AS73211_COLOR_CHANNEL(_color, _si, _addr) { \
.type = IIO_INTENSITY, \
.modified = 1, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), \
.info_mask_shared_by_type = \
BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
BIT(IIO_CHAN_INFO_HARDWAREGAIN) | \
BIT(IIO_CHAN_INFO_INT_TIME), \
.info_mask_shared_by_type_available = \
BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
BIT(IIO_CHAN_INFO_HARDWAREGAIN) | \
BIT(IIO_CHAN_INFO_INT_TIME), \
.channel2 = IIO_MOD_##_color, \
.address = _addr, \
.scan_index = _si, \
.scan_type = { \
.sign = 'u', \
.realbits = 16, \
.storagebits = 16, \
.endianness = IIO_LE, \
}, \
}
#define AS73211_OFFSET_TEMP_INT (-66)
#define AS73211_OFFSET_TEMP_MICRO 900000
#define AS73211_SCALE_TEMP_INT 0
#define AS73211_SCALE_TEMP_MICRO 50000
#define AS73211_SCALE_X 277071108 /* nW/m^2 */
#define AS73211_SCALE_Y 298384270 /* nW/m^2 */
#define AS73211_SCALE_Z 160241927 /* nW/m^2 */
#define AS7331_SCALE_UVA 340000 /* nW/cm^2 */
#define AS7331_SCALE_UVB 378000 /* nW/cm^2 */
#define AS7331_SCALE_UVC 166000 /* nW/cm^2 */
/* Channel order MUST match devices result register order */
#define AS73211_SCAN_INDEX_TEMP 0
#define AS73211_SCAN_INDEX_X 1
#define AS73211_SCAN_INDEX_Y 2
#define AS73211_SCAN_INDEX_Z 3
#define AS73211_SCAN_INDEX_TS 4
#define AS73211_SCAN_MASK_COLOR ( \
BIT(AS73211_SCAN_INDEX_X) | \
BIT(AS73211_SCAN_INDEX_Y) | \
BIT(AS73211_SCAN_INDEX_Z))
#define AS73211_SCAN_MASK_ALL ( \
BIT(AS73211_SCAN_INDEX_TEMP) | \
AS73211_SCAN_MASK_COLOR)
static const unsigned long as73211_scan_masks[] = {
AS73211_SCAN_MASK_COLOR,
AS73211_SCAN_MASK_ALL,
0
};
static const struct iio_chan_spec as73211_channels[] = {
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/completion.h`, `linux/delay.h`, `linux/i2c.h`, `linux/iio/buffer.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`.
- Detected declarations: `struct as73211_data`, `struct as73211_spec_dev_data`, `struct as73211_data`, `function as73211_integration_time_1024cyc`, `function as73211_integration_time_us`, `function as73211_integration_time_calc_avail`, `function as73211_gain`, `function as73211_req_data`, `function as73211_intensity_scale`, `function as7331_intensity_scale`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.