In the previous chapter, Chapter 3, Working with Hardware I/O Memory, in the A PIO example – the i8042 section, we learned how the i8042 device driver uses some very simple helper routines to perform I/O (read/write) on the I/O ports of the i8042 chip (this is often the keyboard/mouse controller on x86 systems). The following code snippet shows some of the code for its hardware interrupt handler routine; you can clearly see it reading both the status and data registers:
// drivers/input/serio/i8042.c
/*
* i8042_interrupt() is the most important function in this driver -
* it handles the interrupts from the i8042, and sends incoming bytes
* to the upper layers.
*/
static irqreturn_t i8042_interrupt(int irq, void *dev_id)
{
unsigned char str, data;
[...]
str = i8042_read_status();
[...]
data = i8042_read_data();
[...]
if (likely(serio && !filtered))
serio_interrupt...