drivers/input/serio/rpckbd.c
Source file repositories/reference/linux-study-clean/drivers/input/serio/rpckbd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/serio/rpckbd.c- Extension
.c- Size
- 3313 bytes
- Lines
- 153
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/interrupt.hlinux/serio.hlinux/err.hlinux/platform_device.hlinux/io.hlinux/slab.hmach/hardware.hasm/hardware/iomd.h
Detected Declarations
struct rpckbd_datafunction rpckbd_writefunction rpckbd_rxfunction rpckbd_txfunction rpckbd_openfunction rpckbd_closefunction rpckbd_probefunction rpckbd_remove
Annotated Snippet
struct rpckbd_data {
int tx_irq;
int rx_irq;
};
static int rpckbd_write(struct serio *port, unsigned char val)
{
while (!(iomd_readb(IOMD_KCTRL) & (1 << 7)))
cpu_relax();
iomd_writeb(val, IOMD_KARTTX);
return 0;
}
static irqreturn_t rpckbd_rx(int irq, void *dev_id)
{
struct serio *port = dev_id;
unsigned int byte;
int handled = IRQ_NONE;
while (iomd_readb(IOMD_KCTRL) & (1 << 5)) {
byte = iomd_readb(IOMD_KARTRX);
serio_interrupt(port, byte, 0);
handled = IRQ_HANDLED;
}
return handled;
}
static irqreturn_t rpckbd_tx(int irq, void *dev_id)
{
return IRQ_HANDLED;
}
static int rpckbd_open(struct serio *port)
{
struct rpckbd_data *rpckbd = port->port_data;
/* Reset the keyboard state machine. */
iomd_writeb(0, IOMD_KCTRL);
iomd_writeb(8, IOMD_KCTRL);
iomd_readb(IOMD_KARTRX);
if (request_irq(rpckbd->rx_irq, rpckbd_rx, 0, "rpckbd", port) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard receive IRQ\n");
return -EBUSY;
}
if (request_irq(rpckbd->tx_irq, rpckbd_tx, 0, "rpckbd", port) != 0) {
printk(KERN_ERR "rpckbd.c: Could not allocate keyboard transmit IRQ\n");
free_irq(rpckbd->rx_irq, port);
return -EBUSY;
}
return 0;
}
static void rpckbd_close(struct serio *port)
{
struct rpckbd_data *rpckbd = port->port_data;
free_irq(rpckbd->rx_irq, port);
free_irq(rpckbd->tx_irq, port);
}
/*
* Allocate and initialize serio structure for subsequent registration
* with serio core.
*/
static int rpckbd_probe(struct platform_device *dev)
{
struct rpckbd_data *rpckbd;
struct serio *serio;
int tx_irq, rx_irq;
rx_irq = platform_get_irq(dev, 0);
if (rx_irq < 0)
return rx_irq;
tx_irq = platform_get_irq(dev, 1);
if (tx_irq < 0)
return tx_irq;
serio = kzalloc_obj(*serio);
rpckbd = kzalloc_obj(*rpckbd);
if (!serio || !rpckbd) {
kfree(rpckbd);
kfree(serio);
return -ENOMEM;
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/serio.h`, `linux/err.h`, `linux/platform_device.h`, `linux/io.h`, `linux/slab.h`, `mach/hardware.h`.
- Detected declarations: `struct rpckbd_data`, `function rpckbd_write`, `function rpckbd_rx`, `function rpckbd_tx`, `function rpckbd_open`, `function rpckbd_close`, `function rpckbd_probe`, `function rpckbd_remove`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.