drivers/iio/imu/adis.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/adis.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/adis.c- Extension
.c- Size
- 13547 bytes
- Lines
- 551
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/gpio/consumer.hlinux/mutex.hlinux/device.hlinux/kernel.hlinux/spi/spi.hlinux/module.hlinux/unaligned.hlinux/iio/iio.hlinux/iio/imu/adis.h
Detected Declarations
function __adis_write_regfunction __adis_read_regfunction __adis_update_bits_basefunction adis_debugfs_reg_accessfunction __adis_enable_irqfunction __adis_check_statusfunction __adis_resetfunction adis_self_testfunction __adis_initial_startupfunction adis_single_conversionfunction adis_init
Annotated Snippet
if (status & BIT(i)) {
dev_err(&adis->spi->dev, "%s.\n",
adis->data->status_error_msgs[i]);
}
}
return -EIO;
}
EXPORT_SYMBOL_NS_GPL(__adis_check_status, "IIO_ADISLIB");
/**
* __adis_reset() - Reset the device (unlocked version)
* @adis: The adis device
*
* Returns 0 on success, a negative error code otherwise
*/
int __adis_reset(struct adis *adis)
{
int ret;
const struct adis_timeout *timeouts = adis->data->timeouts;
ret = __adis_write_reg_8(adis, adis->data->glob_cmd_reg,
ADIS_GLOB_CMD_SW_RESET);
if (ret) {
dev_err(&adis->spi->dev, "Failed to reset device: %d\n", ret);
return ret;
}
msleep(timeouts->sw_reset_ms);
return 0;
}
EXPORT_SYMBOL_NS_GPL(__adis_reset, "IIO_ADIS_LIB");
static int adis_self_test(struct adis *adis)
{
int ret;
const struct adis_timeout *timeouts = adis->data->timeouts;
ret = __adis_write_reg_16(adis, adis->data->self_test_reg,
adis->data->self_test_mask);
if (ret) {
dev_err(&adis->spi->dev, "Failed to initiate self test: %d\n",
ret);
return ret;
}
msleep(timeouts->self_test_ms);
ret = __adis_check_status(adis);
if (adis->data->self_test_no_autoclear)
__adis_write_reg_16(adis, adis->data->self_test_reg, 0x00);
return ret;
}
/**
* __adis_initial_startup() - Device initial setup
* @adis: The adis device
*
* The function performs a HW reset via a reset pin that should be specified
* via GPIOLIB. If no pin is configured a SW reset will be performed.
* The RST pin for the ADIS devices should be configured as ACTIVE_LOW.
*
* After the self-test operation is performed, the function will also check
* that the product ID is as expected. This assumes that drivers providing
* 'prod_id_reg' will also provide the 'prod_id'.
*
* Returns 0 if the device is operational, a negative error code otherwise.
*
* This function should be called early on in the device initialization sequence
* to ensure that the device is in a sane and known state and that it is usable.
*/
int __adis_initial_startup(struct adis *adis)
{
const struct adis_timeout *timeouts = adis->data->timeouts;
struct gpio_desc *gpio;
u16 prod_id;
int ret;
/* check if the device has rst pin low */
gpio = devm_gpiod_get_optional(&adis->spi->dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(gpio))
return PTR_ERR(gpio);
if (gpio) {
usleep_range(10, 12);
/* bring device out of reset */
gpiod_set_value_cansleep(gpio, 0);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gpio/consumer.h`, `linux/mutex.h`, `linux/device.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/module.h`, `linux/unaligned.h`.
- Detected declarations: `function __adis_write_reg`, `function __adis_read_reg`, `function __adis_update_bits_base`, `function adis_debugfs_reg_access`, `function __adis_enable_irq`, `function __adis_check_status`, `function __adis_reset`, `function adis_self_test`, `function __adis_initial_startup`, `function adis_single_conversion`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.