]> git.ipfire.org Git - thirdparty/linux.git/commit
rust: driver core: remove drvdata() and driver_type
authorDanilo Krummrich <dakr@kernel.org>
Tue, 5 May 2026 15:23:09 +0000 (17:23 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Mon, 11 May 2026 13:26:12 +0000 (15:26 +0200)
commit95ade775c4ab9b9b3d7cfa2d45283e93fbfa4e7a
tree9bdc9f86bb1966ff13d0734bc3e9a2548e7bcdb6
parentfd3b87ff0232f46e1ad53a48609a3853c8757c6c
rust: driver core: remove drvdata() and driver_type

When drvdata() was introduced in commit 6f61a2637abe ("rust: device:
introduce Device::drvdata()"), its commit message already noted that a
direct accessor to the driver's bus device private data is not commonly
required -- bus callbacks provide access through &self, and other entry
points (IRQs, workqueues, IOCTLs, etc.) carry their own private data.

The sole motivation for drvdata() was inter-driver interaction -- an
auxiliary driver deriving the parent's bus device private data from the
parent device.

However, drvdata() exposes the driver's bus device private data beyond
the driver's own scope. This creates ordering constraints; for instance
drvdata may not be set yet when the first caller of drvdata() can
appear. It also forces the driver's bus device private data to outlive
all registrations that access it, which causes unnecessary
complications.

Private data should be private to the entity that issues it, i.e. bus
device private data belongs to bus callbacks, class device private data
to class callbacks, IRQ private data to the IRQ handler, etc.

With registration-private data now available through the auxiliary bus,
there is no remaining user of drvdata(), thus remove it.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260505152400.3905096-4-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
drivers/base/base.h
rust/kernel/device.rs