drivers/i2c/busses/i2c-usbio.c
Source file repositories/reference/linux-study-clean/drivers/i2c/busses/i2c-usbio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i2c/busses/i2c-usbio.c- Extension
.c- Size
- 7997 bytes
- Lines
- 323
- Domain
- Driver Families
- Bucket
- drivers/i2c
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/auxiliary_bus.hlinux/dev_printk.hlinux/device.hlinux/i2c.hlinux/types.hlinux/usb/usbio.h
Detected Declarations
struct usbio_i2cfunction usbio_i2c_uninitfunction usbio_i2c_initfunction usbio_i2c_readfunction usbio_i2c_writefunction usbio_i2c_xferfunction usbio_i2c_funcfunction usbio_i2c_probefunction usbio_i2c_remove
Annotated Snippet
struct usbio_i2c {
struct i2c_adapter adap;
struct auxiliary_device *adev;
struct usbio_i2c_rw *rwbuf;
unsigned long quirks;
u32 speed;
u16 txbuf_len;
u16 rxbuf_len;
};
static const struct acpi_device_id usbio_i2c_acpi_hids[] = {
{ "INTC1008" }, /* MTL */
{ "INTC10B3" }, /* ARL */
{ "INTC10B6" }, /* LNL */
{ "INTC10D2" }, /* MTL-CVF */
{ "INTC10E3" }, /* PTL */
{ "INTC1118" }, /* NVL */
{ }
};
static const u32 usbio_i2c_speeds[] = {
I2C_MAX_STANDARD_MODE_FREQ,
I2C_MAX_FAST_MODE_FREQ,
I2C_MAX_FAST_MODE_PLUS_FREQ,
I2C_MAX_HIGH_SPEED_MODE_FREQ
};
static void usbio_i2c_uninit(struct i2c_adapter *adap, struct i2c_msg *msg)
{
struct usbio_i2c *i2c = i2c_get_adapdata(adap);
struct usbio_i2c_uninit ubuf;
ubuf.busid = i2c->adev->id;
ubuf.config = cpu_to_le16(msg->addr);
usbio_bulk_msg(i2c->adev, USBIO_PKTTYPE_I2C, USBIO_I2CCMD_UNINIT, true,
&ubuf, sizeof(ubuf), NULL, 0);
}
static int usbio_i2c_init(struct i2c_adapter *adap, struct i2c_msg *msg)
{
struct usbio_i2c *i2c = i2c_get_adapdata(adap);
struct usbio_i2c_init ibuf;
void *reply_buf;
u16 reply_len;
int ret;
ibuf.busid = i2c->adev->id;
ibuf.config = cpu_to_le16(msg->addr);
ibuf.speed = cpu_to_le32(i2c->speed);
if (i2c->quirks & USBIO_QUIRK_I2C_NO_INIT_ACK) {
reply_buf = NULL;
reply_len = 0;
} else {
reply_buf = &ibuf;
reply_len = sizeof(ibuf);
}
ret = usbio_bulk_msg(i2c->adev, USBIO_PKTTYPE_I2C, USBIO_I2CCMD_INIT, true,
&ibuf, sizeof(ibuf), reply_buf, reply_len);
if (ret != sizeof(ibuf))
return (ret < 0) ? ret : -EIO;
return 0;
}
static int usbio_i2c_read(struct i2c_adapter *adap, struct i2c_msg *msg)
{
struct usbio_i2c *i2c = i2c_get_adapdata(adap);
u16 rxchunk = i2c->rxbuf_len - I2C_RW_OVERHEAD;
struct usbio_i2c_rw *rbuf = i2c->rwbuf;
int ret;
rbuf->busid = i2c->adev->id;
rbuf->config = cpu_to_le16(msg->addr);
rbuf->size = cpu_to_le16(msg->len);
if (msg->len > rxchunk) {
/* Need to split the input buffer */
u16 len = 0;
do {
if (msg->len - len < rxchunk)
rxchunk = msg->len - len;
ret = usbio_bulk_msg(i2c->adev, USBIO_PKTTYPE_I2C,
USBIO_I2CCMD_READ, true,
rbuf, len == 0 ? sizeof(*rbuf) : 0,
rbuf, sizeof(*rbuf) + rxchunk);
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/dev_printk.h`, `linux/device.h`, `linux/i2c.h`, `linux/types.h`, `linux/usb/usbio.h`.
- Detected declarations: `struct usbio_i2c`, `function usbio_i2c_uninit`, `function usbio_i2c_init`, `function usbio_i2c_read`, `function usbio_i2c_write`, `function usbio_i2c_xfer`, `function usbio_i2c_func`, `function usbio_i2c_probe`, `function usbio_i2c_remove`.
- Atlas domain: Driver Families / drivers/i2c.
- 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.