drivers/input/serio/parkbd.c
Source file repositories/reference/linux-study-clean/drivers/input/serio/parkbd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/serio/parkbd.c- Extension
.c- Size
- 5352 bytes
- Lines
- 223
- 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/parport.hlinux/slab.hlinux/init.hlinux/serio.h
Detected Declarations
function parkbd_readlinesfunction parkbd_writelinesfunction parkbd_writefunction parkbd_interruptfunction parkbd_getportfunction parkbd_attachfunction parkbd_detach
Annotated Snippet
if (parkbd_counter && ((parkbd_counter == 11) || time_after(jiffies, parkbd_last + HZ/100))) {
parkbd_counter = 0;
parkbd_buffer = 0;
parkbd_writing = 0;
parkbd_writelines(3);
return;
}
parkbd_writelines(((parkbd_buffer >> parkbd_counter++) & 1) | 2);
if (parkbd_counter == 11) {
parkbd_counter = 0;
parkbd_buffer = 0;
parkbd_writing = 0;
parkbd_writelines(3);
}
} else {
if ((parkbd_counter == parkbd_mode + 10) || time_after(jiffies, parkbd_last + HZ/100)) {
parkbd_counter = 0;
parkbd_buffer = 0;
}
parkbd_buffer |= (parkbd_readlines() >> 1) << parkbd_counter++;
if (parkbd_counter == parkbd_mode + 10)
serio_interrupt(parkbd_port, (parkbd_buffer >> (2 - parkbd_mode)) & 0xff, 0);
}
parkbd_last = jiffies;
}
static int parkbd_getport(struct parport *pp)
{
struct pardev_cb parkbd_parport_cb;
memset(&parkbd_parport_cb, 0, sizeof(parkbd_parport_cb));
parkbd_parport_cb.irq_func = parkbd_interrupt;
parkbd_parport_cb.flags = PARPORT_FLAG_EXCL;
parkbd_dev = parport_register_dev_model(pp, "parkbd",
&parkbd_parport_cb, 0);
if (!parkbd_dev)
return -ENODEV;
if (parport_claim(parkbd_dev)) {
parport_unregister_device(parkbd_dev);
return -EBUSY;
}
parkbd_start = jiffies;
return 0;
}
static struct serio *parkbd_allocate_serio(void)
{
struct serio *serio;
serio = kzalloc_obj(*serio);
if (serio) {
serio->id.type = parkbd_mode;
serio->write = parkbd_write;
strscpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name));
snprintf(serio->phys, sizeof(serio->phys), "%s/serio0", parkbd_dev->port->name);
}
return serio;
}
static void parkbd_attach(struct parport *pp)
{
if (pp->number != parkbd_pp_no) {
pr_debug("Not using parport%d.\n", pp->number);
return;
}
if (parkbd_getport(pp))
return;
parkbd_port = parkbd_allocate_serio();
if (!parkbd_port) {
parport_release(parkbd_dev);
parport_unregister_device(parkbd_dev);
return;
}
parkbd_writelines(3);
Annotation
- Immediate include surface: `linux/module.h`, `linux/parport.h`, `linux/slab.h`, `linux/init.h`, `linux/serio.h`.
- Detected declarations: `function parkbd_readlines`, `function parkbd_writelines`, `function parkbd_write`, `function parkbd_interrupt`, `function parkbd_getport`, `function parkbd_attach`, `function parkbd_detach`.
- 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.