drivers/iio/magnetometer/rm3100-spi.c
Source file repositories/reference/linux-study-clean/drivers/iio/magnetometer/rm3100-spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/magnetometer/rm3100-spi.c- Extension
.c- Size
- 1484 bytes
- Lines
- 65
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/spi/spi.hrm3100.h
Detected Declarations
function rm3100_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Support for PNI RM3100 3-axis geomagnetic sensor on a spi bus.
*
* Copyright (C) 2018 Song Qiang <songqiang1304521@gmail.com>
*/
#include <linux/module.h>
#include <linux/spi/spi.h>
#include "rm3100.h"
static const struct regmap_config rm3100_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.rd_table = &rm3100_readable_table,
.wr_table = &rm3100_writable_table,
.volatile_table = &rm3100_volatile_table,
.read_flag_mask = 0x80,
.cache_type = REGCACHE_RBTREE,
};
static int rm3100_probe(struct spi_device *spi)
{
struct regmap *regmap;
int ret;
/* Actually this device supports both mode 0 and mode 3. */
spi->mode = SPI_MODE_0;
/* Data rates cannot exceed 1Mbits. */
spi->max_speed_hz = 1000000;
ret = spi_setup(spi);
if (ret)
return ret;
regmap = devm_regmap_init_spi(spi, &rm3100_regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
return rm3100_common_probe(&spi->dev, regmap, spi->irq);
}
static const struct of_device_id rm3100_dt_match[] = {
{ .compatible = "pni,rm3100", },
{ }
};
MODULE_DEVICE_TABLE(of, rm3100_dt_match);
static struct spi_driver rm3100_driver = {
.driver = {
.name = "rm3100-spi",
.of_match_table = rm3100_dt_match,
},
.probe = rm3100_probe,
};
module_spi_driver(rm3100_driver);
MODULE_AUTHOR("Song Qiang <songqiang1304521@gmail.com>");
MODULE_DESCRIPTION("PNI RM3100 3-axis magnetometer spi driver");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS("IIO_RM3100");
Annotation
- Immediate include surface: `linux/module.h`, `linux/spi/spi.h`, `rm3100.h`.
- Detected declarations: `function rm3100_probe`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.