From: clicedvly768 <harepro29@gmail.com>
To: ojeda@kernel.org, dmitry.torokhov@gmail.com
Cc: rust-for-linux@vger.kernel.org, linux-input@vger.kernel.org,
clicedvly768 <harepro29@gmail.com>
Subject: [PATCH 0/3] rust: input: add input/serio abstractions and port Gravis Stinger driver
Date: Sat, 7 Nov 2026 00:17:11 +0500 [thread overview]
Message-ID: <20261106191714.334055-1-harepro29@gmail.com> (raw)
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
next reply other threads:[~2026-11-06 19:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 19:17 clicedvly768 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106191714.334055-1-harepro29@gmail.com \
--to=harepro29@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.