drivers/input/joystick/joydump.c
Source file repositories/reference/linux-study-clean/drivers/input/joystick/joydump.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/joystick/joydump.c- Extension
.c- Size
- 3287 bytes
- Lines
- 143
- Domain
- Driver Families
- Bucket
- drivers/input
- 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/module.hlinux/gameport.hlinux/kernel.hlinux/delay.hlinux/slab.h
Detected Declarations
struct joydumpfunction joydump_connectfunction joydump_disconnect
Annotated Snippet
struct joydump {
unsigned int time;
unsigned char data;
};
static int joydump_connect(struct gameport *gameport, struct gameport_driver *drv)
{
struct joydump *buf; /* all entries */
struct joydump *dump, *prev; /* one entry each */
int axes[4], buttons;
int i, j, t, timeout;
unsigned long flags;
unsigned char u;
printk(KERN_INFO "joydump: ,------------------ START ----------------.\n");
printk(KERN_INFO "joydump: | Dumping: %30s |\n", gameport->phys);
printk(KERN_INFO "joydump: | Speed: %28d kHz |\n", gameport->speed);
if (gameport_open(gameport, drv, GAMEPORT_MODE_RAW)) {
printk(KERN_INFO "joydump: | Raw mode not available - trying cooked. |\n");
if (gameport_open(gameport, drv, GAMEPORT_MODE_COOKED)) {
printk(KERN_INFO "joydump: | Cooked not available either. Failing. |\n");
printk(KERN_INFO "joydump: `------------------- END -----------------'\n");
return -ENODEV;
}
gameport_cooked_read(gameport, axes, &buttons);
for (i = 0; i < 4; i++)
printk(KERN_INFO "joydump: | Axis %d: %4d. |\n", i, axes[i]);
printk(KERN_INFO "joydump: | Buttons %02x. |\n", buttons);
printk(KERN_INFO "joydump: `------------------- END -----------------'\n");
}
timeout = gameport_time(gameport, 10000); /* 10 ms */
buf = kmalloc_objs(struct joydump, BUF_SIZE);
if (!buf) {
printk(KERN_INFO "joydump: no memory for testing\n");
goto jd_end;
}
dump = buf;
t = 0;
i = 1;
local_irq_save(flags);
u = gameport_read(gameport);
dump->data = u;
dump->time = t;
dump++;
gameport_trigger(gameport);
while (i < BUF_SIZE && t < timeout) {
dump->data = gameport_read(gameport);
if (dump->data ^ u) {
u = dump->data;
dump->time = t;
i++;
dump++;
}
t++;
}
local_irq_restore(flags);
/*
* Dump data.
*/
t = i;
dump = buf;
prev = dump;
printk(KERN_INFO "joydump: >------------------ DATA -----------------<\n");
printk(KERN_INFO "joydump: | index: %3d delta: %3d us data: ", 0, 0);
for (j = 7; j >= 0; j--)
printk("%d", (dump->data >> j) & 1);
printk(" |\n");
dump++;
for (i = 1; i < t; i++, dump++, prev++) {
printk(KERN_INFO "joydump: | index: %3d delta: %3d us data: ",
Annotation
- Immediate include surface: `linux/module.h`, `linux/gameport.h`, `linux/kernel.h`, `linux/delay.h`, `linux/slab.h`.
- Detected declarations: `struct joydump`, `function joydump_connect`, `function joydump_disconnect`.
- Atlas domain: Driver Families / drivers/input.
- 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.