drivers/staging/iio/addac/adt7316.c
Source file repositories/reference/linux-study-clean/drivers/staging/iio/addac/adt7316.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/iio/addac/adt7316.c- Extension
.c- Size
- 58502 bytes
- Lines
- 2198
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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.
- 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/interrupt.hlinux/gpio/consumer.hlinux/irq.hlinux/workqueue.hlinux/device.hlinux/kernel.hlinux/slab.hlinux/sysfs.hlinux/list.hlinux/i2c.hlinux/rtc.hlinux/module.hlinux/iio/iio.hlinux/iio/events.hlinux/iio/sysfs.hadt7316.h
Detected Declarations
struct adt7316_chip_infofunction adt7316_show_enabledfunction _adt7316_store_enabledfunction adt7316_store_enabledfunction adt7316_show_select_ex_tempfunction adt7316_store_select_ex_tempfunction adt7316_show_modefunction adt7316_store_modefunction adt7316_show_all_modesfunction adt7316_show_ad_channelfunction adt7316_store_ad_channelfunction adt7316_show_all_ad_channelsfunction adt7316_show_disable_averagingfunction adt7316_store_disable_averagingfunction adt7316_show_enable_smbus_timeoutfunction adt7316_store_enable_smbus_timeoutfunction adt7316_show_powerdownfunction adt7316_store_powerdownfunction adt7316_show_fast_ad_clockfunction adt7316_store_fast_ad_clockfunction adt7316_show_da_high_resolutionfunction adt7316_store_da_high_resolutionfunction adt7316_show_AIN_internal_Vreffunction adt7316_store_AIN_internal_Vreffunction adt7316_show_enable_prop_DACAfunction adt7316_store_enable_prop_DACAfunction adt7316_show_enable_prop_DACBfunction adt7316_store_enable_prop_DACBfunction adt7316_show_DAC_2Vref_ch_maskfunction adt7316_store_DAC_2Vref_ch_maskfunction adt7316_show_DAC_update_modefunction adt7316_store_DAC_update_modefunction adt7316_show_all_DAC_update_modesfunction adt7316_store_update_DACfunction adt7316_show_DA_AB_Vref_bypassfunction adt7316_store_DA_AB_Vref_bypassfunction adt7316_show_DA_CD_Vref_bypassfunction adt7316_store_DA_CD_Vref_bypassfunction adt7316_show_DAC_internal_Vreffunction adt7316_store_DAC_internal_Vreffunction adt7316_show_adfunction adt7316_show_VDDfunction adt7316_show_in_tempfunction adt7316_show_ex_temp_AIN1function adt7316_show_AIN2function adt7316_show_AIN3function adt7316_show_AIN4function adt7316_show_temp_offset
Annotated Snippet
struct adt7316_chip_info {
struct adt7316_bus bus;
struct gpio_desc *ldac_pin;
u16 int_mask; /* 0x2f */
u8 config1;
u8 config2;
u8 config3;
u8 dac_config; /* DAC config */
u8 ldac_config; /* LDAC config */
u8 dac_bits; /* 8, 10, 12 */
u8 id; /* chip id */
};
/*
* Logic interrupt mask for user application to enable
* interrupts.
*/
#define ADT7316_IN_TEMP_HIGH_INT_MASK 0x1
#define ADT7316_IN_TEMP_LOW_INT_MASK 0x2
#define ADT7316_EX_TEMP_HIGH_INT_MASK 0x4
#define ADT7316_EX_TEMP_LOW_INT_MASK 0x8
#define ADT7316_EX_TEMP_FAULT_INT_MASK 0x10
#define ADT7516_AIN1_INT_MASK 0x4
#define ADT7516_AIN2_INT_MASK 0x20
#define ADT7516_AIN3_INT_MASK 0x40
#define ADT7516_AIN4_INT_MASK 0x80
#define ADT7316_VDD_INT_MASK 0x100
#define ADT7316_TEMP_INT_MASK 0x1F
#define ADT7516_AIN_INT_MASK 0xE0
#define ADT7316_TEMP_AIN_INT_MASK \
(ADT7316_TEMP_INT_MASK)
static ssize_t adt7316_show_enabled(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
return sysfs_emit(buf, "%d\n", !!(chip->config1 & ADT7316_EN));
}
static ssize_t _adt7316_store_enabled(struct adt7316_chip_info *chip,
int enable)
{
u8 config1;
int ret;
if (enable)
config1 = chip->config1 | ADT7316_EN;
else
config1 = chip->config1 & ~ADT7316_EN;
ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, config1);
if (ret)
return -EIO;
chip->config1 = config1;
return ret;
}
static ssize_t adt7316_store_enabled(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t len)
{
struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info);
int enable;
if (buf[0] == '1')
enable = 1;
else
enable = 0;
if (_adt7316_store_enabled(chip, enable) < 0)
return -EIO;
return len;
}
static IIO_DEVICE_ATTR(enabled, 0644,
adt7316_show_enabled,
adt7316_store_enabled,
0);
static ssize_t adt7316_show_select_ex_temp(struct device *dev,
struct device_attribute *attr,
char *buf)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/gpio/consumer.h`, `linux/irq.h`, `linux/workqueue.h`, `linux/device.h`, `linux/kernel.h`, `linux/slab.h`, `linux/sysfs.h`.
- Detected declarations: `struct adt7316_chip_info`, `function adt7316_show_enabled`, `function _adt7316_store_enabled`, `function adt7316_store_enabled`, `function adt7316_show_select_ex_temp`, `function adt7316_store_select_ex_temp`, `function adt7316_show_mode`, `function adt7316_store_mode`, `function adt7316_show_all_modes`, `function adt7316_show_ad_channel`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: integration implementation candidate.
- 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.