Skip to content

Commit bb1e9fd

Browse files
marcanjannau
authored andcommitted
driver core: fw_devlink: Add fw_devlink_count_absent_consumers()
Some platforms have power domains that are active on boot and must remain powered up until all of their consumers probe. The genpd core needs a way to count how many consumers haven't probed yet to avoid powering off such domains. Add a fw_devlink_count_absent_consumers() function, which returns the total count of consumer devices which either have not been created at all yet (only fwlinks exist) or have been created but have no driver bound and fully probed yet. Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 0321977 commit bb1e9fd

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

drivers/base/core.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,32 @@ static void fw_devlink_link_device(struct device *dev)
23312331
__fw_devlink_link_to_suppliers(dev, fwnode);
23322332
}
23332333

2334+
/**
2335+
* fw_devlink_count_absent_consumers - Return how many consumers have
2336+
* either not been created yet, or do not yet have a driver attached.
2337+
* @fwnode: fwnode of the supplier
2338+
*/
2339+
int fw_devlink_count_absent_consumers(struct fwnode_handle *fwnode)
2340+
{
2341+
struct fwnode_link *link, *tmp;
2342+
struct device_link *dlink, *dtmp;
2343+
struct device *sup_dev = get_dev_from_fwnode(fwnode);
2344+
int count = 0;
2345+
2346+
list_for_each_entry_safe(link, tmp, &fwnode->consumers, s_hook)
2347+
count++;
2348+
2349+
if (!sup_dev)
2350+
return count;
2351+
2352+
list_for_each_entry_safe(dlink, dtmp, &sup_dev->links.consumers, s_node)
2353+
if (dlink->consumer->links.status != DL_DEV_DRIVER_BOUND)
2354+
count++;
2355+
2356+
return count;
2357+
}
2358+
EXPORT_SYMBOL_GPL(fw_devlink_count_absent_consumers);
2359+
23342360
/* Device links support end. */
23352361

23362362
static struct kobject *dev_kobj;

include/linux/fwnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,6 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup,
224224
void fwnode_links_purge(struct fwnode_handle *fwnode);
225225
void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
226226
bool fw_devlink_is_strict(void);
227+
int fw_devlink_count_absent_consumers(struct fwnode_handle *fwnode);
227228

228229
#endif

0 commit comments

Comments
 (0)