From 1597d453289b385237628cd96d57d147632ab105 Mon Sep 17 00:00:00 2001 From: Georgi Djakov Date: Tue, 12 May 2020 15:53:20 +0300 Subject: interconnect: Add of_icc_get_by_index() helper function This is the same as the traditional of_icc_get() function, but the difference is that it takes index as an argument, instead of name. Reviewed-by: Matthias Kaehlcke Reviewed-by: Sibi Sankar Link: https://lore.kernel.org/r/20200512125327.1868-4-georgi.djakov@linaro.org Signed-off-by: Georgi Djakov --- drivers/interconnect/core.c | 72 +++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 2c6515e3ecf1..aba5d38ea9d1 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -351,9 +351,9 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec) } /** - * of_icc_get() - get a path handle from a DT node based on name + * of_icc_get_by_index() - get a path handle from a DT node based on index * @dev: device pointer for the consumer device - * @name: interconnect path name + * @idx: interconnect path index * * This function will search for a path between two endpoints and return an * 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) * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned * when the API is disabled or the "interconnects" DT property is missing. */ -struct icc_path *of_icc_get(struct device *dev, const char *name) +struct icc_path *of_icc_get_by_index(struct device *dev, int idx) { - struct icc_path *path = ERR_PTR(-EPROBE_DEFER); + struct icc_path *path; struct icc_node *src_node, *dst_node; - struct device_node *np = NULL; + struct device_node *np; struct of_phandle_args src_args, dst_args; - int idx = 0; int ret; if (!dev || !dev->of_node) @@ -391,12 +390,6 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) * lets support only global ids and extend this in the future if needed * without breaking DT compatibility. */ - if (name) { - idx = of_property_match_string(np, "interconnect-names", name); - if (idx < 0) - return ERR_PTR(idx); - } - ret = of_parse_phandle_with_args(np, "interconnects", "#interconnect-cells", idx * 2, &src_args); @@ -439,12 +432,8 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) return path; } - if (name) - path->name = kstrdup_const(name, GFP_KERNEL); - else - path->name = kasprintf(GFP_KERNEL, "%s-%s", - src_node->name, dst_node->name); - + path->name = kasprintf(GFP_KERNEL, "%s-%s", + src_node->name, dst_node->name); if (!path->name) { kfree(path); return ERR_PTR(-ENOMEM); @@ -452,6 +441,53 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) return path; } +EXPORT_SYMBOL_GPL(of_icc_get_by_index); + +/** + * of_icc_get() - get a path handle from a DT node based on name + * @dev: device pointer for the consumer device + * @name: interconnect path name + * + * This function will search for a path between two endpoints and return an + * icc_path handle on success. Use icc_put() to release constraints when they + * are not needed anymore. + * If the interconnect API is disabled, NULL is returned and the consumer + * drivers will still build. Drivers are free to handle this specifically, + * but they don't have to. + * + * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned + * when the API is disabled or the "interconnects" DT property is missing. + */ +struct icc_path *of_icc_get(struct device *dev, const char *name) +{ + struct device_node *np; + int idx = 0; + + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + np = dev->of_node; + + /* + * When the consumer DT node do not have "interconnects" property + * return a NULL path to skip setting constraints. + */ + if (!of_find_property(np, "interconnects", NULL)) + return NULL; + + /* + * We use a combination of phandle and specifier for endpoint. For now + * lets support only global ids and extend this in the future if needed + * without breaking DT compatibility. + */ + if (name) { + idx = of_property_match_string(np, "interconnect-names", name); + if (idx < 0) + return ERR_PTR(idx); + } + + return of_icc_get_by_index(dev, idx); +} EXPORT_SYMBOL_GPL(of_icc_get); /** -- cgit v1.2.3-59-g8ed1b From fcb57bfcb87f3bdb1b29fea1a1cd72940fa559fd Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Thu, 29 Aug 2019 13:37:29 +0530 Subject: interconnect: Disallow interconnect core to be built as a module Building individual drivers as modules is fine but allowing a core framework to be built as a module makes it really complex and should be avoided. Whatever uses the interconnect core APIs must also be built as a module if interconnect core is built as module, else we will see compilation failures. If another core framework (like cpufreq, clk, etc), that can't be built as module, needs to use interconnect APIs then we will start seeing compilation failures with allmodconfig configurations as the symbols (like of_icc_get()) used in other frameworks will not be available in the built-in image. Disallow the interconnect core to be built as a module to avoid all these issues. Signed-off-by: Viresh Kumar Reviewed-by: Bjorn Andersson Link: https://lore.kernel.org/r/b789cce388dd1f2906492f307dea6780c398bc6a.1567065991.git.viresh.kumar@linaro.org Signed-off-by: Georgi Djakov --- drivers/interconnect/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig index bfa4ca3ab7a9..b6ea8f0a6122 100644 --- a/drivers/interconnect/Kconfig +++ b/drivers/interconnect/Kconfig @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig INTERCONNECT - tristate "On-Chip Interconnect management support" + bool "On-Chip Interconnect management support" help Support for management of the on-chip interconnects. -- cgit v1.2.3-59-g8ed1b From 8fd3574b54a54e4a33d5a6684df89d64ca812f0b Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Thu, 31 Oct 2019 12:28:52 -0600 Subject: interconnect: Remove unused module exit code from core The interconnect core is currently always built in: menuconfig INTERCONNECT bool "On-Chip Interconnect management support" So remove the module_exit function and symbolically rename module_init to device_initcall to drive home the point. Signed-off-by: Jordan Crouse Reviewed-by: Bjorn Andersson Link: https://lore.kernel.org/r/1572546532-19248-3-git-send-email-jcrouse@codeaurora.org Signed-off-by: Georgi Djakov --- drivers/interconnect/core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index aba5d38ea9d1..2d2e49780511 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -944,12 +944,7 @@ static int __init icc_init(void) return 0; } -static void __exit icc_exit(void) -{ - debugfs_remove_recursive(icc_debugfs_dir); -} -module_init(icc_init); -module_exit(icc_exit); +device_initcall(icc_init); MODULE_AUTHOR("Georgi Djakov "); MODULE_DESCRIPTION("Interconnect Driver Core"); -- cgit v1.2.3-59-g8ed1b