* [PATCH] driver core: fix inverted "locked" suffix of driver_match_device()
@ 2026-01-31 1:42 Danilo Krummrich
2026-01-31 5:36 ` Gui-Dong Han
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Danilo Krummrich @ 2026-01-31 1:42 UTC (permalink / raw)
To: gregkh, rafael, hanguidong02; +Cc: driver-core, linux-kernel, Danilo Krummrich
In the current implementation driver_match_device() expects the device
lock to be held, while driver_match_device_locked() acquires the device
lock.
By convention it should be the other way around, hence swap the name of
both functions.
Fixes: dc23806a7c47 ("driver core: enforce device_lock for driver_match_device()")
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
drivers/base/base.h | 10 +++++-----
drivers/base/bus.c | 2 +-
drivers/base/dd.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 5bc1439d3498..8c2175820da9 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -179,19 +179,19 @@ void device_release_driver_internal(struct device *dev, const struct device_driv
void driver_detach(const struct device_driver *drv);
void driver_deferred_probe_del(struct device *dev);
void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf);
-static inline int driver_match_device(const struct device_driver *drv,
- struct device *dev)
+static inline int driver_match_device_locked(const struct device_driver *drv,
+ struct device *dev)
{
device_lock_assert(dev);
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
}
-static inline int driver_match_device_locked(const struct device_driver *drv,
- struct device *dev)
+static inline int driver_match_device(const struct device_driver *drv,
+ struct device *dev)
{
guard(device)(dev);
- return driver_match_device(drv, dev);
+ return driver_match_device_locked(drv, dev);
}
static inline void dev_sync_state(struct device *dev)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 331d750465e2..9eb7771706f0 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -263,7 +263,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
int err = -ENODEV;
dev = bus_find_device_by_name(bus, NULL, buf);
- if (dev && driver_match_device_locked(drv, dev)) {
+ if (dev && driver_match_device(drv, dev)) {
err = device_driver_attach(drv, dev);
if (!err) {
/* success */
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index ed3a07624816..0354f209529c 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -928,7 +928,7 @@ static int __device_attach_driver(struct device_driver *drv, void *_data)
bool async_allowed;
int ret;
- ret = driver_match_device(drv, dev);
+ ret = driver_match_device_locked(drv, dev);
if (ret == 0) {
/* no match */
return 0;
@@ -1180,7 +1180,7 @@ static int __driver_attach(struct device *dev, void *data)
* is an error.
*/
- ret = driver_match_device_locked(drv, dev);
+ ret = driver_match_device(drv, dev);
if (ret == 0) {
/* no match */
return 0;
base-commit: c71257394bc9c59ea727803f6e55e83fe63db74e
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] driver core: fix inverted "locked" suffix of driver_match_device()
2026-01-31 1:42 [PATCH] driver core: fix inverted "locked" suffix of driver_match_device() Danilo Krummrich
@ 2026-01-31 5:36 ` Gui-Dong Han
2026-01-31 6:23 ` Greg KH
2026-02-01 21:33 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Gui-Dong Han @ 2026-01-31 5:36 UTC (permalink / raw)
To: Danilo Krummrich; +Cc: gregkh, rafael, driver-core, linux-kernel
On Sat, Jan 31, 2026 at 9:46 AM Danilo Krummrich <dakr@kernel.org> wrote:
>
> In the current implementation driver_match_device() expects the device
> lock to be held, while driver_match_device_locked() acquires the device
> lock.
>
> By convention it should be the other way around, hence swap the name of
> both functions.
>
> Fixes: dc23806a7c47 ("driver core: enforce device_lock for driver_match_device()")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Looks good to me. Thanks for fixing the naming convention.
Reviewed-by: Gui-Dong Han <hanguidong02@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver core: fix inverted "locked" suffix of driver_match_device()
2026-01-31 1:42 [PATCH] driver core: fix inverted "locked" suffix of driver_match_device() Danilo Krummrich
2026-01-31 5:36 ` Gui-Dong Han
@ 2026-01-31 6:23 ` Greg KH
2026-02-01 21:33 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-01-31 6:23 UTC (permalink / raw)
To: Danilo Krummrich; +Cc: rafael, hanguidong02, driver-core, linux-kernel
On Sat, Jan 31, 2026 at 02:42:07AM +0100, Danilo Krummrich wrote:
> In the current implementation driver_match_device() expects the device
> lock to be held, while driver_match_device_locked() acquires the device
> lock.
>
> By convention it should be the other way around, hence swap the name of
> both functions.
>
> Fixes: dc23806a7c47 ("driver core: enforce device_lock for driver_match_device()")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver core: fix inverted "locked" suffix of driver_match_device()
2026-01-31 1:42 [PATCH] driver core: fix inverted "locked" suffix of driver_match_device() Danilo Krummrich
2026-01-31 5:36 ` Gui-Dong Han
2026-01-31 6:23 ` Greg KH
@ 2026-02-01 21:33 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Danilo Krummrich @ 2026-02-01 21:33 UTC (permalink / raw)
To: gregkh, rafael, hanguidong02; +Cc: driver-core, linux-kernel
On Sat Jan 31, 2026 at 2:42 AM CET, Danilo Krummrich wrote:
> In the current implementation driver_match_device() expects the device
> lock to be held, while driver_match_device_locked() acquires the device
> lock.
>
> By convention it should be the other way around, hence swap the name of
> both functions.
>
> Fixes: dc23806a7c47 ("driver core: enforce device_lock for driver_match_device()")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Applied to driver-core-testing, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-01 21:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-31 1:42 [PATCH] driver core: fix inverted "locked" suffix of driver_match_device() Danilo Krummrich
2026-01-31 5:36 ` Gui-Dong Han
2026-01-31 6:23 ` Greg KH
2026-02-01 21:33 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox