1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/interconnect-provider.h>
4 #include <linux/device.h>
5 #include <linux/export.h>
8 * of_icc_bulk_get() - get interconnect paths
9 * @dev: the device requesting the path
10 * @num_paths: the number of icc_bulk_data
11 * @paths: the table with the paths we want to get
13 * Returns 0 on success or negative errno otherwise.
15 int __must_check of_icc_bulk_get(struct device *dev, int num_paths,
16 struct icc_bulk_data *paths)
20 for (i = 0; i < num_paths; i++) {
21 paths[i].path = of_icc_get(dev, paths[i].name);
22 if (IS_ERR(paths[i].path)) {
23 ret = PTR_ERR(paths[i].path);
24 if (ret != -EPROBE_DEFER)
25 dev_err(dev, "of_icc_get() failed on path %s (%d)\n",
35 icc_bulk_put(i, paths);
39 EXPORT_SYMBOL_GPL(of_icc_bulk_get);
42 * icc_bulk_put() - put a list of interconnect paths
43 * @num_paths: the number of icc_bulk_data
44 * @paths: the icc_bulk_data table with the paths being put
46 void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
48 while (--num_paths >= 0) {
49 icc_put(paths[num_paths].path);
50 paths[num_paths].path = NULL;
53 EXPORT_SYMBOL_GPL(icc_bulk_put);
56 * icc_bulk_set_bw() - set bandwidth to a set of paths
57 * @num_paths: the number of icc_bulk_data
58 * @paths: the icc_bulk_data table containing the paths and bandwidth
60 * Returns 0 on success or negative errno otherwise.
62 int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths)
67 for (i = 0; i < num_paths; i++) {
68 ret = icc_set_bw(paths[i].path, paths[i].avg_bw, paths[i].peak_bw);
70 pr_err("icc_set_bw() failed on path %s (%d)\n", paths[i].name, ret);
77 EXPORT_SYMBOL_GPL(icc_bulk_set_bw);
80 * icc_bulk_enable() - enable a previously disabled set of paths
81 * @num_paths: the number of icc_bulk_data
82 * @paths: the icc_bulk_data table containing the paths and bandwidth
84 * Returns 0 on success or negative errno otherwise.
86 int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths)
90 for (i = 0; i < num_paths; i++) {
91 ret = icc_enable(paths[i].path);
93 pr_err("icc_enable() failed on path %s (%d)\n", paths[i].name, ret);
101 icc_bulk_disable(i, paths);
105 EXPORT_SYMBOL_GPL(icc_bulk_enable);
108 * icc_bulk_disable() - disable a set of interconnect paths
109 * @num_paths: the number of icc_bulk_data
110 * @paths: the icc_bulk_data table containing the paths and bandwidth
112 void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
114 while (--num_paths >= 0)
115 icc_disable(paths[num_paths].path);
117 EXPORT_SYMBOL_GPL(icc_bulk_disable);