Skip to content

Commit 92c376a

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 235a099 commit 92c376a

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

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

23332359
static struct kobject *dev_kobj;

include/linux/fwnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,6 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup,
229229
void fwnode_links_purge(struct fwnode_handle *fwnode);
230230
void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
231231
bool fw_devlink_is_strict(void);
232+
int fw_devlink_count_absent_consumers(struct fwnode_handle *fwnode);
232233

233234
#endif

0 commit comments

Comments
 (0)