Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] rust: debugfs: migrate debugfs traits requirements to zerocopy
@ 2026-07-28 17:31 Josef Ippisch via B4 Relay
  2026-07-28 17:31 ` [PATCH v2 1/2] " Josef Ippisch via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Ippisch via B4 Relay @ 2026-07-28 17:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: driver-core, rust-for-linux, linux-kernel, Joshua Liebow-Feeser,
	Miguel Ojeda, Josef Ippisch

Migrate `BinaryWriter` and `BinaryReaderMut`'s default implementation's
requirements on T from `kernel::transmute` traits to `zerocopy` traits.

This is part of a bigger migration from rust/kernel/transmute.rs to the
zerocopy crate, see also [1] and [2]

[1] https://github.com/Rust-for-Linux/linux/issues/975
[2] https://github.com/Rust-for-Linux/linux/issues/1241

The crate zerocopy was introduced with

c37398010a05 rust: zerocopy: import crate

This introduced among other things the `FromBytes` and `IntoBytes` traits
that, when derived, do better checks on the actual requirements of the
types they are implemented on than the existing
`kernel::transmute::FromBytes` and `kernel::transmute::AsBytes` traits,
respectively.

This is my first kernel patch so please let me know if I do anything wrong
process wise or regarding some other aspect!

I noticed that we could probably get rid of the `BinaryWriter` and
`BinaryReaderMut` implementations for `Vec` altogether if we implemented
`FromBytes`, `Immutable` and `IntoBytes` for `Vec`.  These are already
implemented for [T] after all. What do you think?

Suggested-by: Joshua Liebow-Feeser <joshlf@google.com>
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/975
Link: https://github.com/Rust-for-Linux/linux/issues/1241
Signed-off-by: Josef Ippisch <josef.ippisch.dev@mailbox.org>
---
Changes in v2:
- Addresses Sashiko AI review's comment about also migrating
  `BinaryReaderMut` to zerocopy to not bifurcate the API requirements of
  debugfs/traits.rs.
- Do not `use zerocopy::{FromBytes, IntoBytes}` as they are part of
  `use kernel::prelude::*`.
- For some reason sending v2 via SMTP server did not reach the mailing
  list.  I apologize if some of you receive this twice now.  I did not
  mark this RESEND because of the email never reaching the mailing list.
- Link to v1: https://patch.msgid.link/20260719-migrate-binarywriter-to-zerocopy-intobytes-v1-0-27ed30512e75@mailbox.org

---
Josef Ippisch (2):
      rust: debugfs: migrate debugfs traits requirements to zerocopy
      rust: debugfs: remove unsafe blocks from traits impl for Vec

 rust/kernel/debugfs/traits.rs | 41 +++++++++++------------------------------
 1 file changed, 11 insertions(+), 30 deletions(-)
---
base-commit: 7059bdf4f04a3e14f4fafb3ac35fdca913e3e21a
change-id: 20260719-migrate-binarywriter-to-zerocopy-intobytes-1e8f4ef93a60

Best regards,
--  
Josef Ippisch <josef.ippisch.dev@mailbox.org>



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

end of thread, other threads:[~2026-07-31  9:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 17:31 [PATCH v2 0/2] rust: debugfs: migrate debugfs traits requirements to zerocopy Josef Ippisch via B4 Relay
2026-07-28 17:31 ` [PATCH v2 1/2] " Josef Ippisch via B4 Relay
2026-07-28 17:31 ` [PATCH v2 2/2] rust: debugfs: remove unsafe blocks from traits impl for Vec Josef Ippisch via B4 Relay
2026-07-31  9:09 ` [PATCH v2 0/2] rust: debugfs: migrate debugfs traits requirements to zerocopy Greg Kroah-Hartman

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