|
|
Log in / Subscribe / Register

Add Rust abstractions for nvmem-provider

From:  Link Mauve <linkmauve-AT-linkmauve.fr>
To:  rust-for-linux-AT-vger.kernel.org
Subject:  [RFC PATCH 0/3] Add Rust abstractions for nvmem-provider
Date:  Wed, 28 Jan 2026 19:29:19 +0100
Message-ID:  <20260128182925.13225-1-linkmauve@linkmauve.fr>
Cc:  Link Mauve <linkmauve-AT-linkmauve.fr>, Srinivas Kandagatla <srini-AT-kernel.org>, Miguel Ojeda <ojeda-AT-kernel.org>, Boqun Feng <boqun.feng-AT-gmail.com>, Gary Guo <gary-AT-garyguo.net>, Björn Roy Baron <bjorn3_gh-AT-protonmail.com>, Benno Lossin <lossin-AT-kernel.org>, Andreas Hindborg <a.hindborg-AT-kernel.org>, Alice Ryhl <aliceryhl-AT-google.com>, Trevor Gross <tmgross-AT-umich.edu>, Danilo Krummrich <dakr-AT-kernel.org>, Daniel Almeida <daniel.almeida-AT-collabora.com>, Greg Kroah-Hartman <gregkh-AT-linuxfoundation.org>, Lyude Paul <lyude-AT-redhat.com>, Asahi Lina <lina+kernel-AT-asahilina.net>, Viresh Kumar <viresh.kumar-AT-linaro.org>, Lorenzo Stoakes <lorenzo.stoakes-AT-oracle.com>, Tamir Duberstein <tamird-AT-kernel.org>, linux-kernel-AT-vger.kernel.org
Archive-link:  Article

Hi, this is my first foray in Rust in the kernel!  I’m fairly used to
both Rust and the kernel, but not yet to both at the same time.

I wanted to try something simple before jumping to more advanced stuff
like DRM or V4L2 drivers, so I set on rewriting one of my old Wii
drivers in Rust.  So far I have only tested that the nvmem abstraction
and the driver compile, but haven’t tested it on an actual Wii, hence
the RFC.

I made sure there was no unsafe anywhere in the driver, and tried to
keep it to as few places as possible in the nvmem abstraction.  I still
have issues with the mutability of the NvmemProvider::Priv type, so for
now I’ve made it a simple reference but I believe this won’t work in the
long run (or even in the short run).  I’ll take any idea for how to fix
that.

So, comments welcome! :)

Link Mauve (3):
  nvmem: Document enum nvmem_type and its variants
  rust: nvmem: Add an abstraction for nvmem providers
  nvmem: Replace the Wii and Wii U OTP driver with a Rust one

 drivers/nvmem/Makefile          |   2 +-
 drivers/nvmem/nintendo-otp.c    | 122 -------------------------
 drivers/nvmem/nintendo_otp.rs   | 137 ++++++++++++++++++++++++++++
 include/linux/nvmem-provider.h  |   8 ++
 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/lib.rs              |   2 +
 rust/kernel/nvmem.rs            | 155 ++++++++++++++++++++++++++++++++
 7 files changed, 304 insertions(+), 123 deletions(-)
 delete mode 100644 drivers/nvmem/nintendo-otp.c
 create mode 100644 drivers/nvmem/nintendo_otp.rs
 create mode 100644 rust/kernel/nvmem.rs

-- 
2.52.0




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds