Skip to content

Commit e9e3094

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 b011751 commit e9e3094

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
@@ -2330,6 +2330,32 @@ static void fw_devlink_link_device(struct device *dev)
23302330
__fw_devlink_link_to_suppliers(dev, fwnode);
23312331
}
23322332

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

23352361
static struct kobject *dev_kobj;

include/linux/fwnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,6 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup,
221221
void fwnode_links_purge(struct fwnode_handle *fwnode);
222222
void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
223223
bool fw_devlink_is_strict(void);
224+
int fw_devlink_count_absent_consumers(struct fwnode_handle *fwnode);
224225

225226
#endif

0 commit comments

Comments
 (0)