drivers/media/usb/stk1160/stk1160-i2c.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/stk1160/stk1160-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/stk1160/stk1160-i2c.c- Extension
.c- Size
- 5859 bytes
- Lines
- 285
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/usb.hlinux/i2c.hstk1160.hstk1160-reg.h
Detected Declarations
function stk1160_i2c_busy_waitfunction stk1160_i2c_write_regfunction stk1160_i2c_read_regfunction stk1160_i2c_check_for_devicefunction stk1160_i2c_xferfunction functionalityfunction stk1160_i2c_registerfunction stk1160_i2c_unregister
Annotated Snippet
if (!msgs[i].len) {
/* no len: check only for device presence */
rc = stk1160_i2c_check_for_device(dev, addr);
if (rc < 0) {
dprintk_i2c(" no device\n");
return rc;
}
} else if (msgs[i].flags & I2C_M_RD) {
/* read request without preceding register selection */
dprintk_i2c(" subaddr not selected");
rc = -EOPNOTSUPP;
goto err;
} else if (i + 1 < num && msgs[i].len <= 2 &&
(msgs[i + 1].flags & I2C_M_RD) &&
msgs[i].addr == msgs[i + 1].addr) {
if (msgs[i].len != 1 || msgs[i + 1].len != 1) {
dprintk_i2c(" len not supported");
rc = -EOPNOTSUPP;
goto err;
}
dprintk_i2c(" subaddr=%x", msgs[i].buf[0]);
rc = stk1160_i2c_read_reg(dev, addr, msgs[i].buf[0],
msgs[i + 1].buf);
dprintk_i2c(" read=%x", *msgs[i + 1].buf);
/* consumed two msgs, so we skip one of them */
i++;
} else {
if (msgs[i].len != 2) {
dprintk_i2c(" len not supported");
rc = -EOPNOTSUPP;
goto err;
}
dprintk_i2c(" subaddr=%x write=%x",
msgs[i].buf[0], msgs[i].buf[1]);
rc = stk1160_i2c_write_reg(dev, addr, msgs[i].buf[0],
msgs[i].buf[1]);
}
if (rc < 0)
goto err;
dprintk_i2c(" OK\n");
}
return num;
err:
dprintk_i2c(" ERROR: %d\n", rc);
return num;
}
/*
* functionality(), what da heck is this?
*/
static u32 functionality(struct i2c_adapter *adap)
{
return I2C_FUNC_SMBUS_EMUL;
}
static const struct i2c_algorithm algo = {
.master_xfer = stk1160_i2c_xfer,
.functionality = functionality,
};
static const struct i2c_adapter adap_template = {
.owner = THIS_MODULE,
.name = "stk1160",
.algo = &algo,
};
static const struct i2c_client client_template = {
.name = "stk1160 internal",
};
/*
* stk1160_i2c_register()
* register i2c bus
*/
int stk1160_i2c_register(struct stk1160 *dev)
{
int rc;
Annotation
- Immediate include surface: `linux/module.h`, `linux/usb.h`, `linux/i2c.h`, `stk1160.h`, `stk1160-reg.h`.
- Detected declarations: `function stk1160_i2c_busy_wait`, `function stk1160_i2c_write_reg`, `function stk1160_i2c_read_reg`, `function stk1160_i2c_check_for_device`, `function stk1160_i2c_xfer`, `function functionality`, `function stk1160_i2c_register`, `function stk1160_i2c_unregister`.
- Atlas domain: Driver Families / drivers/media.
- 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.