drivers/iio/pressure/st_pressure_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/pressure/st_pressure_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/pressure/st_pressure_core.c- Extension
.c- Size
- 19710 bytes
- Lines
- 799
- 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/mutex.hlinux/sysfs.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/unaligned.hlinux/iio/common/st_sensors.hst_pressure.h
Detected Declarations
function st_press_write_rawfunction st_press_read_rawfunction st_press_get_settingsfunction st_press_common_probe
Annotated Snippet
switch (ch->type) {
case IIO_PRESSURE:
*val = 0;
*val2 = press_data->current_fullscale->gain;
return IIO_VAL_INT_PLUS_NANO;
case IIO_TEMP:
*val = MCELSIUS_PER_CELSIUS;
*val2 = press_data->current_fullscale->gain2;
return IIO_VAL_FRACTIONAL;
default:
err = -EINVAL;
goto read_error;
}
case IIO_CHAN_INFO_OFFSET:
switch (ch->type) {
case IIO_TEMP:
*val = ST_PRESS_MILLI_CELSIUS_OFFSET *
press_data->current_fullscale->gain2;
*val2 = MCELSIUS_PER_CELSIUS;
break;
default:
err = -EINVAL;
goto read_error;
}
return IIO_VAL_FRACTIONAL;
case IIO_CHAN_INFO_SAMP_FREQ:
*val = press_data->odr;
return IIO_VAL_INT;
default:
return -EINVAL;
}
read_error:
return err;
}
static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL();
static struct attribute *st_press_attributes[] = {
&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
NULL,
};
static const struct attribute_group st_press_attribute_group = {
.attrs = st_press_attributes,
};
static const struct iio_info press_info = {
.attrs = &st_press_attribute_group,
.read_raw = &st_press_read_raw,
.write_raw = &st_press_write_raw,
.debugfs_reg_access = &st_sensors_debugfs_reg_access,
};
#ifdef CONFIG_IIO_TRIGGER
static const struct iio_trigger_ops st_press_trigger_ops = {
.set_trigger_state = ST_PRESS_TRIGGER_SET_STATE,
.validate_device = st_sensors_validate_device,
};
#define ST_PRESS_TRIGGER_OPS (&st_press_trigger_ops)
#else
#define ST_PRESS_TRIGGER_OPS NULL
#endif
/*
* st_press_get_settings() - get sensor settings from device name
* @name: device name buffer reference.
*
* Return: valid reference on success, NULL otherwise.
*/
const struct st_sensor_settings *st_press_get_settings(const char *name)
{
int index = st_sensors_get_settings_index(name,
st_press_sensors_settings,
ARRAY_SIZE(st_press_sensors_settings));
if (index < 0)
return NULL;
return &st_press_sensors_settings[index];
}
EXPORT_SYMBOL_NS(st_press_get_settings, "IIO_ST_SENSORS");
int st_press_common_probe(struct iio_dev *indio_dev)
{
struct st_sensor_data *press_data = iio_priv(indio_dev);
struct device *parent = indio_dev->dev.parent;
struct st_sensors_platform_data *pdata = dev_get_platdata(parent);
int err;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/sysfs.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/iio/trigger.h`, `linux/unaligned.h`.
- Detected declarations: `function st_press_write_raw`, `function st_press_read_raw`, `function st_press_get_settings`, `function st_press_common_probe`.
- 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.