drivers/iio/pressure/rohm-bm1390.c
Source file repositories/reference/linux-study-clean/drivers/iio/pressure/rohm-bm1390.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/pressure/rohm-bm1390.c- Extension
.c- Size
- 22768 bytes
- Lines
- 914
- 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.
- 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/bitfield.hlinux/bits.hlinux/cleanup.hlinux/device.hlinux/i2c.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.hlinux/iio/iio.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct bm1390_data_bufstruct bm1390_dataenum bm1390_meas_modefunction bm1390_read_tempfunction bm1390_pressure_readfunction bm1390_meas_setfunction bm1390_read_datafunction bm1390_read_rawfunction __bm1390_fifo_flushfunction bm1390_fifo_flushfunction bm1390_set_watermarkfunction bm1390_chip_initfunction bm1390_fifo_set_wmifunction bm1390_fifo_enablefunction bm1390_fifo_disablefunction bm1390_buffer_postenablefunction bm1390_buffer_predisablefunction bm1390_trigger_handlerfunction bm1390_irq_handlerfunction bm1390_irq_thread_handlerfunction bm1390_set_drdy_irqfunction bm1390_trigger_set_statefunction bm1390_setup_bufferfunction bm1390_setup_triggerfunction bm1390_probe
Annotated Snippet
struct bm1390_data_buf {
u32 pressure;
__be16 temp;
aligned_s64 ts;
};
/* BM1390 has FIFO for 4 pressure samples */
#define BM1390_FIFO_LENGTH 4
struct bm1390_data {
s64 timestamp, old_timestamp;
struct iio_trigger *trig;
struct regmap *regmap;
struct device *dev;
struct bm1390_data_buf buf;
int irq;
unsigned int state;
bool trigger_enabled;
u8 watermark;
/* Prevent accessing sensor during FIFO read sequence */
struct mutex mutex;
};
enum {
BM1390_CHAN_PRESSURE,
BM1390_CHAN_TEMP,
};
static const struct iio_chan_spec bm1390_channels[] = {
{
.type = IIO_PRESSURE,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
/*
* When IIR is used, we must fix amount of averaged samples.
* Thus we don't allow setting oversampling ratio.
*/
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
.scan_index = BM1390_CHAN_PRESSURE,
.scan_type = {
.sign = 'u',
.realbits = 22,
.storagebits = 32,
.endianness = IIO_LE,
},
},
{
.type = IIO_TEMP,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
.scan_index = BM1390_CHAN_TEMP,
.scan_type = {
.sign = 's',
.realbits = 16,
.storagebits = 16,
.endianness = IIO_BE,
},
},
IIO_CHAN_SOFT_TIMESTAMP(2),
};
/*
* We can't skip reading the pressure because the watermark IRQ is acked
* only when the pressure data is read from the FIFO.
*/
static const unsigned long bm1390_scan_masks[] = {
BIT(BM1390_CHAN_PRESSURE),
BIT(BM1390_CHAN_PRESSURE) | BIT(BM1390_CHAN_TEMP),
0
};
static int bm1390_read_temp(struct bm1390_data *data, int *temp)
{
__be16 temp_raw;
int ret;
ret = regmap_bulk_read(data->regmap, BM1390_REG_TEMP_HI, &temp_raw,
sizeof(temp_raw));
if (ret)
return ret;
*temp = be16_to_cpu(temp_raw);
return 0;
}
static int bm1390_pressure_read(struct bm1390_data *data, u32 *pressure)
{
/* Pressure data is in 3 8-bit registers */
u8 raw[3];
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/device.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct bm1390_data_buf`, `struct bm1390_data`, `enum bm1390_meas_mode`, `function bm1390_read_temp`, `function bm1390_pressure_read`, `function bm1390_meas_set`, `function bm1390_read_data`, `function bm1390_read_raw`, `function __bm1390_fifo_flush`, `function bm1390_fifo_flush`.
- 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.
- 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.