sound/usb/6fire/firmware.c
Source file repositories/reference/linux-study-clean/sound/usb/6fire/firmware.c
File Facts
- System
- Linux kernel
- Corpus path
sound/usb/6fire/firmware.c- Extension
.c- Size
- 10057 bytes
- Lines
- 406
- Domain
- Driver Families
- Bucket
- sound/usb
- 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/firmware.hlinux/module.hlinux/bitrev.hlinux/hex.hlinux/kernel.hfirmware.hchip.h
Detected Declarations
struct ihex_recordfunction usb6fire_fw_ihex_hexfunction usb6fire_fw_ihex_next_recordfunction usb6fire_fw_ihex_initfunction usb6fire_fw_ezusb_writefunction usb6fire_fw_ezusb_readfunction usb6fire_fw_fpga_writefunction usb6fire_fw_ezusb_uploadfunction usb6fire_fw_fpga_uploadfunction usb6fire_fw_checkfunction usb6fire_fw_init
Annotated Snippet
struct ihex_record {
u16 address;
u8 len;
u8 data[256];
char error; /* true if an error occurred parsing this record */
u8 max_len; /* maximum record length in whole ihex */
/* private */
const char *txt_data;
unsigned int txt_length;
unsigned int txt_offset; /* current position in txt_data */
};
static u8 usb6fire_fw_ihex_hex(const u8 *data, u8 *crc)
{
u8 val = 0;
int hval;
hval = hex_to_bin(data[0]);
if (hval >= 0)
val |= (hval << 4);
hval = hex_to_bin(data[1]);
if (hval >= 0)
val |= hval;
*crc += val;
return val;
}
/*
* returns true if record is available, false otherwise.
* iff an error occurred, false will be returned and record->error will be true.
*/
static bool usb6fire_fw_ihex_next_record(struct ihex_record *record)
{
u8 crc = 0;
u8 type;
int i;
record->error = false;
/* find begin of record (marked by a colon) */
while (record->txt_offset < record->txt_length
&& record->txt_data[record->txt_offset] != ':')
record->txt_offset++;
if (record->txt_offset == record->txt_length)
return false;
/* number of characters needed for len, addr and type entries */
record->txt_offset++;
if (record->txt_offset + 8 > record->txt_length) {
record->error = true;
return false;
}
record->len = usb6fire_fw_ihex_hex(record->txt_data +
record->txt_offset, &crc);
record->txt_offset += 2;
record->address = usb6fire_fw_ihex_hex(record->txt_data +
record->txt_offset, &crc) << 8;
record->txt_offset += 2;
record->address |= usb6fire_fw_ihex_hex(record->txt_data +
record->txt_offset, &crc);
record->txt_offset += 2;
type = usb6fire_fw_ihex_hex(record->txt_data +
record->txt_offset, &crc);
record->txt_offset += 2;
/* number of characters needed for data and crc entries */
if (record->txt_offset + 2 * (record->len + 1) > record->txt_length) {
record->error = true;
return false;
}
for (i = 0; i < record->len; i++) {
record->data[i] = usb6fire_fw_ihex_hex(record->txt_data
+ record->txt_offset, &crc);
record->txt_offset += 2;
}
usb6fire_fw_ihex_hex(record->txt_data + record->txt_offset, &crc);
if (crc) {
record->error = true;
return false;
}
if (type == 1 || !record->len) /* eof */
return false;
else if (type == 0)
return true;
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/bitrev.h`, `linux/hex.h`, `linux/kernel.h`, `firmware.h`, `chip.h`.
- Detected declarations: `struct ihex_record`, `function usb6fire_fw_ihex_hex`, `function usb6fire_fw_ihex_next_record`, `function usb6fire_fw_ihex_init`, `function usb6fire_fw_ezusb_write`, `function usb6fire_fw_ezusb_read`, `function usb6fire_fw_fpga_write`, `function usb6fire_fw_ezusb_upload`, `function usb6fire_fw_fpga_upload`, `function usb6fire_fw_check`.
- Atlas domain: Driver Families / sound/usb.
- 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.