drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c- Extension
.c- Size
- 3451 bytes
- Lines
- 164
- Domain
- Driver Families
- Bucket
- drivers/comedi
- 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
stdint.hstdbool.hstddef.herrno.hstdlib.h../ni_route_values.c../ni_device_routes.call_cfiles.cstdio.h
Detected Declarations
function family_writefunction is_valid_ni_sigfunction device_writefunction main
Annotated Snippet
if (r == 0) {
continue;
} else if (MARKED_V(r)) {
M = "V";
} else if (MARKED_I(r)) {
M = "I";
} else if (MARKED_U(r)) {
M = "U";
} else {
fprintf(stderr,
"Invalid register marking %s[%u][%u] = %u\n",
rv->family, dest, src, r);
exit(1);
}
fprintf(fp, " %u : \"%s(%u)\",\n",
src, M, UNMARK(r));
}
fprintf(fp, " },\n");
}
fprintf(fp, " },\n\n");
}
bool is_valid_ni_sig(unsigned int sig)
{
return (sig >= NI_NAMES_BASE) && (sig < (NI_NAMES_BASE + NI_NUM_NAMES));
}
/*
* write out
* {
* "family" : "<family-name>",
* "register_values": {
* <destination0>:[src0, src1, ...],
* <destination0>:[src0, src1, ...],
* ...
* }
* }
*/
void device_write(const struct ni_device_routes *dR, FILE *fp)
{
fprintf(fp,
" \"%s\" : {\n"
" # dest -> [src0, src1, ...]\n"
, dR->device);
unsigned int i = 0;
while (dR->routes[i].dest != 0) {
if (!is_valid_ni_sig(dR->routes[i].dest)) {
fprintf(stderr,
"Invalid NI signal value [%u] for destination %s.[%u]\n",
dR->routes[i].dest, dR->device, i);
exit(1);
}
fprintf(fp, " %u : [", dR->routes[i].dest);
unsigned int j = 0;
while (dR->routes[i].src[j] != 0) {
if (!is_valid_ni_sig(dR->routes[i].src[j])) {
fprintf(stderr,
"Invalid NI signal value [%u] for source %s.[%u].[%u]\n",
dR->routes[i].src[j], dR->device, i, j);
exit(1);
}
fprintf(fp, "%u,", dR->routes[i].src[j]);
++j;
}
fprintf(fp, "],\n");
++i;
}
fprintf(fp, " },\n\n");
}
int main(void)
{
FILE *fp = fopen("ni_values.py", "w");
if (fp == NULL) {
fprintf(stderr, "Could not open file!");
return -1;
}
/* write route register values */
fprintf(fp, "ni_route_values = {\n");
Annotation
- Immediate include surface: `stdint.h`, `stdbool.h`, `stddef.h`, `errno.h`, `stdlib.h`, `../ni_route_values.c`, `../ni_device_routes.c`, `all_cfiles.c`.
- Detected declarations: `function family_write`, `function is_valid_ni_sig`, `function device_write`, `function main`.
- Atlas domain: Driver Families / drivers/comedi.
- 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.