drivers/iio/pressure/mprls0025pa_i2c.c
Source file repositories/reference/linux-study-clean/drivers/iio/pressure/mprls0025pa_i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/pressure/mprls0025pa_i2c.c- Extension
.c- Size
- 2256 bytes
- Lines
- 91
- 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/device.hlinux/errno.hlinux/i2c.hlinux/mod_devicetable.hlinux/module.hlinux/types.hmprls0025pa.h
Detected Declarations
function Copyrightfunction mpr_i2c_writefunction mpr_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* MPRLS0025PA - Honeywell MicroPressure pressure sensor series driver
*
* Copyright (c) Andreas Klinger <ak@it-klinger.de>
*
* Data sheet:
* https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf
*/
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/i2c.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/types.h>
#include "mprls0025pa.h"
static int mpr_i2c_read(struct mpr_data *data, const u8 unused, const u8 cnt)
{
int ret;
struct i2c_client *client = to_i2c_client(data->dev);
if (cnt > MPR_MEASUREMENT_RD_SIZE)
return -EOVERFLOW;
ret = i2c_master_recv(client, data->rx_buf, cnt);
if (ret < 0)
return ret;
else if (ret != cnt)
return -EIO;
return 0;
}
static int mpr_i2c_write(struct mpr_data *data, const u8 cmd, const u8 unused)
{
int ret;
struct i2c_client *client = to_i2c_client(data->dev);
data->tx_buf[0] = cmd;
ret = i2c_master_send(client, data->tx_buf, MPR_PKT_SYNC_LEN);
if (ret < 0)
return ret;
else if (ret != MPR_PKT_SYNC_LEN)
return -EIO;
return 0;
}
static const struct mpr_ops mpr_i2c_ops = {
.read = mpr_i2c_read,
.write = mpr_i2c_write,
};
static int mpr_i2c_probe(struct i2c_client *client)
{
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE))
return -EOPNOTSUPP;
return mpr_common_probe(&client->dev, &mpr_i2c_ops, client->irq);
}
static const struct of_device_id mpr_i2c_match[] = {
{ .compatible = "honeywell,mprls0025pa" },
{ }
};
MODULE_DEVICE_TABLE(of, mpr_i2c_match);
static const struct i2c_device_id mpr_i2c_id[] = {
{ "mprls0025pa" },
{ }
};
MODULE_DEVICE_TABLE(i2c, mpr_i2c_id);
static struct i2c_driver mpr_i2c_driver = {
.probe = mpr_i2c_probe,
.id_table = mpr_i2c_id,
.driver = {
.name = "mprls0025pa",
.of_match_table = mpr_i2c_match,
},
};
module_i2c_driver(mpr_i2c_driver);
MODULE_AUTHOR("Andreas Klinger <ak@it-klinger.de>");
MODULE_DESCRIPTION("Honeywell MPR pressure sensor i2c driver");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("IIO_HONEYWELL_MPRLS0025PA");
Annotation
- Immediate include surface: `linux/device.h`, `linux/errno.h`, `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/types.h`, `mprls0025pa.h`.
- Detected declarations: `function Copyright`, `function mpr_i2c_write`, `function mpr_i2c_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.