From: Danilo Krummrich <dakr@kernel.org>
To: gregkh@linuxfoundation.org, rafael@kernel.org,
hanguidong02@gmail.com, ysato@users.sourceforge.jp,
dalias@libc.org, glaubitz@physik.fu-berlin.de,
abelvesa@kernel.org, srini@kernel.org, s.nawrocki@samsung.com,
nuno.sa@analog.com
Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-hwmon@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org,
linux-sh@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH v2 2/4] docs: driver-model: document driver_override
Date: Tue, 3 Mar 2026 12:53:19 +0100 [thread overview]
Message-ID: <20260303115720.48783-3-dakr@kernel.org> (raw)
In-Reply-To: <20260303115720.48783-1-dakr@kernel.org>
Now that we support driver_override as a driver-core feature through
struct device and struct bus_type, add some documentation in the context
of how a device / driver binding is established.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
.../driver-api/driver-model/binding.rst | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/Documentation/driver-api/driver-model/binding.rst b/Documentation/driver-api/driver-model/binding.rst
index d1d311a4011f..fa0888c2b3b9 100644
--- a/Documentation/driver-api/driver-model/binding.rst
+++ b/Documentation/driver-api/driver-model/binding.rst
@@ -99,3 +99,51 @@ of the driver is decremented. All symlinks between the two are removed.
When a driver is removed, the list of devices that it supports is
iterated over, and the driver's remove callback is called for each
one. The device is removed from that list and the symlinks removed.
+
+
+Driver Override
+~~~~~~~~~~~~~~~
+
+Userspace may override the standard matching by writing a driver name to
+a device's ``driver_override`` sysfs attribute. When set, only a driver
+whose name matches the override will be considered during binding. This
+bypasses all bus-specific matching (OF, ACPI, ID tables, etc.).
+
+The override may be cleared by writing an empty string, which returns
+the device to standard matching rules. Writing to ``driver_override``
+does not automatically unbind the device from its current driver or
+make any attempt to load the specified driver.
+
+Buses opt into this mechanism by setting the ``driver_override`` flag in
+their ``struct bus_type``::
+
+ const struct bus_type example_bus_type = {
+ ...
+ .driver_override = true,
+ };
+
+When the flag is set, the driver core automatically creates the
+``driver_override`` sysfs attribute for every device on that bus.
+
+The bus's ``match()`` callback should check the override before performing
+its own matching, using ``device_match_driver_override()``::
+
+ static int example_match(struct device *dev, const struct device_driver *drv)
+ {
+ int ret;
+
+ ret = device_match_driver_override(dev, drv);
+ if (ret >= 0)
+ return ret;
+
+ /* Fall through to bus-specific matching... */
+ }
+
+``device_match_driver_override()`` returns > 0 if the override matches
+the given driver, 0 if the override is set but does not match, or < 0 if
+no override is set at all.
+
+Additional helpers are available:
+
+- ``device_set_driver_override()`` - set or clear the override from kernel code.
+- ``device_has_driver_override()`` - check whether an override is set.
--
2.53.0
next prev parent reply other threads:[~2026-03-03 11:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 11:53 [PATCH v2 0/4] driver core: generalize driver_override infrastructure Danilo Krummrich
2026-03-03 11:53 ` [PATCH v2 1/4] driver core: generalize driver_override in struct device Danilo Krummrich
2026-03-03 21:01 ` Frank Li
2026-03-04 2:27 ` Gui-Dong Han
2026-03-03 11:53 ` Danilo Krummrich [this message]
2026-03-03 21:01 ` [PATCH v2 2/4] docs: driver-model: document driver_override Frank Li
2026-03-03 11:53 ` [PATCH v2 3/4] hwmon: axi-fan: don't use driver_override as IRQ name Danilo Krummrich
2026-03-03 14:53 ` Nuno Sá
2026-03-03 16:23 ` Guenter Roeck
2026-03-03 16:25 ` Danilo Krummrich
2026-03-03 16:57 ` Guenter Roeck
2026-03-03 19:18 ` Danilo Krummrich
2026-03-03 21:01 ` Frank Li
2026-03-03 11:53 ` [PATCH v2 4/4] driver core: platform: use generic driver_override infrastructure Danilo Krummrich
2026-03-03 21:01 ` Frank Li
2026-03-05 12:42 ` Danilo Krummrich
2026-03-12 20:15 ` Danilo Krummrich
2026-03-16 23:56 ` Danilo Krummrich
2026-03-17 5:06 ` Greg KH
2026-03-17 8:36 ` Geert Uytterhoeven
2026-03-03 13:03 ` [PATCH v2 0/4] driver core: generalize " Gui-Dong Han
2026-03-12 15:21 ` Greg KH
2026-03-17 20:17 ` 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=20260303115720.48783-3-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=abelvesa@kernel.org \
--cc=dalias@libc.org \
--cc=driver-core@lists.linux.dev \
--cc=glaubitz@physik.fu-berlin.de \
--cc=gregkh@linuxfoundation.org \
--cc=hanguidong02@gmail.com \
--cc=imx@lists.linux.dev \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=rafael@kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=srini@kernel.org \
--cc=ysato@users.sourceforge.jp \
/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