]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
driver core: fix inverted "locked" suffix of driver_match_device()
authorDanilo Krummrich <dakr@kernel.org>
Sat, 31 Jan 2026 01:42:07 +0000 (02:42 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Sun, 1 Feb 2026 21:24:25 +0000 (22:24 +0100)
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()")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Gui-Dong Han <hanguidong02@gmail.com>
Link: https://patch.msgid.link/20260131014211.12841-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
drivers/base/base.h
drivers/base/bus.c
drivers/base/dd.c

index 5bc1439d349872fa1b1a33e083db47fe219630cd..8c2175820da9b0db2c4ec9cbcdb99675746df03e 100644 (file)
@@ -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)
index 331d750465e2fcc2a4b80df0a7ca91254dde36a9..9eb7771706f018ce51c7899acdd33aa567a74a73 100644 (file)
@@ -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 */
index ed3a0762481696ae958c9c21ee8abee2863b12a1..0354f209529c69bc4cf5783f56b0030537377c00 100644 (file)
@@ -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;