drivers/iio/accel/adis16201.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/adis16201.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/adis16201.c- Extension
.c- Size
- 8485 bytes
- Lines
- 304
- 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/device.hlinux/kernel.hlinux/module.hlinux/spi/spi.hlinux/iio/iio.hlinux/iio/imu/adis.h
Detected Declarations
enum adis16201_scanfunction adis16201_read_rawfunction adis16201_write_rawfunction adis16201_probe
Annotated Snippet
switch (chan->type) {
case IIO_VOLTAGE:
if (chan->channel == 0) {
/* Voltage base units are mV hence 1.22 mV */
*val = 1;
*val2 = 220000;
} else {
/* Voltage base units are mV hence 0.61 mV */
*val = 0;
*val2 = 610000;
}
return IIO_VAL_INT_PLUS_MICRO;
case IIO_TEMP:
*val = -470;
*val2 = 0;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_ACCEL:
/*
* IIO base unit for sensitivity of accelerometer
* is milli g.
* 1 LSB represents 0.244 mg.
*/
*val = 0;
*val2 = IIO_G_TO_M_S_2(462400);
return IIO_VAL_INT_PLUS_NANO;
case IIO_INCLI:
*val = 0;
*val2 = 100000;
return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
}
break;
case IIO_CHAN_INFO_OFFSET:
/*
* The raw ADC value is 1278 when the temperature
* is 25 degrees and the scale factor per milli
* degree Celsius is -470.
*/
*val = 25000 / -470 - 1278;
return IIO_VAL_INT;
case IIO_CHAN_INFO_CALIBBIAS:
switch (chan->type) {
case IIO_ACCEL:
bits = 12;
break;
case IIO_INCLI:
bits = 9;
break;
default:
return -EINVAL;
}
addr = adis16201_addresses[chan->scan_index];
ret = adis_read_reg_16(st, addr, &val16);
if (ret)
return ret;
*val = sign_extend32(val16, bits - 1);
return IIO_VAL_INT;
}
return -EINVAL;
}
static int adis16201_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val,
int val2,
long mask)
{
struct adis *st = iio_priv(indio_dev);
int m;
if (mask != IIO_CHAN_INFO_CALIBBIAS)
return -EINVAL;
switch (chan->type) {
case IIO_ACCEL:
m = GENMASK(11, 0);
break;
case IIO_INCLI:
m = GENMASK(8, 0);
break;
default:
return -EINVAL;
}
return adis_write_reg_16(st, adis16201_addresses[chan->scan_index],
val & m);
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/module.h`, `linux/spi/spi.h`, `linux/iio/iio.h`, `linux/iio/imu/adis.h`.
- Detected declarations: `enum adis16201_scan`, `function adis16201_read_raw`, `function adis16201_write_raw`, `function adis16201_probe`.
- 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.