History

coresight: Make device to CPU mapping generic

The CoreSight components ETM and CPU-Debug are always associated with CPUs. Replace the of_coresight_get_cpu() with a platform agnostic helper, in preparation to add ACPI support.

Suzuki K Poulose committed 7 years ago

Commit 91824db1 parent f03631d3 files · +15 −13Browse files

Unified · Split

3 files
  1. drivers/hwtracing/coresight/coresight-cpu-debug.c +1 −2
  2. drivers/hwtracing/coresight/coresight-platform.c +13 −5
  3. include/linux/coresight.h +1 −6
drivers/hwtracing/coresight/coresight-cpu-debug.c+1−2
@@ -572,14 +572,13 @@ static int debug_probe(struct amba_device *adev, const struct amba_id *id) · 571 unmodified lines
572572 struct device *dev = &adev->dev;
573573 struct debug_drvdata *drvdata;
574574 struct resource *res = &adev->res;
575− struct device_node *np = adev->dev.of_node;
576575 int ret;
577576
578577 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
579578 if (!drvdata)
580579 return -ENOMEM;
581580
582− drvdata->cpu = np ? of_coresight_get_cpu(np) : 0;
581+ drvdata->cpu = coresight_get_cpu(dev);
583582 if (per_cpu(debug_drvdata, drvdata->cpu)) {
584583 dev_err(dev, "CPU%d drvdata has already been initialized\n",
585584 drvdata->cpu);
drivers/hwtracing/coresight/coresight-platform.c+13−5
@@ -151,12 +151,14 @@ static void of_coresight_get_ports(const struct device_node *node, · 150 unmodified lines
151151 }
152152 }
153153
154−int of_coresight_get_cpu(const struct device_node *node)
154+static int of_coresight_get_cpu(struct device *dev)
155155 {
156156 int cpu;
157157 struct device_node *dn;
158158
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);
160162 /* Affinity defaults to CPU0 */
161163 if (!dn)
162164 return 0;
@@ -166,7 +168,6 @@ int of_coresight_get_cpu(const struct device_node *node) · 3 unmodified lines
166168 /* Affinity to CPU0 if no cpu nodes are found */
167169 return (cpu < 0) ? 0 : cpu;
168170 }
169−EXPORT_SYMBOL_GPL(of_coresight_get_cpu);
170171
171172 /*
172173 * 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
240241 bool legacy_binding = false;
241242 struct device_node *node = dev->of_node;
242243
243− pdata->cpu = of_coresight_get_cpu(node);
244−
245244 /* Get the number of input and output port for this component */
246245 of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport);
247246
@@ -300,6 +299,14 @@ of_get_coresight_platform_data(struct device *dev, · 52 unmodified lines
300299 }
301300 #endif
302301
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+
303310 struct coresight_platform_data *
304311 coresight_get_platform_data(struct device *dev)
305312 {
@@ -318,6 +325,7 @@ coresight_get_platform_data(struct device *dev) · 12 unmodified lines
318325
319326 /* Use device name as sysfs handle */
320327 pdata->name = dev_name(dev);
328+ pdata->cpu = coresight_get_cpu(dev);
321329
322330 if (is_of_node(fwnode))
323331 ret = of_get_coresight_platform_data(dev, pdata);
include/linux/coresight.h+1−6
@@ -292,12 +292,7 @@ static inline void coresight_disclaim_device_unlocked(void __iomem *base) {} · 291 unmodified lines
292292
293293 #endif
294294
295−#ifdef CONFIG_OF
296−extern int of_coresight_get_cpu(const struct device_node *node);
297−#else
298−static inline int of_coresight_get_cpu(const struct device_node *node)
299−{ return 0; }
300−#endif
295+extern int coresight_get_cpu(struct device *dev);
301296
302297 struct coresight_platform_data *coresight_get_platform_data(struct device *dev);
303298

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t