| @@ -151,12 +151,14 @@ static void of_coresight_get_ports(const struct device_node *node, · 150 unmodified lines |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | | −int of_coresight_get_cpu(const struct device_node *node) |
| 154 | +static int of_coresight_get_cpu(struct device *dev) |
| 155 | 155 | { |
| 156 | 156 | int cpu; |
| 157 | 157 | struct device_node *dn; |
| 158 | 158 | |
| 159 | | − dn = of_parse_phandle(node, "cpu", 0); |
| 159 | + if (!dev->of_node) |
| 160 | + return 0; |
| 161 | + dn = of_parse_phandle(dev->of_node, "cpu", 0); |
| 160 | 162 | /* Affinity defaults to CPU0 */ |
| 161 | 163 | if (!dn) |
| 162 | 164 | return 0; |
| @@ -166,7 +168,6 @@ int of_coresight_get_cpu(const struct device_node *node) · 3 unmodified lines |
| 166 | 168 | /* Affinity to CPU0 if no cpu nodes are found */ |
| 167 | 169 | return (cpu < 0) ? 0 : cpu; |
| 168 | 170 | } |
| 169 | | −EXPORT_SYMBOL_GPL(of_coresight_get_cpu); |
| 170 | 171 | |
| 171 | 172 | /* |
| 172 | 173 | * of_coresight_parse_endpoint : Parse the given output endpoint @ep |
| @@ -240,8 +241,6 @@ static int of_get_coresight_platform_data(struct device *dev, · 67 unmodified lines |
| 240 | 241 | bool legacy_binding = false; |
| 241 | 242 | struct device_node *node = dev->of_node; |
| 242 | 243 | |
| 243 | | − pdata->cpu = of_coresight_get_cpu(node); |
| 244 | | − |
| 245 | 244 | /* Get the number of input and output port for this component */ |
| 246 | 245 | of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport); |
| 247 | 246 | |
| @@ -300,6 +299,14 @@ of_get_coresight_platform_data(struct device *dev, · 52 unmodified lines |
| 300 | 299 | } |
| 301 | 300 | #endif |
| 302 | 301 | |
| 302 | +int coresight_get_cpu(struct device *dev) |
| 303 | +{ |
| 304 | + if (is_of_node(dev->fwnode)) |
| 305 | + return of_coresight_get_cpu(dev); |
| 306 | + return 0; |
| 307 | +} |
| 308 | +EXPORT_SYMBOL_GPL(coresight_get_cpu); |
| 309 | + |
| 303 | 310 | struct coresight_platform_data * |
| 304 | 311 | coresight_get_platform_data(struct device *dev) |
| 305 | 312 | { |
| @@ -318,6 +325,7 @@ coresight_get_platform_data(struct device *dev) · 12 unmodified lines |
| 318 | 325 | |
| 319 | 326 | /* Use device name as sysfs handle */ |
| 320 | 327 | pdata->name = dev_name(dev); |
| 328 | + pdata->cpu = coresight_get_cpu(dev); |
| 321 | 329 | |
| 322 | 330 | if (is_of_node(fwnode)) |
| 323 | 331 | ret = of_get_coresight_platform_data(dev, pdata); |