STRUCT PS2DEV(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct ps2dev(9) ✨

okay bestie, welcome to the struct ps2dev(9) glow-up πŸ’… β€” this is the page from the Kernel API Manual and it's literally all about one little struct that represents a device speaking the PS/2 protocol. yes, that PS/2. keyboards, mice, the whole legacy icon lineup 🐭⌨️. she's vintage, she's still in your kernel, and she ate.


πŸŽ€ NAME πŸŽ€

struct ps2dev β€” represents a device using PS/2 protocol. that's it, that's the vibe. a whole struct whose entire main character energy is "i am a PS/2 device" 🫢


✨ SYNOPSIS ✨

struct ps2dev {
    struct serio *serio;
    struct mutex cmd_mutex;
    wait_queue_head_t wait;
    unsigned long flags;
    u8 cmdbuf[8];
    u8 cmdcnt;
    u8 nak;
    ps2_pre_receive_handler_t pre_receive_handler;
    ps2_receive_handler_t receive_handler;
 };

look at her. nine fields. flawless. no notes πŸ”₯


🌸 Members 🌸

okay so here's the field-by-field breakdown, iykyk:

  • serio β€” a serio port used by the PS/2 device. this is her home address, her little landing pad 🏠
  • cmd_mutex β€” a mutex ensuring that only one command is executing at a time. one at a time, bestie!! no cutting the line, no chaos, we take turns βœ‹
  • wait β€” a waitqueue used to signal completion from the serio interrupt handler. this is how the interrupt handler goes "hey girl, it's done πŸ’Œ" from the depths of interrupt context.
  • flags β€” various internal flags indicating stages of PS/2 command execution. the vibes tracker πŸ“Š β€” internal, mysterious, doing her thing.
  • cmdbuf β€” buffer holding command response. eight bytes of u8 pure potential πŸ“
  • cmdcnt β€” outstanding number of bytes of the command response. like a countdown but make it protocol πŸ’€ how many bytes are still out there? she knows.
  • nak β€” a byte transmitted by the device when it refuses command. that's the NAK, the device's "no <3" β€” it literally refuses and sends this byte back πŸ™ˆ
  • pre_receive_handler β€” checks communication errors and returns disposition (enum ps2_disposition) of the received data byte. the bouncer at the door πŸšͺ she checks for comms errors first and then says what she thinks of the byte (that's the enum ps2_disposition verdict, no cap).
  • receive_handler β€” main handler of particular PS/2 protocol, such as keyboard or mouse protocol. the main character of the whole operation πŸ‘‘ β€” the protocol-specific handler that actually deals with the data.

🌈 SEE ALSO 🌈

  • Kernel file ./include/linux/libps2.h
  • enum ps2_disposition(9)

fr fr: if you're poking at a PS/2 device in the kernel, this struct is your bestie β€” the port, the mutex, the buffer, the handlers, all of it. respect her πŸ’œ

and that's a wrap, bestie!! this page lives in ./include/linux, dated October 2026, and its whole title is struct ps2dev(9) β€” go off and read the source, slay πŸ§šβœ¨πŸŽ€

πŸ“¦ where this page comes from