[PATCH RFC 02/15] coresight: remove multiple init calls from funnel driver

From: Mian Yousaf Kaukab
Date: Fri Jan 17 2020 - 09:39:50 EST


Dynamic-funnel uses module_amba_driver to register. Whereas
static-funnel uses builtin_platform_driver. Combine these init calls
into a single module_init/exit pair in preparation to make the driver
modular.

Signed-off-by: Mian Yousaf Kaukab <ykaukab@xxxxxxx>
---
drivers/hwtracing/coresight/coresight-funnel.c | 30 ++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index 08d8f2b3565f..32cbf112ae34 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -342,7 +342,6 @@ static struct platform_driver static_funnel_driver = {
.suppress_bind_attrs = true,
},
};
-builtin_platform_driver(static_funnel_driver);

static int dynamic_funnel_probe(struct amba_device *adev,
const struct amba_id *id)
@@ -373,7 +372,34 @@ static struct amba_driver dynamic_funnel_driver = {
.probe = dynamic_funnel_probe,
.id_table = dynamic_funnel_ids,
};
-module_amba_driver(dynamic_funnel_driver);
+
+static int __init funnel_init(void)
+{
+ int ret;
+
+ ret = platform_driver_register(&static_funnel_driver);
+ if (ret) {
+ pr_info("Error registering platform driver\n");
+ return ret;
+ }
+
+ ret = amba_driver_register(&dynamic_funnel_driver);
+ if (ret) {
+ pr_info("Error registering amba driver\n");
+ platform_driver_unregister(&static_funnel_driver);
+ }
+
+ return ret;
+}
+
+static void __exit funnel_exit(void)
+{
+ platform_driver_unregister(&static_funnel_driver);
+ amba_driver_unregister(&dynamic_funnel_driver);
+}
+
+module_init(funnel_init);
+module_exit(funnel_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("CoreSight Funnel driver");
--
2.16.4