aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing
diff options
context:
space:
mode:
authorLeo Yan <leo.yan@linaro.org>2017-06-05 16:15:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-06-09 05:45:25 -0400
commitc56cdd7a5c836db7834256f09692112afee9eb3f (patch)
treecf4101a2b1aa2a44ce2f17949ecb080c71884fec /drivers/hwtracing
parent04c9490035691a398d851fd160ce8af08ba0af0d (diff)
coresight: refactor with function of_coresight_get_cpu
This is refactor to add function of_coresight_get_cpu(), so it's used to retrieve CPU id for coresight component. Finally can use it as a common function for multiple places. Suggested-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r--drivers/hwtracing/coresight/of_coresight.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c
index 225b2dd5970c..a18794128bf8 100644
--- a/drivers/hwtracing/coresight/of_coresight.c
+++ b/drivers/hwtracing/coresight/of_coresight.c
@@ -101,16 +101,40 @@ static int of_coresight_alloc_memory(struct device *dev,
101 return 0; 101 return 0;
102} 102}
103 103
104int of_coresight_get_cpu(const struct device_node *node)
105{
106 int cpu;
107 bool found;
108 struct device_node *dn, *np;
109
110 dn = of_parse_phandle(node, "cpu", 0);
111
112 /* Affinity defaults to CPU0 */
113 if (!dn)
114 return 0;
115
116 for_each_possible_cpu(cpu) {
117 np = of_cpu_device_node_get(cpu);
118 found = (dn == np);
119 of_node_put(np);
120 if (found)
121 break;
122 }
123 of_node_put(dn);
124
125 /* Affinity to CPU0 if no cpu nodes are found */
126 return found ? cpu : 0;
127}
128EXPORT_SYMBOL_GPL(of_coresight_get_cpu);
129
104struct coresight_platform_data * 130struct coresight_platform_data *
105of_get_coresight_platform_data(struct device *dev, 131of_get_coresight_platform_data(struct device *dev,
106 const struct device_node *node) 132 const struct device_node *node)
107{ 133{
108 int i = 0, ret = 0, cpu; 134 int i = 0, ret = 0;
109 struct coresight_platform_data *pdata; 135 struct coresight_platform_data *pdata;
110 struct of_endpoint endpoint, rendpoint; 136 struct of_endpoint endpoint, rendpoint;
111 struct device *rdev; 137 struct device *rdev;
112 bool found;
113 struct device_node *dn, *np;
114 struct device_node *ep = NULL; 138 struct device_node *ep = NULL;
115 struct device_node *rparent = NULL; 139 struct device_node *rparent = NULL;
116 struct device_node *rport = NULL; 140 struct device_node *rport = NULL;
@@ -177,18 +201,7 @@ of_get_coresight_platform_data(struct device *dev,
177 } while (ep); 201 } while (ep);
178 } 202 }
179 203
180 dn = of_parse_phandle(node, "cpu", 0); 204 pdata->cpu = of_coresight_get_cpu(node);
181 for_each_possible_cpu(cpu) {
182 np = of_cpu_device_node_get(cpu);
183 found = (dn == np);
184 of_node_put(np);
185 if (found)
186 break;
187 }
188 of_node_put(dn);
189
190 /* Affinity to CPU0 if no cpu nodes are found */
191 pdata->cpu = found ? cpu : 0;
192 205
193 return pdata; 206 return pdata;
194} 207}