drivers/iio/humidity/hdc2010.c
Source file repositories/reference/linux-study-clean/drivers/iio/humidity/hdc2010.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/humidity/hdc2010.c- Extension
.c- Size
- 8476 bytes
- Lines
- 347
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/i2c.hlinux/bitops.hlinux/iio/iio.hlinux/iio/sysfs.h
Detected Declarations
struct hdc2010_datastruct hdc2010_reg_recordenum hdc2010_addr_groupsfunction hdc2010_update_drdy_configfunction hdc2010_get_prim_measurement_wordfunction hdc2010_get_peak_measurement_bytefunction hdc2010_get_heater_statusfunction hdc2010_read_rawfunction hdc2010_write_rawfunction hdc2010_probefunction hdc2010_remove
Annotated Snippet
struct hdc2010_data {
struct i2c_client *client;
struct mutex lock;
u8 measurement_config;
u8 drdy_config;
};
enum hdc2010_addr_groups {
HDC2010_GROUP_TEMP = 0,
HDC2010_GROUP_HUMIDITY,
};
struct hdc2010_reg_record {
unsigned long primary;
unsigned long peak;
};
static const struct hdc2010_reg_record hdc2010_reg_translation[] = {
[HDC2010_GROUP_TEMP] = {
.primary = HDC2010_REG_TEMP_LOW,
.peak = HDC2010_REG_TEMP_MAX,
},
[HDC2010_GROUP_HUMIDITY] = {
.primary = HDC2010_REG_HUMIDITY_LOW,
.peak = HDC2010_REG_HUMIDITY_MAX,
},
};
static IIO_CONST_ATTR(out_current_heater_raw_available, "0 1");
static struct attribute *hdc2010_attributes[] = {
&iio_const_attr_out_current_heater_raw_available.dev_attr.attr,
NULL
};
static const struct attribute_group hdc2010_attribute_group = {
.attrs = hdc2010_attributes,
};
static const struct iio_chan_spec hdc2010_channels[] = {
{
.type = IIO_TEMP,
.address = HDC2010_GROUP_TEMP,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PEAK) |
BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE),
},
{
.type = IIO_HUMIDITYRELATIVE,
.address = HDC2010_GROUP_HUMIDITY,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PEAK) |
BIT(IIO_CHAN_INFO_SCALE),
},
{
.type = IIO_CURRENT,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.extend_name = "heater",
.output = 1,
},
};
static int hdc2010_update_drdy_config(struct hdc2010_data *data,
char mask, char val)
{
u8 tmp = (~mask & data->drdy_config) | val;
int ret;
ret = i2c_smbus_write_byte_data(data->client,
HDC2010_REG_RESET_DRDY_INT_CONF, tmp);
if (ret)
return ret;
data->drdy_config = tmp;
return 0;
}
static int hdc2010_get_prim_measurement_word(struct hdc2010_data *data,
struct iio_chan_spec const *chan)
{
struct i2c_client *client = data->client;
s32 ret;
ret = i2c_smbus_read_word_data(client,
hdc2010_reg_translation[chan->address].primary);
if (ret < 0)
dev_err(&client->dev, "Could not read sensor measurement word\n");
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/i2c.h`, `linux/bitops.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`.
- Detected declarations: `struct hdc2010_data`, `struct hdc2010_reg_record`, `enum hdc2010_addr_groups`, `function hdc2010_update_drdy_config`, `function hdc2010_get_prim_measurement_word`, `function hdc2010_get_peak_measurement_byte`, `function hdc2010_get_heater_status`, `function hdc2010_read_raw`, `function hdc2010_write_raw`, `function hdc2010_probe`.
- 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.
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.