mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Shuai Liu" <847807867@qq.com>, <linux-spi@vger.kernel.org>,
	<rust-for-linux@vger.kernel.org>
Cc: <broonie@kernel.org>, <ojeda@kernel.org>, <dakr@kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 0/3] Rust abstractions for the SPI driver subsystem
Date: Mon, 09 Nov 2026 16:37:39 +0000	[thread overview]
Message-ID: <DMQTSR52MFG2.HUM8KW5WEE8Z@garyguo.net> (raw)
In-Reply-To: <tencent_2588854DF4B99B4897B3F4CAFF3461E14A0A@qq.com>

On Tue Oct 27, 2026 at 5:42 AM GMT, Shuai Liu wrote:
> Changes since v5:
>   - validate in `write_then_read()` that the sum of the two buffer
>     lengths fits in `u32`: the C core's spi_write_then_read() sums the
>     two lengths as `unsigned int` when selecting and sizing its bounce
>     buffer, so two ~2GiB slices would wrap the sum to zero and select
>     the preallocated `SPI_BUFSIZ` buffer, which then overflows on the
>     copy. Found by Karl Mehltretter.
>
> The Rust abstractions for several buses are already present in the
> kernel (PCI, platform, I2C, USB, serdev, ...), but the SPI driver
> subsystem is still missing such abstractions. This series adds them,
> along with a sample driver demonstrating their usage.
>
> To my knowledge, nobody is currently working on Rust SPI abstractions;
> if someone already has work in progress, please let me know and I will
> happily drop or rebase this series.
>
> The abstractions follow the same layout as the existing I2C and serdev
> abstractions: a `Driver` trait for drivers to implement, an `Adapter`
> for driver registration, and a `SpiDevice` wrapping `struct spi_device`.
> This first installment provides synchronous `read`, `write` and
> `write_then_read` operations; message-based transfers (`spi_message` /
> `spi_transfer`) can be added on top in a follow-up series.
>
> One deviation from the I2C abstractions: `spi_match_id()` is not
> exported to modules, so device id matching by modalias uses the
> exported `spi_get_device_id()` instead, falling back to the OF and ACPI
> tables.
>
> The series is based on the current mainline tree (7.4 merge window) and
> has been build-tested with CONFIG_RUST=y, including the KUnit tests and
> doctests for the new abstractions. I do not have access to real SPI
> hardware to run-test this series, but the included sample driver can be
> used for that purpose.
>
> Signed-off-by: Shuai Liu <847807867@qq.com>

Your patches are not replies to the cover letter, as your email provider
rewrites the Message-ID. This break lore (and email clients).

You can try "--outlook-id-fix" (but it's not guaranteed to work if your email
provider doesn't report the reassigned Message-ID in the same way as outlook).
Alternatively, submit your patches via B4.

Best,
Gary

>
> 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              |  25 ++
>  rust/kernel/Kconfig.test        |  11 +
>  rust/kernel/lib.rs              |   2 +
>  rust/kernel/spi.rs              | 570 ++++++++++++++++++++++++++++++++
>  samples/rust/Kconfig            |  11 +
>  samples/rust/Makefile           |   1 +
>  samples/rust/rust_driver_spi.rs |  66 ++++
>  9 files changed, 688 insertions(+)
>  create mode 100644 rust/helpers/spi.c
>  create mode 100644 rust/kernel/spi.rs
>  create mode 100644 samples/rust/rust_driver_spi.rs



      reply	other threads:[~2026-11-09 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  5:42 Shuai Liu
2026-11-09 16:37 ` Gary Guo [this message]

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=DMQTSR52MFG2.HUM8KW5WEE8Z@garyguo.net \
    --to=gary@garyguo.net \
    --cc=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®