2020-01-17 14:41:32

by Yousaf Kaukab

[permalink] [raw]
Subject: [PATCH RFC 06/15] coresight: combine bus and PMU init calls

There is no need to initialize coresight bus at postcore level since
coresight API is private now. Moreover, call etm_perf_init() from
coresight_init() to combine bus and PMU into a single module. There
are circular dependencies between them.

Signed-off-by: Mian Yousaf Kaukab <[email protected]>
---
drivers/hwtracing/coresight/coresight-bus.c | 41 ++++++++++++++++++------
drivers/hwtracing/coresight/coresight-etm-perf.c | 3 +-
drivers/hwtracing/coresight/coresight-etm-perf.h | 2 ++
3 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-bus.c b/drivers/hwtracing/coresight/coresight-bus.c
index ef20f74c85fa..c2eaeeea98cd 100644
--- a/drivers/hwtracing/coresight/coresight-bus.c
+++ b/drivers/hwtracing/coresight/coresight-bus.c
@@ -1142,16 +1142,6 @@ int coresight_timeout(void __iomem *addr, u32 offset, int position, int value)
return -EAGAIN;
}

-struct bus_type coresight_bustype = {
- .name = "coresight",
-};
-
-static int __init coresight_init(void)
-{
- return bus_register(&coresight_bustype);
-}
-postcore_initcall(coresight_init);
-
/*
* coresight_release_platform_data: Release references to the devices connected
* to the output port of this device.
@@ -1336,3 +1326,34 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict,
return name;
}
EXPORT_SYMBOL_GPL(coresight_alloc_device_name);
+
+struct bus_type coresight_bustype = {
+ .name = "coresight",
+};
+
+static int __init coresight_init(void)
+{
+ int ret;
+
+ ret = bus_register(&coresight_bustype);
+ if (ret)
+ return ret;
+
+ ret = etm_perf_init();
+ if (ret)
+ bus_unregister(&coresight_bustype);
+
+ return ret;
+}
+
+static void __exit coresight_exit(void)
+{
+ /* TODO: perf_pmu_unregister() */
+ bus_unregister(&coresight_bustype);
+}
+
+module_init(coresight_init);
+module_exit(coresight_exit);
+
+MODULE_DESCRIPTION("Coresight bus and pmu driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 84f1dcb69827..1bd71c2f6802 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -579,7 +579,7 @@ void etm_perf_del_symlink_sink(struct coresight_device *csdev)
csdev->ea = NULL;
}

-static int __init etm_perf_init(void)
+int __init etm_perf_init(void)
{
int ret;

@@ -606,4 +606,3 @@ static int __init etm_perf_init(void)

return ret;
}
-device_initcall(etm_perf_init);
diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h
index 015213abe00a..4b1c1f55fb46 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.h
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.h
@@ -82,4 +82,6 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle)

#endif /* CONFIG_CORESIGHT */

+int __init etm_perf_init(void);
+
#endif
--
2.16.4