drivers/iio/imu/bno055/bno055.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/bno055/bno055.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/bno055/bno055.c- Extension
.c- Size
- 46713 bytes
- Lines
- 1694
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/bitmap.hlinux/clk.hlinux/debugfs.hlinux/device.hlinux/firmware.hlinux/gpio/consumer.hlinux/module.hlinux/mutex.hlinux/regmap.hlinux/util_macros.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hbno055.h
Detected Declarations
struct bno055_sysfs_attrstruct bno055_privenum bno055_scan_axisfunction bno055_regmap_volatilefunction bno055_regmap_readablefunction bno055_regmap_writeablefunction bno055_calibration_loadfunction bno055_operation_mode_do_setfunction bno055_system_resetfunction bno055_initfunction bno055_operation_mode_setfunction bno055_uninitfunction bno055_get_regmaskfunction bno055_set_regmaskfunction bno055_read_simple_chanfunction bno055_sysfs_attr_availfunction bno055_read_availfunction bno055_read_temp_chanfunction bno055_read_quaternionfunction bno055_is_chan_readablefunction _bno055_read_raw_multifunction bno055_read_raw_multifunction _bno055_write_rawfunction bno055_write_rawfunction in_accel_range_raw_available_showfunction fusion_enable_showfunction fusion_enable_storefunction in_magn_calibration_fast_enable_showfunction in_magn_calibration_fast_enable_storefunction in_accel_range_raw_showfunction in_accel_range_raw_storefunction bno055_get_calib_statusfunction serialnumber_showfunction calibration_data_readfunction sys_calibration_auto_status_showfunction in_accel_calibration_auto_status_showfunction in_gyro_calibration_auto_status_showfunction in_magn_calibration_auto_status_showfunction bno055_debugfs_reg_accessfunction bno055_show_fw_versionfunction bno055_debugfs_removefunction bno055_debugfs_initfunction cullfunction for_each_set_bitfunction bno055_trigger_handlerfunction iio_get_masklengthfunction bno055_buffer_preenablefunction bno055_probe
Annotated Snippet
static const struct file_operations bno055_fw_version_ops = {
.open = simple_open,
.read = bno055_show_fw_version,
.llseek = default_llseek,
.owner = THIS_MODULE,
};
static void bno055_debugfs_remove(void *_priv)
{
struct bno055_priv *priv = _priv;
debugfs_remove(priv->debugfs);
priv->debugfs = NULL;
}
static void bno055_debugfs_init(struct iio_dev *iio_dev)
{
struct bno055_priv *priv = iio_priv(iio_dev);
priv->debugfs = debugfs_create_file("firmware_version", 0400,
iio_get_debugfs_dentry(iio_dev),
priv, &bno055_fw_version_ops);
if (!IS_ERR(priv->debugfs))
devm_add_action_or_reset(priv->dev, bno055_debugfs_remove,
priv);
if (IS_ERR_OR_NULL(priv->debugfs))
dev_warn(priv->dev, "failed to setup debugfs");
}
static IIO_DEVICE_ATTR_RW(fusion_enable, 0);
static IIO_DEVICE_ATTR_RW(in_magn_calibration_fast_enable, 0);
static IIO_DEVICE_ATTR_RW(in_accel_range_raw, 0);
static IIO_DEVICE_ATTR_RO(in_accel_range_raw_available, 0);
static IIO_DEVICE_ATTR_RO(sys_calibration_auto_status, 0);
static IIO_DEVICE_ATTR_RO(in_accel_calibration_auto_status, 0);
static IIO_DEVICE_ATTR_RO(in_gyro_calibration_auto_status, 0);
static IIO_DEVICE_ATTR_RO(in_magn_calibration_auto_status, 0);
static IIO_DEVICE_ATTR_RO(serialnumber, 0);
static struct attribute *bno055_attrs[] = {
&iio_dev_attr_in_accel_range_raw_available.dev_attr.attr,
&iio_dev_attr_in_accel_range_raw.dev_attr.attr,
&iio_dev_attr_fusion_enable.dev_attr.attr,
&iio_dev_attr_in_magn_calibration_fast_enable.dev_attr.attr,
&iio_dev_attr_sys_calibration_auto_status.dev_attr.attr,
&iio_dev_attr_in_accel_calibration_auto_status.dev_attr.attr,
&iio_dev_attr_in_gyro_calibration_auto_status.dev_attr.attr,
&iio_dev_attr_in_magn_calibration_auto_status.dev_attr.attr,
&iio_dev_attr_serialnumber.dev_attr.attr,
NULL
};
static const BIN_ATTR_RO(calibration_data, BNO055_CALDATA_LEN);
static const struct bin_attribute *const bno055_bin_attrs[] = {
&bin_attr_calibration_data,
NULL
};
static const struct attribute_group bno055_attrs_group = {
.attrs = bno055_attrs,
.bin_attrs = bno055_bin_attrs,
};
static const struct iio_info bno055_info = {
.read_raw_multi = bno055_read_raw_multi,
.read_avail = bno055_read_avail,
.write_raw = bno055_write_raw,
.attrs = &bno055_attrs_group,
.debugfs_reg_access = bno055_debugfs_reg_access,
};
/*
* Reads len samples from the HW, stores them in buf starting from buf_idx,
* and applies mask to cull (skip) unneeded samples.
* Updates buf_idx incrementing with the number of stored samples.
* Samples from HW are transferred into buf, then in-place copy on buf is
* performed in order to cull samples that need to be skipped.
* This avoids copies of the first samples until we hit the 1st sample to skip,
* and also avoids having an extra bounce buffer.
* buf must be able to contain len elements in spite of how many samples we are
* going to cull.
*/
static int bno055_scan_xfer(struct bno055_priv *priv,
int start_ch, int len, unsigned long mask,
__le16 *buf, int *buf_idx)
{
const int base = BNO055_ACC_DATA_X_LSB_REG;
bool quat_in_read = false;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitmap.h`, `linux/clk.h`, `linux/debugfs.h`, `linux/device.h`, `linux/firmware.h`, `linux/gpio/consumer.h`, `linux/module.h`.
- Detected declarations: `struct bno055_sysfs_attr`, `struct bno055_priv`, `enum bno055_scan_axis`, `function bno055_regmap_volatile`, `function bno055_regmap_readable`, `function bno055_regmap_writeable`, `function bno055_calibration_load`, `function bno055_operation_mode_do_set`, `function bno055_system_reset`, `function bno055_init`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: pattern 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.