Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 0/3] rust: input: add input/serio abstractions and port Gravis Stinger driver
@ 2026-11-06 19:17 clicedvly768
  2026-11-06 19:17 ` [PATCH 1/3] rust: input: add input device abstractions clicedvly768
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: clicedvly768 @ 2026-11-06 19:17 UTC (permalink / raw)
  To: ojeda, dmitry.torokhov; +Cc: rust-for-linux, linux-input, clicedvly768

This series introduces safe Rust abstractions for the Linux input and
serio (Serial I/O) subsystems and demonstrates their real-world usage
by porting the legacy Gravis Stinger serial gamepad driver from C to
safe Rust.

Motivation and Design:
- In the Rust for Linux (RfL) philosophy, device drivers should not rely
  on raw FFI and unsafe blocks. Instead, the kernel crate provides safe,
  idiomatic Rust abstractions.
- The Gravis Stinger gamepad is an ideal candidate for demonstrating safe
  Rust driver development in the input subsystem: it uses a well-defined
  4-byte serial protocol at 9600 baud, 10 buttons, and 2 analog axes.
- The ported driver (`drivers/input/joystick/stinger.rs`) contains ZERO
  unsafe blocks, using RAII types (`AllocatedDevice`, `RegisteredDevice`,
  `serio::Registration`) for memory safety and device lifetime management.

Testing:
- Built with Clang/LLVM and rustc 1.99.1.
- Passes all strict kernel Rust checks: `make rustfmtcheck`,
  `make rustdoc`,
  and `make CLIPPY=1` with zero warnings.
- Tested end-to-end in a custom QEMU virtual test environment with serial
  port loopback (`serport` line discipline `N_MOUSE` and `SERIO_STINGER`).
- Verified event reporting (`EV_KEY`, `EV_ABS`, `EV_SYN`) via `evtest`
  and an automated Python protocol test suite across all 10 buttons and
  both axes (-64..64).

Structure of the series:
1. Patch 1: Add input device abstractions (`kernel::input`).
2. Patch 2: Add serio bus abstractions (`kernel::serio`).
3. Patch 3: Port `drivers/input/joystick/stinger.c` to `stinger.rs`.

clicedvly768 (3):
  rust: input: add input device abstractions
  rust: serio: add serio bus abstractions
  input: joystick: stinger: port Gravis Stinger driver to safe Rust

 drivers/input/joystick/Kconfig    |   1 +
 drivers/input/joystick/stinger.c  | 191 -------------------------
 drivers/input/joystick/stinger.rs | 174 +++++++++++++++++++++++
 rust/bindings/bindings_helper.h   |   2 +
 rust/helpers/helpers.c            |   2 +
 rust/helpers/input.c              |  18 +++
 rust/helpers/serio.c              |  23 +++
 rust/kernel/input.rs              | 174 +++++++++++++++++++++++
 rust/kernel/lib.rs                |   2 +
 rust/kernel/serio.rs              | 223 ++++++++++++++++++++++++++++++
 10 files changed, 619 insertions(+), 191 deletions(-)
 delete mode 100644 drivers/input/joystick/stinger.c
 create mode 100644 drivers/input/joystick/stinger.rs
 create mode 100644 rust/helpers/input.c
 create mode 100644 rust/helpers/serio.c
 create mode 100644 rust/kernel/input.rs
 create mode 100644 rust/kernel/serio.rs

-- 
2.56.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-06 19:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-06 19:17 [PATCH 0/3] rust: input: add input/serio abstractions and port Gravis Stinger driver clicedvly768
2026-11-06 19:17 ` [PATCH 1/3] rust: input: add input device abstractions clicedvly768
2026-11-06 19:29   ` sashiko-bot
2026-11-06 19:17 ` [PATCH 2/3] rust: serio: add serio bus abstractions clicedvly768
2026-11-06 19:35   ` sashiko-bot
2026-11-06 19:17 ` [PATCH 3/3] input: joystick: stinger: port Gravis Stinger driver to safe Rust clicedvly768
2026-11-06 19:42   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox