drivers/iio/pressure/abp2030pa_i2c.c
Source file repositories/reference/linux-study-clean/drivers/iio/pressure/abp2030pa_i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/pressure/abp2030pa_i2c.c- Extension
.c- Size
- 2023 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.habp2030pa.h
Detected Declarations
function Copyrightfunction abp2_i2c_writefunction abp2_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Honeywell ABP2 series pressure sensor driver
*
* Copyright (c) 2025 Petre Rodan <petre.rodan@subdimension.ro>
*/
#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 "abp2030pa.h"
static int abp2_i2c_read(struct abp2_data *data, u8 unused, u8 nbytes)
{
struct i2c_client *client = to_i2c_client(data->dev);
int ret;
if (nbytes > ABP2_MEASUREMENT_RD_SIZE)
return -EOVERFLOW;
ret = i2c_master_recv(client, data->rx_buf, nbytes);
if (ret < 0)
return ret;
if (ret != nbytes)
return -EIO;
return 0;
}
static int abp2_i2c_write(struct abp2_data *data, u8 cmd, u8 nbytes)
{
struct i2c_client *client = to_i2c_client(data->dev);
int ret;
if (nbytes > ABP2_MEASUREMENT_RD_SIZE)
return -EOVERFLOW;
data->tx_buf[0] = cmd;
ret = i2c_master_send(client, data->tx_buf, nbytes);
if (ret < 0)
return ret;
if (ret != nbytes)
return -EIO;
return 0;
}
static const struct abp2_ops abp2_i2c_ops = {
.read = abp2_i2c_read,
.write = abp2_i2c_write,
};
static int abp2_i2c_probe(struct i2c_client *client)
{
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -EOPNOTSUPP;
return abp2_common_probe(&client->dev, &abp2_i2c_ops, client->irq);
}
static const struct of_device_id abp2_i2c_match[] = {
{ .compatible = "honeywell,abp2030pa" },
{ }
};
MODULE_DEVICE_TABLE(of, abp2_i2c_match);
static const struct i2c_device_id abp2_i2c_id[] = {
{ "abp2030pa" },
{ }
};
MODULE_DEVICE_TABLE(i2c, abp2_i2c_id);
static struct i2c_driver abp2_i2c_driver = {
.driver = {
.name = "abp2030pa",
.of_match_table = abp2_i2c_match,
},
.probe = abp2_i2c_probe,
.id_table = abp2_i2c_id,
};
module_i2c_driver(abp2_i2c_driver);
MODULE_AUTHOR("Petre Rodan <petre.rodan@subdimension.ro>");
MODULE_DESCRIPTION("Honeywell ABP2 pressure sensor i2c driver");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("IIO_HONEYWELL_ABP2030PA");
Annotation
- Immediate include surface: `linux/device.h`, `linux/errno.h`, `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/types.h`, `abp2030pa.h`.
- Detected declarations: `function Copyright`, `function abp2_i2c_write`, `function abp2_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.