From: Shuai Liu <847807867@qq.com>
To: linux-spi@vger.kernel.org
Cc: rust-for-linux@vger.kernel.org, Mark Brown <broonie@kernel.org>,
ojeda@kernel.org, dakr@kernel.org, linux-kernel@vger.kernel.org,
847807867@qq.com
Subject: [PATCH v7 0/3] rust: spi: add SPI driver abstractions
Date: Fri, 13 Nov 2026 10:05:28 +0800 [thread overview]
Message-ID: <tencent_097BA6F40A0B8FBC4C130C6EBF58F8048006@qq.com> (raw)
In-Reply-To: <179451185979.339049.12323339081307899766.b4-review@b4>
Rework the device I/O to map onto the lower-level C APIs, as suggested
by Mark Brown [1]: instead of leveraging the C convenience wrappers
(spi_write(), spi_read() and spi_write_then_read()), all device I/O is
now built on a single `SpiDevice::transfer()` primitive that maps onto
spi_sync(). The convenience methods `write()`, `read()` and
`write_then_read()` remain as thin wrappers on top of `transfer()`.
`spi_sync()` requires DMA-safe transfer buffers and Rust slices may be
located anywhere (e.g. on the stack), so the Rust layer owns the
bounce-buffering: every transfer buffer is copied into a kmalloc'd
buffer before submission, and received data is copied back afterwards.
This removes the dependency on the C convenience wrappers (and their
helpers) entirely, and adds full-duplex support via
`Transfer::full_duplex()`, which the wrappers do not offer.
Changes in v7:
- Rework device I/O around a `transfer()` primitive that maps onto
spi_sync(), per Mark Brown's review (patch 2).
- Drop the spi_write()/spi_read() helpers; add
spi_message_init()/spi_message_add_tail() helpers instead (patch 1).
[1] https://lore.kernel.org/rust-for-linux/179451185979.339049.12323339081307899766.b4-review@b4/
Shuai Liu (3):
rust: helpers: add SPI helpers
rust: spi: add SPI driver abstractions
samples: rust: add SPI driver sample
rust/bindings/bindings_helper.h | 1 +
rust/helpers/helpers.c | 1 +
rust/helpers/spi.c | 26 ++
rust/kernel/Kconfig.test | 11 +
rust/kernel/lib.rs | 2 +
rust/kernel/spi.rs | 673 ++++++++++++++++++++++++++++++++
samples/rust/Kconfig | 11 +
samples/rust/Makefile | 1 +
samples/rust/rust_driver_spi.rs | 66 ++++
9 files changed, 792 insertions(+)
create mode 100644 rust/helpers/spi.c
create mode 100644 rust/kernel/spi.rs
create mode 100644 samples/rust/rust_driver_spi.rs
--
2.43.0
next prev parent reply other threads:[~2026-11-13 2:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261027054209.904654-1-847807867@qq.com>
2026-10-27 5:42 ` [PATCH v6 1/3] rust: helpers: add SPI helpers Shuai Liu
2026-10-27 5:42 ` [PATCH v6 2/3] rust: spi: add SPI driver abstractions Shuai Liu
2026-11-12 19:30 ` Mark Brown
2026-11-13 2:04 ` Shuai Liu
2026-11-13 2:05 ` Shuai Liu [this message]
2026-11-13 2:25 ` [PATCH v7 1/3] rust: helpers: add SPI helpers Shuai Liu
[not found] ` <20261113022539.601421-1-847807867@qq.com>
2026-11-13 2:25 ` [PATCH v7 2/3] rust: spi: add SPI driver abstractions Shuai Liu
2026-11-13 2:25 ` [PATCH v7 3/3] samples: rust: add SPI driver sample Shuai Liu
2026-11-13 2:25 ` [PATCH v7 1/3] rust: helpers: add SPI helpers Shuai Liu
[not found] ` <20261113022552.601873-1-847807867@qq.com>
2026-11-13 2:25 ` [PATCH v7 2/3] rust: spi: add SPI driver abstractions Shuai Liu
2026-11-13 2:25 ` [PATCH v7 3/3] samples: rust: add SPI driver sample Shuai Liu
2026-10-27 5:42 ` [PATCH v6 " Shuai Liu
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=tencent_097BA6F40A0B8FBC4C130C6EBF58F8048006@qq.com \
--to=847807867@qq.com \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®