drivers/thunderbolt/property.c
Source file repositories/reference/linux-study-clean/drivers/thunderbolt/property.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/thunderbolt/property.c- Extension
.c- Size
- 19487 bytes
- Lines
- 791
- Domain
- Driver Families
- Bucket
- drivers/thunderbolt
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/err.hlinux/overflow.hlinux/slab.hlinux/string.hlinux/uuid.hlinux/thunderbolt.h
Detected Declarations
struct tb_property_entrystruct tb_property_rootdir_entrystruct tb_property_dir_entryfunction parse_dwdatafunction format_dwdatafunction tb_property_entry_validfunction tb_property_key_validfunction tb_property_allocfunction tb_property_parse_dirfunction tb_property_create_dirfunction tb_property_freefunction tb_property_free_dirfunction list_for_each_entry_safefunction tb_property_dir_lengthfunction list_for_each_entryfunction __tb_property_format_dirfunction list_for_each_entryfunction tb_property_format_dirfunction tb_property_copy_dirfunction list_for_each_entryfunction tb_property_add_immediatefunction tb_property_add_datafunction tb_property_add_textfunction tb_property_add_dirfunction tb_property_removefunction tb_property_findfunction list_for_each_entryfunction tb_property_get_nextexport tb_property_create_direxport tb_property_free_direxport tb_property_add_immediateexport tb_property_add_dataexport tb_property_add_textexport tb_property_add_direxport tb_property_removeexport tb_property_findexport tb_property_get_next
Annotated Snippet
struct tb_property_entry {
u32 key_hi;
u32 key_lo;
u16 length;
u8 reserved;
u8 type;
u32 value;
};
struct tb_property_rootdir_entry {
u32 magic;
u32 length;
struct tb_property_entry entries[];
};
struct tb_property_dir_entry {
u32 uuid[4];
struct tb_property_entry entries[];
};
#define TB_PROPERTY_ROOTDIR_MAGIC 0x55584401
#define TB_PROPERTY_MAX_DEPTH 8
static struct tb_property_dir *__tb_property_parse_dir(const u32 *block,
size_t block_len, unsigned int dir_offset, size_t dir_len,
bool is_root, unsigned int depth);
static inline void parse_dwdata(void *dst, const void *src, size_t dwords)
{
be32_to_cpu_array(dst, src, dwords);
}
static inline void format_dwdata(void *dst, const void *src, size_t dwords)
{
cpu_to_be32_array(dst, src, dwords);
}
static bool tb_property_entry_valid(const struct tb_property_entry *entry,
size_t block_len)
{
u32 end;
switch (entry->type) {
case TB_PROPERTY_TYPE_DIRECTORY:
case TB_PROPERTY_TYPE_DATA:
case TB_PROPERTY_TYPE_TEXT:
if (!entry->length)
return false;
if (entry->length > block_len)
return false;
if (check_add_overflow(entry->value, entry->length, &end) ||
end > block_len)
return false;
break;
case TB_PROPERTY_TYPE_VALUE:
if (entry->length != 1)
return false;
break;
}
return true;
}
static bool tb_property_key_valid(const char *key)
{
return key && strlen(key) <= TB_PROPERTY_KEY_SIZE;
}
static struct tb_property *
tb_property_alloc(const char *key, enum tb_property_type type)
{
struct tb_property *property;
property = kzalloc_obj(*property);
if (!property)
return NULL;
strcpy(property->key, key);
property->type = type;
INIT_LIST_HEAD(&property->list);
return property;
}
static struct tb_property *tb_property_parse(const u32 *block, size_t block_len,
const struct tb_property_entry *entry,
unsigned int depth)
{
char key[TB_PROPERTY_KEY_SIZE + 1];
Annotation
- Immediate include surface: `linux/err.h`, `linux/overflow.h`, `linux/slab.h`, `linux/string.h`, `linux/uuid.h`, `linux/thunderbolt.h`.
- Detected declarations: `struct tb_property_entry`, `struct tb_property_rootdir_entry`, `struct tb_property_dir_entry`, `function parse_dwdata`, `function format_dwdata`, `function tb_property_entry_valid`, `function tb_property_key_valid`, `function tb_property_alloc`, `function tb_property_parse_dir`, `function tb_property_create_dir`.
- Atlas domain: Driver Families / drivers/thunderbolt.
- Implementation status: integration 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.