]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
interconnect: Add devm_of_icc_get_by_index() as exported API for users
authorLuca Weiss <luca.weiss@fairphone.com>
Fri, 1 May 2026 09:18:29 +0000 (11:18 +0200)
committerBjorn Andersson <andersson@kernel.org>
Sun, 7 Jun 2026 00:51:14 +0000 (19:51 -0500)
Users can use devm version of of_icc_get_by_index() to benefit from
automatic resource release.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Acked-by: Georgi Djakov <djakov@kernel.org>
Link: https://lore.kernel.org/r/20260501-milos-camcc-icc-v2-1-bb83c1256cc3@fairphone.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
drivers/interconnect/core.c
include/linux/interconnect.h

index 8569b78a18517b33abeafac091978b25cbc1acc7..bc2e416dbcb272741f1138865a1cdf3c92d7d961 100644 (file)
@@ -443,6 +443,26 @@ struct icc_path *devm_of_icc_get(struct device *dev, const char *name)
 }
 EXPORT_SYMBOL_GPL(devm_of_icc_get);
 
+struct icc_path *devm_of_icc_get_by_index(struct device *dev, int idx)
+{
+       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_by_index(dev, idx);
+       if (!IS_ERR(path)) {
+               *ptr = path;
+               devres_add(dev, ptr);
+       } else {
+               devres_free(ptr);
+       }
+
+       return path;
+}
+EXPORT_SYMBOL_GPL(devm_of_icc_get_by_index);
+
 /**
  * of_icc_get_by_index() - get a path handle from a DT node based on index
  * @dev: device pointer for the consumer device
index 4b12821528a6b960f649eb713e1ae41dd9a9d981..75a32ad0482e2368de6bceef4ef795a7da775bc8 100644 (file)
@@ -47,6 +47,7 @@ struct icc_path *of_icc_get(struct device *dev, const char *name);
 struct icc_path *devm_of_icc_get(struct device *dev, const char *name);
 int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths);
 struct icc_path *of_icc_get_by_index(struct device *dev, int idx);
+struct icc_path *devm_of_icc_get_by_index(struct device *dev, int idx);
 void icc_put(struct icc_path *path);
 int icc_enable(struct icc_path *path);
 int icc_disable(struct icc_path *path);
@@ -79,6 +80,11 @@ static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
        return NULL;
 }
 
+static inline struct icc_path *devm_of_icc_get_by_index(struct device *dev, int idx)
+{
+       return NULL;
+}
+
 static inline void icc_put(struct icc_path *path)
 {
 }