* [PATCH] coresight: replicator: Use module_platform_driver
@ 2015-07-07 5:26 Vaishali Thakkar
2015-07-08 14:27 ` Mathieu Poirier
0 siblings, 1 reply; 2+ messages in thread
From: Vaishali Thakkar @ 2015-07-07 5:26 UTC (permalink / raw)
To: linux-arm-kernel
Use module_platform_driver for drivers whose init and exit functions
only register and unregister, respectively.
A simplified version of the Coccinelle semantic patch that performs
this transformation is as follows:
@a@
identifier f, x;
@@
-static f(...) { return platform_driver_register(&x); }
@b depends on a@
identifier e, a.x;
@@
-static e(...) { platform_driver_unregister(&x); }
@c depends on a && b@
identifier a.f;
declarer name module_init;
@@
-module_init(f);
@d depends on a && b && c@
identifier b.e, a.x;
declarer name module_exit;
declarer name module_platform_driver;
@@
-module_exit(e);
+module_platform_driver(x);
Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
---
drivers/hwtracing/coresight/coresight-replicator.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index 7974b7c..df45932 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -183,18 +183,7 @@ static struct platform_driver replicator_driver = {
.pm = &replicator_dev_pm_ops,
},
};
-
-static int __init replicator_init(void)
-{
- return platform_driver_register(&replicator_driver);
-}
-module_init(replicator_init);
-
-static void __exit replicator_exit(void)
-{
- platform_driver_unregister(&replicator_driver);
-}
-module_exit(replicator_exit);
+module_platform_driver(replicator_driver);
MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("CoreSight Replicator driver");
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] coresight: replicator: Use module_platform_driver
2015-07-07 5:26 [PATCH] coresight: replicator: Use module_platform_driver Vaishali Thakkar
@ 2015-07-08 14:27 ` Mathieu Poirier
0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Poirier @ 2015-07-08 14:27 UTC (permalink / raw)
To: linux-arm-kernel
On 6 July 2015 at 23:26, Vaishali Thakkar <vthakkar1994@gmail.com> wrote:
> Use module_platform_driver for drivers whose init and exit functions
> only register and unregister, respectively.
>
> A simplified version of the Coccinelle semantic patch that performs
> this transformation is as follows:
>
> @a@
> identifier f, x;
> @@
> -static f(...) { return platform_driver_register(&x); }
>
> @b depends on a@
> identifier e, a.x;
> @@
> -static e(...) { platform_driver_unregister(&x); }
>
> @c depends on a && b@
> identifier a.f;
> declarer name module_init;
> @@
> -module_init(f);
>
> @d depends on a && b && c@
> identifier b.e, a.x;
> declarer name module_exit;
> declarer name module_platform_driver;
> @@
> -module_exit(e);
> +module_platform_driver(x);
>
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> ---
> drivers/hwtracing/coresight/coresight-replicator.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
> index 7974b7c..df45932 100644
> --- a/drivers/hwtracing/coresight/coresight-replicator.c
> +++ b/drivers/hwtracing/coresight/coresight-replicator.c
> @@ -183,18 +183,7 @@ static struct platform_driver replicator_driver = {
> .pm = &replicator_dev_pm_ops,
> },
> };
> -
> -static int __init replicator_init(void)
> -{
> - return platform_driver_register(&replicator_driver);
> -}
> -module_init(replicator_init);
> -
> -static void __exit replicator_exit(void)
> -{
> - platform_driver_unregister(&replicator_driver);
> -}
> -module_exit(replicator_exit);
> +module_platform_driver(replicator_driver);
>
> MODULE_LICENSE("GPL v2");
> MODULE_DESCRIPTION("CoreSight Replicator driver");
> --
> 1.9.1
>
I agree with this patch but please remove the comment about Coccinelle
in the commit log (along with the code) and add a newline before
module_platform_driver().
Thanks,
Mathieu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-08 14:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07 5:26 [PATCH] coresight: replicator: Use module_platform_driver Vaishali Thakkar
2015-07-08 14:27 ` Mathieu Poirier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox