drivers/iio/humidity/hts221_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/humidity/hts221_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/humidity/hts221_core.c- Extension
.c- Size
- 15423 bytes
- Lines
- 683
- 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/kernel.hlinux/module.hlinux/device.hlinux/iio/sysfs.hlinux/delay.hlinux/pm.hlinux/regmap.hlinux/regulator/consumer.hlinux/bitfield.hhts221.h
Detected Declarations
struct hts221_odrstruct hts221_avgfunction hts221_check_whoamifunction hts221_update_odrfunction hts221_update_avgfunction hts221_sysfs_sampling_freqfunction hts221_sysfs_rh_oversampling_availfunction hts221_sysfs_temp_oversampling_availfunction hts221_set_enablefunction hts221_parse_temp_caldatafunction hts221_parse_rh_caldatafunction hts221_get_sensor_scalefunction hts221_get_sensor_offsetfunction hts221_read_oneshotfunction __hts221_read_rawfunction hts221_read_rawfunction __hts221_write_rawfunction hts221_write_rawfunction hts221_validate_triggerfunction hts221_init_regulatorsfunction hts221_probefunction hts221_suspendfunction hts221_resume
Annotated Snippet
struct hts221_odr {
u8 hz;
u8 val;
};
#define HTS221_AVG_DEPTH 8
struct hts221_avg {
u8 addr;
u8 mask;
u16 avg_avl[HTS221_AVG_DEPTH];
};
static const struct hts221_odr hts221_odr_table[] = {
{ 1, 0x01 }, /* 1Hz */
{ 7, 0x02 }, /* 7Hz */
{ 13, 0x03 }, /* 12.5Hz */
};
static const struct hts221_avg hts221_avg_list[] = {
{
.addr = 0x10,
.mask = 0x07,
.avg_avl = {
4, /* 0.4 %RH */
8, /* 0.3 %RH */
16, /* 0.2 %RH */
32, /* 0.15 %RH */
64, /* 0.1 %RH */
128, /* 0.07 %RH */
256, /* 0.05 %RH */
512, /* 0.03 %RH */
},
},
{
.addr = 0x10,
.mask = 0x38,
.avg_avl = {
2, /* 0.08 degC */
4, /* 0.05 degC */
8, /* 0.04 degC */
16, /* 0.03 degC */
32, /* 0.02 degC */
64, /* 0.015 degC */
128, /* 0.01 degC */
256, /* 0.007 degC */
},
},
};
static const struct iio_chan_spec hts221_channels[] = {
{
.type = IIO_HUMIDITYRELATIVE,
.address = 0x28,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
.scan_index = 0,
.scan_type = {
.sign = 's',
.realbits = 16,
.storagebits = 16,
.endianness = IIO_LE,
},
},
{
.type = IIO_TEMP,
.address = 0x2a,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO),
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
.scan_index = 1,
.scan_type = {
.sign = 's',
.realbits = 16,
.storagebits = 16,
.endianness = IIO_LE,
},
},
IIO_CHAN_SOFT_TIMESTAMP(2),
};
static int hts221_check_whoami(struct hts221_hw *hw)
{
int err, data;
err = regmap_read(hw->regmap, HTS221_REG_WHOAMI_ADDR, &data);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/device.h`, `linux/iio/sysfs.h`, `linux/delay.h`, `linux/pm.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct hts221_odr`, `struct hts221_avg`, `function hts221_check_whoami`, `function hts221_update_odr`, `function hts221_update_avg`, `function hts221_sysfs_sampling_freq`, `function hts221_sysfs_rh_oversampling_avail`, `function hts221_sysfs_temp_oversampling_avail`, `function hts221_set_enable`, `function hts221_parse_temp_caldata`.
- 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.