drivers/nvmem/layouts/onie-tlv.c
Source file repositories/reference/linux-study-clean/drivers/nvmem/layouts/onie-tlv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvmem/layouts/onie-tlv.c- Extension
.c- Size
- 5869 bytes
- Lines
- 262
- Domain
- Driver Families
- Bucket
- drivers/nvmem
- 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.
- 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/crc32.hlinux/etherdevice.hlinux/nvmem-consumer.hlinux/nvmem-provider.hlinux/of.h
Detected Declarations
struct onie_tlv_hdrstruct onie_tlvfunction onie_tlv_mac_read_cbfunction onie_tlv_read_cbfunction onie_tlv_add_cellsfunction onie_tlv_hdr_is_validfunction onie_tlv_crc_is_validfunction onie_tlv_parse_tablefunction onie_tlv_probefunction onie_tlv_remove
Annotated Snippet
struct onie_tlv_hdr {
u8 id[8];
u8 version;
__be16 data_len;
} __packed;
struct onie_tlv {
u8 type;
u8 len;
} __packed;
static const char *onie_tlv_cell_name(u8 type)
{
switch (type) {
case 0x21:
return "product-name";
case 0x22:
return "part-number";
case 0x23:
return "serial-number";
case 0x24:
return "mac-address";
case 0x25:
return "manufacture-date";
case 0x26:
return "device-version";
case 0x27:
return "label-revision";
case 0x28:
return "platform-name";
case 0x29:
return "onie-version";
case 0x2A:
return "num-macs";
case 0x2B:
return "manufacturer";
case 0x2C:
return "country-code";
case 0x2D:
return "vendor";
case 0x2E:
return "diag-version";
case 0x2F:
return "service-tag";
case 0xFD:
return "vendor-extension";
case 0xFE:
return "crc32";
default:
break;
}
return NULL;
}
static int onie_tlv_mac_read_cb(void *priv, const char *id, int index,
unsigned int offset, void *buf,
size_t bytes)
{
eth_addr_add(buf, index);
return 0;
}
static nvmem_cell_post_process_t onie_tlv_read_cb(u8 type, u8 *buf)
{
switch (type) {
case 0x24:
return &onie_tlv_mac_read_cb;
default:
break;
}
return NULL;
}
static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem,
size_t data_len, u8 *data)
{
struct nvmem_cell_info cell = {};
struct device_node *layout;
struct onie_tlv tlv;
unsigned int hdr_len = sizeof(struct onie_tlv_hdr);
unsigned int offset = 0;
int ret;
layout = of_nvmem_layout_get_container(nvmem);
if (!layout)
return -ENOENT;
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/etherdevice.h`, `linux/nvmem-consumer.h`, `linux/nvmem-provider.h`, `linux/of.h`.
- Detected declarations: `struct onie_tlv_hdr`, `struct onie_tlv`, `function onie_tlv_mac_read_cb`, `function onie_tlv_read_cb`, `function onie_tlv_add_cells`, `function onie_tlv_hdr_is_valid`, `function onie_tlv_crc_is_valid`, `function onie_tlv_parse_table`, `function onie_tlv_probe`, `function onie_tlv_remove`.
- Atlas domain: Driver Families / drivers/nvmem.
- 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.