drivers/media/usb/go7007/go7007-i2c.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/go7007/go7007-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/go7007/go7007-i2c.c- Extension
.c- Size
- 5860 bytes
- Lines
- 217
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/delay.hlinux/sched.hlinux/list.hlinux/unistd.hlinux/time.hlinux/device.hlinux/i2c.hlinux/mutex.hlinux/uaccess.hgo7007-priv.h
Detected Declarations
function adlink_mpg24_i2c_lockfunction adlink_mpg24_i2c_unlockfunction go7007_i2c_xferfunction go7007_smbus_xferfunction go7007_i2c_master_xferfunction go7007_functionalityfunction go7007_i2c_init
Annotated Snippet
if (msgs[i].len == 2) {
if (i + 1 == num || msgs[i].addr != msgs[i + 1].addr ||
(msgs[i].flags & I2C_M_RD) ||
!(msgs[i + 1].flags & I2C_M_RD) ||
msgs[i + 1].len != 1)
return -EIO;
if (go7007_i2c_xfer(go, msgs[i].addr, 1,
(msgs[i].buf[0] << 8) | msgs[i].buf[1],
0x01, &msgs[i + 1].buf[0]) < 0)
return -EIO;
++i;
} else if (msgs[i].len == 3) {
if (msgs[i].flags & I2C_M_RD)
return -EIO;
if (go7007_i2c_xfer(go, msgs[i].addr, 0,
(msgs[i].buf[0] << 8) | msgs[i].buf[1],
0x01, &msgs[i].buf[2]) < 0)
return -EIO;
} else
return -EIO;
}
return num;
}
static u32 go7007_functionality(struct i2c_adapter *adapter)
{
return I2C_FUNC_SMBUS_BYTE_DATA;
}
static const struct i2c_algorithm go7007_algo = {
.smbus_xfer = go7007_smbus_xfer,
.master_xfer = go7007_i2c_master_xfer,
.functionality = go7007_functionality,
};
static struct i2c_adapter go7007_adap_templ = {
.owner = THIS_MODULE,
.name = "WIS GO7007SB",
.algo = &go7007_algo,
};
int go7007_i2c_init(struct go7007 *go)
{
memcpy(&go->i2c_adapter, &go7007_adap_templ,
sizeof(go7007_adap_templ));
go->i2c_adapter.dev.parent = go->dev;
i2c_set_adapdata(&go->i2c_adapter, go);
if (i2c_add_adapter(&go->i2c_adapter) < 0) {
dev_err(go->dev,
"go7007-i2c: error: i2c_add_adapter failed\n");
return -1;
}
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/delay.h`, `linux/sched.h`, `linux/list.h`, `linux/unistd.h`, `linux/time.h`, `linux/device.h`, `linux/i2c.h`.
- Detected declarations: `function adlink_mpg24_i2c_lock`, `function adlink_mpg24_i2c_unlock`, `function go7007_i2c_xfer`, `function go7007_smbus_xfer`, `function go7007_i2c_master_xfer`, `function go7007_functionality`, `function go7007_i2c_init`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.