drivers/media/i2c/ccs/ccs-data.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ccs/ccs-data.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ccs/ccs-data.c- Extension
.c- Size
- 23985 bytes
- Lines
- 983
- 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/device.hlinux/errno.hlinux/limits.hlinux/mm.hlinux/slab.hlinux/string.hccs-data-defs.h
Detected Declarations
struct bin_containerfunction bin_reservefunction bin_backing_allocfunction ccs_data_parse_length_specifierfunction ccs_data_parse_format_versionfunction ccs_data_parse_block_idfunction ccs_data_parse_versionfunction print_ccs_data_versionfunction ccs_data_block_parse_headerfunction ccs_data_parse_regsfunction ccs_data_parse_reg_rulesfunction assign_ffd_entryfunction ccs_data_parse_ffdfunction ccs_data_parse_pdaf_readoutfunction ccs_data_parse_rulesfunction ccs_data_parse_pdaffunction ccs_data_parse_licensefunction ccs_data_parse_endfunction __ccs_data_parsefunction ccs_data_parse
Annotated Snippet
struct bin_container {
void *base;
void *now;
void *end;
size_t size;
};
static void *bin_alloc(struct bin_container *bin, size_t len)
{
void *ptr;
len = ALIGN(len, 8);
if (bin->end - bin->now < len)
return NULL;
ptr = bin->now;
bin->now += len;
return ptr;
}
static void bin_reserve(struct bin_container *bin, size_t len)
{
bin->size += ALIGN(len, 8);
}
static int bin_backing_alloc(struct bin_container *bin)
{
bin->base = bin->now = kvzalloc(bin->size, GFP_KERNEL);
if (!bin->base)
return -ENOMEM;
bin->end = bin->base + bin->size;
return 0;
}
#define is_contained(var, endp) \
(sizeof(*var) <= (endp) - (void *)(var))
#define has_headroom(ptr, headroom, endp) \
((headroom) <= (endp) - (void *)(ptr))
#define is_contained_with_headroom(var, headroom, endp) \
(sizeof(*var) + (headroom) <= (endp) - (void *)(var))
static int
ccs_data_parse_length_specifier(const struct __ccs_data_length_specifier *__len,
size_t *__hlen, size_t *__plen,
const void *endp)
{
size_t hlen, plen;
if (!is_contained(__len, endp))
return -ENODATA;
switch (__len->length >> CCS_DATA_LENGTH_SPECIFIER_SIZE_SHIFT) {
case CCS_DATA_LENGTH_SPECIFIER_1:
hlen = sizeof(*__len);
plen = __len->length &
((1 << CCS_DATA_LENGTH_SPECIFIER_SIZE_SHIFT) - 1);
break;
case CCS_DATA_LENGTH_SPECIFIER_2: {
struct __ccs_data_length_specifier2 *__len2 = (void *)__len;
if (!is_contained(__len2, endp))
return -ENODATA;
hlen = sizeof(*__len2);
plen = ((size_t)
(__len2->length[0] &
((1 << CCS_DATA_LENGTH_SPECIFIER_SIZE_SHIFT) - 1))
<< 8) + __len2->length[1];
break;
}
case CCS_DATA_LENGTH_SPECIFIER_3: {
struct __ccs_data_length_specifier3 *__len3 = (void *)__len;
if (!is_contained(__len3, endp))
return -ENODATA;
hlen = sizeof(*__len3);
plen = ((size_t)
(__len3->length[0] &
((1 << CCS_DATA_LENGTH_SPECIFIER_SIZE_SHIFT) - 1))
<< 16) + (__len3->length[1] << 8) + __len3->length[2];
break;
}
default:
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/errno.h`, `linux/limits.h`, `linux/mm.h`, `linux/slab.h`, `linux/string.h`, `ccs-data-defs.h`.
- Detected declarations: `struct bin_container`, `function bin_reserve`, `function bin_backing_alloc`, `function ccs_data_parse_length_specifier`, `function ccs_data_parse_format_version`, `function ccs_data_parse_block_id`, `function ccs_data_parse_version`, `function print_ccs_data_version`, `function ccs_data_block_parse_header`, `function ccs_data_parse_regs`.
- 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.