drivers/media/i2c/ccs/ccs-reg-access.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ccs/ccs-reg-access.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ccs/ccs-reg-access.c- Extension
.c- Size
- 5969 bytes
- Lines
- 270
- 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/unaligned.hlinux/delay.hlinux/hex.hlinux/i2c.hccs.hccs-limits.h
Detected Declarations
function Copyrightfunction ireal32_to_u32_mul_1000000function ccs_reg_convfunction __ccs_read_addrfunction __ccs_static_data_read_ro_regfunction ccs_static_data_read_ro_regfunction ccs_read_addr_rawfunction ccs_read_addrfunction ccs_read_addr_8onlyfunction ccs_read_addr_noconvfunction ccs_write_addrfunction ccs_write_data_regs
Annotated Snippet
switch (width) {
case sizeof(u8):
*val = *data;
break;
case sizeof(u16):
*val = get_unaligned_be16(data);
break;
case sizeof(u32):
*val = get_unaligned_be32(data);
break;
default:
WARN_ON(1);
return -EINVAL;
}
return 0;
}
return -ENOENT;
}
static int
ccs_static_data_read_ro_reg(struct ccs_sensor *sensor, u32 reg, u32 *val)
{
if (!__ccs_static_data_read_ro_reg(sensor->sdata.sensor_read_only_regs,
sensor->sdata.num_sensor_read_only_regs,
reg, val))
return 0;
return __ccs_static_data_read_ro_reg(sensor->mdata.module_read_only_regs,
sensor->mdata.num_module_read_only_regs,
reg, val);
}
static int ccs_read_addr_raw(struct ccs_sensor *sensor, u32 reg, u32 *val,
bool force8, bool quirk, bool conv, bool data)
{
int rval;
if (data) {
rval = ccs_static_data_read_ro_reg(sensor, reg, val);
if (!rval)
return 0;
}
if (quirk) {
*val = 0;
rval = ccs_call_quirk(sensor, reg_access, false, ®, val);
if (rval == -ENOIOCTLCMD)
return 0;
if (rval < 0)
return rval;
if (force8)
return __ccs_read_addr(sensor, reg, val, true, conv);
}
return __ccs_read_addr(sensor, reg, val,
ccs_needs_quirk(sensor,
CCS_QUIRK_FLAG_8BIT_READ_ONLY),
conv);
}
int ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val)
{
return ccs_read_addr_raw(sensor, reg, val, false, true, true, true);
}
int ccs_read_addr_8only(struct ccs_sensor *sensor, u32 reg, u32 *val)
{
return ccs_read_addr_raw(sensor, reg, val, true, true, true, true);
}
int ccs_read_addr_noconv(struct ccs_sensor *sensor, u32 reg, u32 *val)
{
return ccs_read_addr_raw(sensor, reg, val, false, true, false, true);
}
/*
* Write to a 8/16-bit register.
* Returns zero if successful, or non-zero otherwise.
*/
int ccs_write_addr(struct ccs_sensor *sensor, u32 reg, u32 val)
{
int rval;
rval = ccs_call_quirk(sensor, reg_access, true, ®, &val);
if (rval == -ENOIOCTLCMD)
return 0;
if (rval < 0)
Annotation
- Immediate include surface: `linux/unaligned.h`, `linux/delay.h`, `linux/hex.h`, `linux/i2c.h`, `ccs.h`, `ccs-limits.h`.
- Detected declarations: `function Copyright`, `function ireal32_to_u32_mul_1000000`, `function ccs_reg_conv`, `function __ccs_read_addr`, `function __ccs_static_data_read_ro_reg`, `function ccs_static_data_read_ro_reg`, `function ccs_read_addr_raw`, `function ccs_read_addr`, `function ccs_read_addr_8only`, `function ccs_read_addr_noconv`.
- 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.