Skip to content

Commit 1d13d3b

Browse files
Mike TiptonGeorgi Djakov
authored andcommitted
interconnect: Reintroduce icc_get()
The original icc_get() that took integer node IDs was removed due to lack of users. Reintroduce a new version that takes string node names, which is needed for the debugfs client. Signed-off-by: Mike Tipton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Georgi Djakov <[email protected]>
1 parent 86b5488 commit 1d13d3b

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

drivers/interconnect/core.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,21 @@ static struct icc_node *node_find(const int id)
147147
return idr_find(&icc_idr, id);
148148
}
149149

150+
static struct icc_node *node_find_by_name(const char *name)
151+
{
152+
struct icc_provider *provider;
153+
struct icc_node *n;
154+
155+
list_for_each_entry(provider, &icc_providers, provider_list) {
156+
list_for_each_entry(n, &provider->nodes, node_list) {
157+
if (!strcmp(n->name, name))
158+
return n;
159+
}
160+
}
161+
162+
return NULL;
163+
}
164+
150165
static struct icc_path *path_init(struct device *dev, struct icc_node *dst,
151166
ssize_t num_nodes)
152167
{
@@ -561,6 +576,54 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
561576
}
562577
EXPORT_SYMBOL_GPL(of_icc_get);
563578

579+
/**
580+
* icc_get() - get a path handle between two endpoints
581+
* @dev: device pointer for the consumer device
582+
* @src: source node name
583+
* @dst: destination node name
584+
*
585+
* This function will search for a path between two endpoints and return an
586+
* icc_path handle on success. Use icc_put() to release constraints when they
587+
* are not needed anymore.
588+
*
589+
* Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
590+
* when the API is disabled.
591+
*/
592+
struct icc_path *icc_get(struct device *dev, const char *src, const char *dst)
593+
{
594+
struct icc_node *src_node, *dst_node;
595+
struct icc_path *path = ERR_PTR(-EPROBE_DEFER);
596+
597+
mutex_lock(&icc_lock);
598+
599+
src_node = node_find_by_name(src);
600+
if (!src_node) {
601+
dev_err(dev, "%s: invalid src=%s\n", __func__, src);
602+
goto out;
603+
}
604+
605+
dst_node = node_find_by_name(dst);
606+
if (!dst_node) {
607+
dev_err(dev, "%s: invalid dst=%s\n", __func__, dst);
608+
goto out;
609+
}
610+
611+
path = path_find(dev, src_node, dst_node);
612+
if (IS_ERR(path)) {
613+
dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path));
614+
goto out;
615+
}
616+
617+
path->name = kasprintf(GFP_KERNEL, "%s-%s", src_node->name, dst_node->name);
618+
if (!path->name) {
619+
kfree(path);
620+
path = ERR_PTR(-ENOMEM);
621+
}
622+
out:
623+
mutex_unlock(&icc_lock);
624+
return path;
625+
}
626+
564627
/**
565628
* icc_set_tag() - set an optional tag on a path
566629
* @path: the path we want to tag

drivers/interconnect/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ struct icc_path {
4141
struct icc_req reqs[];
4242
};
4343

44+
struct icc_path *icc_get(struct device *dev, const char *src, const char *dst);
45+
4446
#endif

0 commit comments

Comments
 (0)