* [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver
@ 2015-09-29 4:56 Shraddha Barke
2015-09-29 4:56 ` [PATCH 2/2] Staging: gdm724x: gdm_mux.c: " Shraddha Barke
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-29 4:56 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Shraddha Barke
Macro module_usb_driver is used for drivers whose init
and exit paths does only register and unregister.Remove
boilerplate code by using module_usb_driver.
Problem found using Coccinelle.
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/staging/gdm724x/gdm_usb.c | 38 +-------------------------------------
1 file changed, 1 insertion(+), 37 deletions(-)
diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
index ed1a12f..3977663 100644
--- a/drivers/staging/gdm724x/gdm_usb.c
+++ b/drivers/staging/gdm724x/gdm_usb.c
@@ -998,43 +998,7 @@ static struct usb_driver gdm_usb_lte_driver = {
.reset_resume = gdm_usb_resume,
};
-static int __init gdm_usb_lte_init(void)
-{
- if (gdm_lte_event_init() < 0) {
- pr_err("error creating event\n");
- return -1;
- }
-
- usb_tx_wq = create_workqueue("usb_tx_wq");
- if (usb_tx_wq == NULL)
- return -1;
-
- usb_rx_wq = create_workqueue("usb_rx_wq");
- if (usb_rx_wq == NULL)
- return -1;
-
- return usb_register(&gdm_usb_lte_driver);
-}
-
-static void __exit gdm_usb_lte_exit(void)
-{
- gdm_lte_event_exit();
-
- usb_deregister(&gdm_usb_lte_driver);
-
- if (usb_tx_wq) {
- flush_workqueue(usb_tx_wq);
- destroy_workqueue(usb_tx_wq);
- }
-
- if (usb_rx_wq) {
- flush_workqueue(usb_rx_wq);
- destroy_workqueue(usb_rx_wq);
- }
-}
-
-module_init(gdm_usb_lte_init);
-module_exit(gdm_usb_lte_exit);
+module_usb_driver(gdm_usb_lte_driver);
MODULE_VERSION(DRIVER_VERSION);
MODULE_DESCRIPTION("GCT LTE USB Device Driver");
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] Staging: gdm724x: gdm_mux.c: Use module_usb_driver
2015-09-29 4:56 [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver Shraddha Barke
@ 2015-09-29 4:56 ` Shraddha Barke
2015-09-29 5:19 ` [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: " Sudip Mukherjee
2015-09-29 5:40 ` Julia Lawall
2 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-29 4:56 UTC (permalink / raw)
To: outreachy-kernel; +Cc: Shraddha Barke
Macro module_usb_driver is used for drivers whose init
and exit paths does only register and unregister. Remove boilerplate code
by using module_usb_driver.
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/staging/gdm724x/gdm_mux.c | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c
index 1cf24e4..7cd9b87 100644
--- a/drivers/staging/gdm724x/gdm_mux.c
+++ b/drivers/staging/gdm724x/gdm_mux.c
@@ -658,34 +658,7 @@ static struct usb_driver gdm_mux_driver = {
.reset_resume = gdm_mux_resume,
};
-static int __init gdm_usb_mux_init(void)
-{
-
- mux_rx_wq = create_workqueue("mux_rx_wq");
- if (mux_rx_wq == NULL) {
- pr_err("work queue create fail\n");
- return -1;
- }
-
- register_lte_tty_driver();
-
- return usb_register(&gdm_mux_driver);
-}
-
-static void __exit gdm_usb_mux_exit(void)
-{
- unregister_lte_tty_driver();
-
- if (mux_rx_wq) {
- flush_workqueue(mux_rx_wq);
- destroy_workqueue(mux_rx_wq);
- }
-
- usb_deregister(&gdm_mux_driver);
-}
-
-module_init(gdm_usb_mux_init);
-module_exit(gdm_usb_mux_exit);
+module_usb_driver(gdm_mux_driver);
MODULE_DESCRIPTION("GCT LTE TTY Device Driver");
MODULE_LICENSE("GPL");
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver
2015-09-29 4:56 [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver Shraddha Barke
2015-09-29 4:56 ` [PATCH 2/2] Staging: gdm724x: gdm_mux.c: " Shraddha Barke
@ 2015-09-29 5:19 ` Sudip Mukherjee
2015-09-29 5:48 ` Shraddha Barke
2015-09-29 5:40 ` Julia Lawall
2 siblings, 1 reply; 6+ messages in thread
From: Sudip Mukherjee @ 2015-09-29 5:19 UTC (permalink / raw)
To: Shraddha Barke; +Cc: outreachy-kernel
On Tue, Sep 29, 2015 at 10:26:48AM +0530, Shraddha Barke wrote:
> Macro module_usb_driver is used for drivers whose init
> and exit paths does only register and unregister.Remove
> boilerplate code by using module_usb_driver.
>
> Problem found using Coccinelle.
>
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
But then how are you going to create the workqueues and
gdm_lte_event_init()?
module_usb_driver() is used in places where the init function is only
having usb_register() and exit function is only having usb_deregister().
If they are doing something special then you can not use
module_usb_driver.
regards
sudip
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver
2015-09-29 4:56 [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver Shraddha Barke
2015-09-29 4:56 ` [PATCH 2/2] Staging: gdm724x: gdm_mux.c: " Shraddha Barke
2015-09-29 5:19 ` [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: " Sudip Mukherjee
@ 2015-09-29 5:40 ` Julia Lawall
2015-09-29 5:55 ` Shraddha Barke
2 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-09-29 5:40 UTC (permalink / raw)
To: Shraddha Barke; +Cc: outreachy-kernel
On Tue, 29 Sep 2015, Shraddha Barke wrote:
> Macro module_usb_driver is used for drivers whose init
> and exit paths does only register and unregister.Remove
> boilerplate code by using module_usb_driver.
>
> Problem found using Coccinelle.
If you find a problem with Coccinelle, please put at least a simplified
version of the semantic patch you used. As Sudip noted, this patch series
is not at allcorrect, and knowing what semantic patch you used could help
suggest where things went wrong.
julia
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> drivers/staging/gdm724x/gdm_usb.c | 38 +-------------------------------------
> 1 file changed, 1 insertion(+), 37 deletions(-)
>
> diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
> index ed1a12f..3977663 100644
> --- a/drivers/staging/gdm724x/gdm_usb.c
> +++ b/drivers/staging/gdm724x/gdm_usb.c
> @@ -998,43 +998,7 @@ static struct usb_driver gdm_usb_lte_driver = {
> .reset_resume = gdm_usb_resume,
> };
>
> -static int __init gdm_usb_lte_init(void)
> -{
> - if (gdm_lte_event_init() < 0) {
> - pr_err("error creating event\n");
> - return -1;
> - }
> -
> - usb_tx_wq = create_workqueue("usb_tx_wq");
> - if (usb_tx_wq == NULL)
> - return -1;
> -
> - usb_rx_wq = create_workqueue("usb_rx_wq");
> - if (usb_rx_wq == NULL)
> - return -1;
> -
> - return usb_register(&gdm_usb_lte_driver);
> -}
> -
> -static void __exit gdm_usb_lte_exit(void)
> -{
> - gdm_lte_event_exit();
> -
> - usb_deregister(&gdm_usb_lte_driver);
> -
> - if (usb_tx_wq) {
> - flush_workqueue(usb_tx_wq);
> - destroy_workqueue(usb_tx_wq);
> - }
> -
> - if (usb_rx_wq) {
> - flush_workqueue(usb_rx_wq);
> - destroy_workqueue(usb_rx_wq);
> - }
> -}
> -
> -module_init(gdm_usb_lte_init);
> -module_exit(gdm_usb_lte_exit);
> +module_usb_driver(gdm_usb_lte_driver);
>
> MODULE_VERSION(DRIVER_VERSION);
> MODULE_DESCRIPTION("GCT LTE USB Device Driver");
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443502609-9918-1-git-send-email-shraddha.6596%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver
2015-09-29 5:19 ` [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: " Sudip Mukherjee
@ 2015-09-29 5:48 ` Shraddha Barke
0 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-29 5:48 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: Shraddha Barke, outreachy-kernel
On Tue, 29 Sep 2015, Sudip Mukherjee wrote:
> On Tue, Sep 29, 2015 at 10:26:48AM +0530, Shraddha Barke wrote:
>> Macro module_usb_driver is used for drivers whose init
>> and exit paths does only register and unregister.Remove
>> boilerplate code by using module_usb_driver.
>>
>> Problem found using Coccinelle.
>>
>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>> ---
> But then how are you going to create the workqueues and
> gdm_lte_event_init()?
> module_usb_driver() is used in places where the init function is only
> having usb_register() and exit function is only having usb_deregister().
> If they are doing something special then you can not use
> module_usb_driver.
Yes. I realised the mistake I made. Since the patch applied to the tree
correctly I made the mistake of thinking the workqueues don't have
significance. I have sent a patch which uses module_i2c_driver. Please
provide feedback on that.
Thanks,
Shraddha
>
> regards
> sudip
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver
2015-09-29 5:40 ` Julia Lawall
@ 2015-09-29 5:55 ` Shraddha Barke
0 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-29 5:55 UTC (permalink / raw)
To: Julia Lawall; +Cc: Shraddha Barke, outreachy-kernel
On Tue, 29 Sep 2015, Julia Lawall wrote:
>
>
> On Tue, 29 Sep 2015, Shraddha Barke wrote:
>
>> Macro module_usb_driver is used for drivers whose init
>> and exit paths does only register and unregister.Remove
>> boilerplate code by using module_usb_driver.
>>
>> Problem found using Coccinelle.
>
> If you find a problem with Coccinelle, please put at least a simplified
> version of the semantic patch you used. As Sudip noted, this patch series
> is not at allcorrect, and knowing what semantic patch you used could help
> suggest where things went wrong.
Yes. I've sent another patch which uses module_i2c_driver. Actually
initially I used Coccinelle to search for all instances of module_init(f)
and module_exit(f) which is why I got these results as well.
>
> julia
>
>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>> ---
>> drivers/staging/gdm724x/gdm_usb.c | 38 +-------------------------------------
>> 1 file changed, 1 insertion(+), 37 deletions(-)
>>
>> diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
>> index ed1a12f..3977663 100644
>> --- a/drivers/staging/gdm724x/gdm_usb.c
>> +++ b/drivers/staging/gdm724x/gdm_usb.c
>> @@ -998,43 +998,7 @@ static struct usb_driver gdm_usb_lte_driver = {
>> .reset_resume = gdm_usb_resume,
>> };
>>
>> -static int __init gdm_usb_lte_init(void)
>> -{
>> - if (gdm_lte_event_init() < 0) {
>> - pr_err("error creating event\n");
>> - return -1;
>> - }
>> -
>> - usb_tx_wq = create_workqueue("usb_tx_wq");
>> - if (usb_tx_wq == NULL)
>> - return -1;
>> -
>> - usb_rx_wq = create_workqueue("usb_rx_wq");
>> - if (usb_rx_wq == NULL)
>> - return -1;
>> -
>> - return usb_register(&gdm_usb_lte_driver);
>> -}
>> -
>> -static void __exit gdm_usb_lte_exit(void)
>> -{
>> - gdm_lte_event_exit();
>> -
>> - usb_deregister(&gdm_usb_lte_driver);
>> -
>> - if (usb_tx_wq) {
>> - flush_workqueue(usb_tx_wq);
>> - destroy_workqueue(usb_tx_wq);
>> - }
>> -
>> - if (usb_rx_wq) {
>> - flush_workqueue(usb_rx_wq);
>> - destroy_workqueue(usb_rx_wq);
>> - }
>> -}
>> -
>> -module_init(gdm_usb_lte_init);
>> -module_exit(gdm_usb_lte_exit);
>> +module_usb_driver(gdm_usb_lte_driver);
>>
>> MODULE_VERSION(DRIVER_VERSION);
>> MODULE_DESCRIPTION("GCT LTE USB Device Driver");
>> --
>> 2.1.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443502609-9918-1-git-send-email-shraddha.6596%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-09-29 5:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29 4:56 [PATCH 1/2] Staging: gdm724x: gdm_usb.c: Use module_usb_driver Shraddha Barke
2015-09-29 4:56 ` [PATCH 2/2] Staging: gdm724x: gdm_mux.c: " Shraddha Barke
2015-09-29 5:19 ` [Outreachy kernel] [PATCH 1/2] Staging: gdm724x: gdm_usb.c: " Sudip Mukherjee
2015-09-29 5:48 ` Shraddha Barke
2015-09-29 5:40 ` Julia Lawall
2015-09-29 5:55 ` Shraddha Barke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.