drivers/iio/magnetometer/ak8975.c
Source file repositories/reference/linux-study-clean/drivers/iio/magnetometer/ak8975.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/magnetometer/ak8975.c- Extension
.c- Size
- 29058 bytes
- Lines
- 1144
- 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/module.hlinux/mod_devicetable.hlinux/kernel.hlinux/slab.hlinux/i2c.hlinux/interrupt.hlinux/err.hlinux/mutex.hlinux/delay.hlinux/bitops.hlinux/gpio/consumer.hlinux/regulator/consumer.hlinux/pm_runtime.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/buffer.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct ak_defstruct ak8975_dataenum asahi_compass_chipsetenum ak_ctrl_reg_addrenum ak_ctrl_reg_maskenum ak_ctrl_modefunction Copyrightfunction ak8963_09911_raw_to_gaussfunction ak09912_raw_to_gaussfunction ak8975_power_onfunction ak8975_power_offfunction ak8975_who_i_amfunction ak8975_set_modefunction ak8975_irq_handlerfunction ak8975_setup_irqfunction ak8975_setupfunction wait_conversion_complete_gpiofunction wait_conversion_complete_polledfunction wait_conversion_complete_interruptfunction ak8975_start_read_axisfunction ak8975_read_axisfunction ak8975_read_rawfunction ak8975_get_mount_matrixfunction ak8975_fill_bufferfunction ak8975_handle_triggerfunction ak8975_probefunction ak8975_removefunction ak8975_runtime_suspendfunction ak8975_runtime_resume
Annotated Snippet
struct ak_def {
enum asahi_compass_chipset type;
long (*raw_to_gauss)(u16 data);
u16 range;
u8 ctrl_regs[REGS_END];
u8 ctrl_masks[MASK_END];
u8 ctrl_modes[MODE_END];
u8 data_regs[3];
};
static const struct ak_def ak_def_array[] = {
[AK8975] = {
.type = AK8975,
.raw_to_gauss = ak8975_raw_to_gauss,
.range = 4096,
.ctrl_regs = {
AK8975_REG_ST1,
AK8975_REG_ST2,
AK8975_REG_CNTL,
AK8975_REG_ASAX,
AK8975_MAX_REGS},
.ctrl_masks = {
AK8975_REG_ST1_DRDY_MASK,
AK8975_REG_ST2_HOFL_MASK,
AK8975_REG_ST2_DERR_MASK,
AK8975_REG_CNTL_MODE_MASK},
.ctrl_modes = {
AK8975_REG_CNTL_MODE_POWER_DOWN,
AK8975_REG_CNTL_MODE_ONCE,
AK8975_REG_CNTL_MODE_SELF_TEST,
AK8975_REG_CNTL_MODE_FUSE_ROM},
.data_regs = {
AK8975_REG_HXL,
AK8975_REG_HYL,
AK8975_REG_HZL},
},
[AK8963] = {
.type = AK8963,
.raw_to_gauss = ak8963_09911_raw_to_gauss,
.range = 8190,
.ctrl_regs = {
AK8975_REG_ST1,
AK8975_REG_ST2,
AK8975_REG_CNTL,
AK8975_REG_ASAX,
AK8975_MAX_REGS},
.ctrl_masks = {
AK8975_REG_ST1_DRDY_MASK,
AK8975_REG_ST2_HOFL_MASK,
0,
AK8975_REG_CNTL_MODE_MASK},
.ctrl_modes = {
AK8975_REG_CNTL_MODE_POWER_DOWN,
AK8975_REG_CNTL_MODE_ONCE,
AK8975_REG_CNTL_MODE_SELF_TEST,
AK8975_REG_CNTL_MODE_FUSE_ROM},
.data_regs = {
AK8975_REG_HXL,
AK8975_REG_HYL,
AK8975_REG_HZL},
},
[AK09911] = {
.type = AK09911,
.raw_to_gauss = ak8963_09911_raw_to_gauss,
.range = 8192,
.ctrl_regs = {
AK09912_REG_ST1,
AK09912_REG_ST2,
AK09912_REG_CNTL2,
AK09912_REG_ASAX,
AK09912_MAX_REGS},
.ctrl_masks = {
AK09912_REG_ST1_DRDY_MASK,
AK09912_REG_ST2_HOFL_MASK,
0,
AK09912_REG_CNTL2_MODE_MASK},
.ctrl_modes = {
AK09912_REG_CNTL_MODE_POWER_DOWN,
AK09912_REG_CNTL_MODE_ONCE,
AK09912_REG_CNTL_MODE_SELF_TEST,
AK09912_REG_CNTL_MODE_FUSE_ROM},
.data_regs = {
AK09912_REG_HXL,
AK09912_REG_HYL,
AK09912_REG_HZL},
},
[AK09912] = {
.type = AK09912,
.raw_to_gauss = ak09912_raw_to_gauss,
.range = 32752,
Annotation
- Immediate include surface: `linux/module.h`, `linux/mod_devicetable.h`, `linux/kernel.h`, `linux/slab.h`, `linux/i2c.h`, `linux/interrupt.h`, `linux/err.h`, `linux/mutex.h`.
- Detected declarations: `struct ak_def`, `struct ak8975_data`, `enum asahi_compass_chipset`, `enum ak_ctrl_reg_addr`, `enum ak_ctrl_reg_mask`, `enum ak_ctrl_mode`, `function Copyright`, `function ak8963_09911_raw_to_gauss`, `function ak09912_raw_to_gauss`, `function ak8975_power_on`.
- 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.