diff options
author | Akash Asthana <akashast@codeaurora.org> | 2020-04-15 15:53:10 +0530 |
---|---|---|
committer | Georgi Djakov <georgi.djakov@linaro.org> | 2020-04-27 21:44:33 +0300 |
commit | e145d9a184f23639edc864e2fa08fcc1853361a4 (patch) | |
tree | 5426d21b7f67c133cb2c5151879a2f146c00496b /drivers/interconnect/core.c | |
parent | 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c (diff) | |
download | linux-stable-e145d9a184f23639edc864e2fa08fcc1853361a4.tar.gz linux-stable-e145d9a184f23639edc864e2fa08fcc1853361a4.tar.bz2 linux-stable-e145d9a184f23639edc864e2fa08fcc1853361a4.zip |
interconnect: Add devm_of_icc_get() as exported API for users
Users can use devm version of of_icc_get() to benefit from automatic
resource release.
Signed-off-by: Akash Asthana <akashast@codeaurora.org>
Reviewed by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/1586946198-13912-2-git-send-email-akashast@codeaurora.org
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Diffstat (limited to 'drivers/interconnect/core.c')
-rw-r--r-- | drivers/interconnect/core.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 2c6515e3ecf1..f5699ed34e43 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -350,6 +350,31 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec) return node; } +static void devm_icc_release(struct device *dev, void *res) +{ + icc_put(*(struct icc_path **)res); +} + +struct icc_path *devm_of_icc_get(struct device *dev, const char *name) +{ + struct icc_path **ptr, *path; + + ptr = devres_alloc(devm_icc_release, sizeof(**ptr), GFP_KERNEL); + if (!ptr) + return ERR_PTR(-ENOMEM); + + path = of_icc_get(dev, name); + if (!IS_ERR(path)) { + *ptr = path; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return path; +} +EXPORT_SYMBOL_GPL(devm_of_icc_get); + /** * of_icc_get() - get a path handle from a DT node based on name * @dev: device pointer for the consumer device |