Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

interconnect: add device managed bulk API

Add device managed bulk API to simplify driver.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/20220703091132.1412063-4-peng.fan@oss.nxp.com
Signed-off-by: Georgi Djakov <djakov@kernel.org>

authored by

Peng Fan and committed by
Georgi Djakov
2fcfa72f e2a4a0ee

+49
+42
drivers/interconnect/bulk.c
··· 115 115 icc_disable(paths[num_paths].path); 116 116 } 117 117 EXPORT_SYMBOL_GPL(icc_bulk_disable); 118 + 119 + struct icc_bulk_devres { 120 + struct icc_bulk_data *paths; 121 + int num_paths; 122 + }; 123 + 124 + static void devm_icc_bulk_release(struct device *dev, void *res) 125 + { 126 + struct icc_bulk_devres *devres = res; 127 + 128 + icc_bulk_put(devres->num_paths, devres->paths); 129 + } 130 + 131 + /** 132 + * devm_of_icc_bulk_get() - resource managed of_icc_bulk_get 133 + * @dev: the device requesting the path 134 + * @num_paths: the number of icc_bulk_data 135 + * @paths: the table with the paths we want to get 136 + * 137 + * Returns 0 on success or negative errno otherwise. 138 + */ 139 + int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths) 140 + { 141 + struct icc_bulk_devres *devres; 142 + int ret; 143 + 144 + devres = devres_alloc(devm_icc_bulk_release, sizeof(*devres), GFP_KERNEL); 145 + if (!devres) 146 + return -ENOMEM; 147 + 148 + ret = of_icc_bulk_get(dev, num_paths, paths); 149 + if (!ret) { 150 + devres->paths = paths; 151 + devres->num_paths = num_paths; 152 + devres_add(dev, devres); 153 + } else { 154 + devres_free(devres); 155 + } 156 + 157 + return ret; 158 + } 159 + EXPORT_SYMBOL_GPL(devm_of_icc_bulk_get);
+7
include/linux/interconnect.h
··· 44 44 const int dst_id); 45 45 struct icc_path *of_icc_get(struct device *dev, const char *name); 46 46 struct icc_path *devm_of_icc_get(struct device *dev, const char *name); 47 + int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths); 47 48 struct icc_path *of_icc_get_by_index(struct device *dev, int idx); 48 49 void icc_put(struct icc_path *path); 49 50 int icc_enable(struct icc_path *path); ··· 113 112 } 114 113 115 114 static inline int of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths) 115 + { 116 + return 0; 117 + } 118 + 119 + static inline int devm_of_icc_bulk_get(struct device *dev, int num_paths, 120 + struct icc_bulk_data *paths) 116 121 { 117 122 return 0; 118 123 }