1
2
3#include <linux/interconnect-provider.h>
4#include <linux/device.h>
5#include <linux/export.h>
6
7
8
9
10
11
12
13
14
15int __must_check of_icc_bulk_get(struct device *dev, int num_paths,
16 struct icc_bulk_data *paths)
17{
18 int ret, i;
19
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",
26 paths[i].name, ret);
27 paths[i].path = NULL;
28 goto err;
29 }
30 }
31
32 return 0;
33
34err:
35 icc_bulk_put(i, paths);
36
37 return ret;
38}
39EXPORT_SYMBOL_GPL(of_icc_bulk_get);
40
41
42
43
44
45
46void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
47{
48 while (--num_paths >= 0) {
49 icc_put(paths[num_paths].path);
50 paths[num_paths].path = NULL;
51 }
52}
53EXPORT_SYMBOL_GPL(icc_bulk_put);
54
55
56
57
58
59
60
61
62int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths)
63{
64 int ret = 0;
65 int i;
66
67 for (i = 0; i < num_paths; i++) {
68 ret = icc_set_bw(paths[i].path, paths[i].avg_bw, paths[i].peak_bw);
69 if (ret) {
70 pr_err("icc_set_bw() failed on path %s (%d)\n", paths[i].name, ret);
71 return ret;
72 }
73 }
74
75 return ret;
76}
77EXPORT_SYMBOL_GPL(icc_bulk_set_bw);
78
79
80
81
82
83
84
85
86int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths)
87{
88 int ret, i;
89
90 for (i = 0; i < num_paths; i++) {
91 ret = icc_enable(paths[i].path);
92 if (ret) {
93 pr_err("icc_enable() failed on path %s (%d)\n", paths[i].name, ret);
94 goto err;
95 }
96 }
97
98 return 0;
99
100err:
101 icc_bulk_disable(i, paths);
102
103 return ret;
104}
105EXPORT_SYMBOL_GPL(icc_bulk_enable);
106
107
108
109
110
111
112void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
113{
114 while (--num_paths >= 0)
115 icc_disable(paths[num_paths].path);
116}
117EXPORT_SYMBOL_GPL(icc_bulk_disable);
118