Skip to content

Commit 90562c8

Browse files
committed
Merge remote-tracking branch 'georgi/icc-get-by-index' into opp/linux-next
2 parents 6c591ee + 8fd3574 commit 90562c8

File tree

3 files changed

+62
-25
lines changed

3 files changed

+62
-25
lines changed

drivers/interconnect/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
menuconfig INTERCONNECT
3-
tristate "On-Chip Interconnect management support"
3+
bool "On-Chip Interconnect management support"
44
help
55
Support for management of the on-chip interconnects.
66

drivers/interconnect/core.c

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,9 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
351351
}
352352

353353
/**
354-
* of_icc_get() - get a path handle from a DT node based on name
354+
* of_icc_get_by_index() - get a path handle from a DT node based on index
355355
* @dev: device pointer for the consumer device
356-
* @name: interconnect path name
356+
* @idx: interconnect path index
357357
*
358358
* This function will search for a path between two endpoints and return an
359359
* icc_path handle on success. Use icc_put() to release constraints when they
@@ -365,13 +365,12 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
365365
* Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
366366
* when the API is disabled or the "interconnects" DT property is missing.
367367
*/
368-
struct icc_path *of_icc_get(struct device *dev, const char *name)
368+
struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
369369
{
370-
struct icc_path *path = ERR_PTR(-EPROBE_DEFER);
370+
struct icc_path *path;
371371
struct icc_node *src_node, *dst_node;
372-
struct device_node *np = NULL;
372+
struct device_node *np;
373373
struct of_phandle_args src_args, dst_args;
374-
int idx = 0;
375374
int ret;
376375

377376
if (!dev || !dev->of_node)
@@ -391,12 +390,6 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
391390
* lets support only global ids and extend this in the future if needed
392391
* without breaking DT compatibility.
393392
*/
394-
if (name) {
395-
idx = of_property_match_string(np, "interconnect-names", name);
396-
if (idx < 0)
397-
return ERR_PTR(idx);
398-
}
399-
400393
ret = of_parse_phandle_with_args(np, "interconnects",
401394
"#interconnect-cells", idx * 2,
402395
&src_args);
@@ -439,19 +432,62 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
439432
return path;
440433
}
441434

442-
if (name)
443-
path->name = kstrdup_const(name, GFP_KERNEL);
444-
else
445-
path->name = kasprintf(GFP_KERNEL, "%s-%s",
446-
src_node->name, dst_node->name);
447-
435+
path->name = kasprintf(GFP_KERNEL, "%s-%s",
436+
src_node->name, dst_node->name);
448437
if (!path->name) {
449438
kfree(path);
450439
return ERR_PTR(-ENOMEM);
451440
}
452441

453442
return path;
454443
}
444+
EXPORT_SYMBOL_GPL(of_icc_get_by_index);
445+
446+
/**
447+
* of_icc_get() - get a path handle from a DT node based on name
448+
* @dev: device pointer for the consumer device
449+
* @name: interconnect path name
450+
*
451+
* This function will search for a path between two endpoints and return an
452+
* icc_path handle on success. Use icc_put() to release constraints when they
453+
* are not needed anymore.
454+
* If the interconnect API is disabled, NULL is returned and the consumer
455+
* drivers will still build. Drivers are free to handle this specifically,
456+
* but they don't have to.
457+
*
458+
* Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned
459+
* when the API is disabled or the "interconnects" DT property is missing.
460+
*/
461+
struct icc_path *of_icc_get(struct device *dev, const char *name)
462+
{
463+
struct device_node *np;
464+
int idx = 0;
465+
466+
if (!dev || !dev->of_node)
467+
return ERR_PTR(-ENODEV);
468+
469+
np = dev->of_node;
470+
471+
/*
472+
* When the consumer DT node do not have "interconnects" property
473+
* return a NULL path to skip setting constraints.
474+
*/
475+
if (!of_find_property(np, "interconnects", NULL))
476+
return NULL;
477+
478+
/*
479+
* We use a combination of phandle and specifier for endpoint. For now
480+
* lets support only global ids and extend this in the future if needed
481+
* without breaking DT compatibility.
482+
*/
483+
if (name) {
484+
idx = of_property_match_string(np, "interconnect-names", name);
485+
if (idx < 0)
486+
return ERR_PTR(idx);
487+
}
488+
489+
return of_icc_get_by_index(dev, idx);
490+
}
455491
EXPORT_SYMBOL_GPL(of_icc_get);
456492

457493
/**
@@ -908,12 +944,7 @@ static int __init icc_init(void)
908944
return 0;
909945
}
910946

911-
static void __exit icc_exit(void)
912-
{
913-
debugfs_remove_recursive(icc_debugfs_dir);
914-
}
915-
module_init(icc_init);
916-
module_exit(icc_exit);
947+
device_initcall(icc_init);
917948

918949
MODULE_AUTHOR("Georgi Djakov <[email protected]>");
919950
MODULE_DESCRIPTION("Interconnect Driver Core");

include/linux/interconnect.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct device;
2828
struct icc_path *icc_get(struct device *dev, const int src_id,
2929
const int dst_id);
3030
struct icc_path *of_icc_get(struct device *dev, const char *name);
31+
struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
3132
void icc_put(struct icc_path *path);
3233
int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw);
3334
void icc_set_tag(struct icc_path *path, u32 tag);
@@ -46,6 +47,11 @@ static inline struct icc_path *of_icc_get(struct device *dev,
4647
return NULL;
4748
}
4849

50+
static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
51+
{
52+
return NULL;
53+
}
54+
4955
static inline void icc_put(struct icc_path *path)
5056
{
5157
}

0 commit comments

Comments
 (0)