From 5cc74db68155c8eb3e14b6d54895f4fc11390dce Mon Sep 17 00:00:00 2001 From: Saravana Kannan Date: Mon, 13 Feb 2023 13:40:43 -0800 Subject: [PATCH] add class support to device links Signed-off-by: Saravana Kannan --- drivers/base/core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index abc6fd2868a5..a3cc516dc26b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1393,7 +1393,15 @@ void device_links_driver_bound(struct device *dev) continue; WARN_ON(link->status != DL_STATE_DORMANT); - WRITE_ONCE(link->status, DL_STATE_AVAILABLE); + + /* + * A "class" device doesn't really probe. Consider the link as + * active as soon as the supplier probes. + */ + if (link->consumer->class) + WRITE_ONCE(link->status, DL_STATE_ACTIVE); + else + WRITE_ONCE(link->status, DL_STATE_AVAILABLE); if (link->flags & DL_FLAG_AUTOPROBE_CONSUMER) driver_deferred_probe_add(link->consumer); @@ -3599,6 +3607,14 @@ int device_add(struct device *dev) devtmpfs_create_node(dev); } + /* + * Once a device is added to a class, consider it as bound to a driver + * from a device links perspective. This way, we wouldn't block any + * consumers of this device from probing. + */ + if (dev->class) + dev->links.status = DL_DEV_DRIVER_BOUND; + /* Notify clients of device addition. This call must come * after dpm_sysfs_add() and before kobject_uevent(). */ -- 2.39.2.637.g21b0678d19-goog