From: Danilo Krummrich <dakr@kernel.org>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>,
kuba@kernel.org, gregkh@linuxfoundation.org, robh@kernel.org,
saravanak@google.com, alex.gaynor@gmail.com, ojeda@kernel.org,
rafael@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
bhelgaas@google.com, bjorn3_gh@protonmail.com,
boqun.feng@gmail.com, david.m.ertman@intel.com,
devicetree@vger.kernel.org, gary@garyguo.net,
ira.weiny@intel.com, kwilczynski@kernel.org, leon@kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
lossin@kernel.org, netdev@vger.kernel.org,
rust-for-linux@vger.kernel.org, tmgross@umich.edu
Subject: Re: [PATCH v3 0/3] rust: Build PHY device tables by using module_device_table macro
Date: Wed, 9 Jul 2025 00:51:24 +0200 [thread overview]
Message-ID: <aG2g7HgDdvmFJpMz@pollux> (raw)
In-Reply-To: <CANiq72=Cbvrcwqt6PQHwwDVTx1vnVnQ7JBzzXk+K-7Va_OVHEQ@mail.gmail.com>
On Tue, Jul 08, 2025 at 08:47:13PM +0200, Miguel Ojeda wrote:
> Thanks Danilo -- ditto. Even netdev could make sense as you said.
>
> Since it touched several subsystems and it is based on rust-next, I am
> happy to do so, but driver-core makes sense given that is the main
> change after all.
>
> So if I don't see you picking it, I will eventually do it.
Checked again and the driver-core tree makes most sense, since we also need to
fix up the ACPI device ID code, which is queued up in driver-core-next.
I also caught a missing change in rust/kernel/driver.rs, which most likely
slipped through by not building with CONFIG_OF. :)
Here's the diff to fix up both, I already fixed it up on my end -- no need to
send a new version.
--
diff --git a/rust/kernel/acpi.rs b/rust/kernel/acpi.rs
index 2af4d4f92924..7ae317368b00 100644
--- a/rust/kernel/acpi.rs
+++ b/rust/kernel/acpi.rs
@@ -2,7 +2,11 @@
//! Advanced Configuration and Power Interface abstractions.
-use crate::{bindings, device_id::RawDeviceId, prelude::*};
+use crate::{
+ bindings,
+ device_id::{RawDeviceId, RawDeviceIdIndex},
+ prelude::*,
+};
/// IdTable type for ACPI drivers.
pub type IdTable<T> = &'static dyn kernel::device_id::IdTable<DeviceId, T>;
@@ -12,13 +16,14 @@
#[derive(Clone, Copy)]
pub struct DeviceId(bindings::acpi_device_id);
-// SAFETY:
-// * `DeviceId` is a `#[repr(transparent)` wrapper of `struct acpi_device_id` and does not add
-// additional invariants, so it's safe to transmute to `RawType`.
-// * `DRIVER_DATA_OFFSET` is the offset to the `data` field.
+// SAFETY: `DeviceId` is a `#[repr(transparent)]` wrapper of `acpi_device_id` and does not add
+// additional invariants, so it's safe to transmute to `RawType`.
unsafe impl RawDeviceId for DeviceId {
type RawType = bindings::acpi_device_id;
+}
+// SAFETY: `DRIVER_DATA_OFFSET` is the offset to the `driver_data` field.
+unsafe impl RawDeviceIdIndex for DeviceId {
const DRIVER_DATA_OFFSET: usize = core::mem::offset_of!(bindings::acpi_device_id, driver_data);
fn index(&self) -> usize {
diff --git a/rust/kernel/driver.rs b/rust/kernel/driver.rs
index f8dd7593e8dc..573d516b2f06 100644
--- a/rust/kernel/driver.rs
+++ b/rust/kernel/driver.rs
@@ -170,7 +170,7 @@ fn acpi_id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
// and does not add additional invariants, so it's safe to transmute.
let id = unsafe { &*raw_id.cast::<acpi::DeviceId>() };
- Some(table.info(<acpi::DeviceId as crate::device_id::RawDeviceId>::index(id)))
+ Some(table.info(<acpi::DeviceId as crate::device_id::RawDeviceIdIndex>::index(id)))
}
}
}
@@ -204,7 +204,7 @@ fn of_id_info(dev: &device::Device) -> Option<&'static Self::IdInfo> {
// and does not add additional invariants, so it's safe to transmute.
let id = unsafe { &*raw_id.cast::<of::DeviceId>() };
- Some(table.info(<of::DeviceId as crate::device_id::RawDeviceId>::index(id)))
+ Some(table.info(<of::DeviceId as crate::device_id::RawDeviceIdIndex>::index(id)))
}
}
}
next prev parent reply other threads:[~2025-07-08 22:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 4:10 [PATCH v3 0/3] rust: Build PHY device tables by using module_device_table macro FUJITA Tomonori
2025-07-04 4:10 ` [PATCH v3 1/3] rust: device_id: split out index support into a separate trait FUJITA Tomonori
2025-07-09 3:10 ` Trevor Gross
2025-07-11 3:17 ` FUJITA Tomonori
2025-07-04 4:10 ` [PATCH v3 2/3] rust: net::phy represent DeviceId as transparent wrapper over mdio_device_id FUJITA Tomonori
2025-07-09 3:23 ` Trevor Gross
2025-07-11 3:38 ` FUJITA Tomonori
2025-07-04 4:10 ` [PATCH v3 3/3] rust: net::phy Change module_phy_driver macro to use module_device_table macro FUJITA Tomonori
2025-07-09 3:39 ` Trevor Gross
2025-07-08 0:53 ` [PATCH v3 0/3] rust: Build PHY device tables by using " Jakub Kicinski
2025-07-08 10:45 ` Miguel Ojeda
2025-07-08 10:59 ` Danilo Krummrich
2025-07-08 10:59 ` FUJITA Tomonori
2025-07-08 12:47 ` Danilo Krummrich
2025-07-08 18:47 ` Miguel Ojeda
2025-07-08 22:51 ` Danilo Krummrich [this message]
2025-07-09 2:08 ` FUJITA Tomonori
2025-07-10 20:01 ` Danilo Krummrich
2025-07-10 23:03 ` FUJITA Tomonori
2025-07-08 10:49 ` Danilo Krummrich
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=aG2g7HgDdvmFJpMz@pollux \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=david.m.ertman@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=kuba@kernel.org \
--cc=kwilczynski@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=saravanak@google.com \
--cc=tmgross@umich.edu \
/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.