All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: storage: Replace mdelay with msleep in init_freecom
@ 2018-04-10  1:29 ` Jia-Ju Bai
  0 siblings, 0 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2018-04-10  1:29 UTC (permalink / raw)
  To: stern, gregkh; +Cc: linux-usb, usb-storage, linux-kernel, Jia-Ju Bai

init_freecom() is never called in atomic context.

init_freecom() is set as ".initFunction" through UNUSUAL_DEV().
And ->initFunction() is only called by usb_stor_acquire_resources(), 
which is only called by usb_stor_probe2().
usb_stor_probe2() is called by *_probe() functions (like alauda_probe()) 
for each USB driver.
*_probe() functions are set ".probe" in struct usb_driver.
These functions are not called in atomic context.

Despite never getting called from atomic context, init_freecom()
calls mdelay() to busily wait.
This is not necessary and can be replaced with msleep() to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
 drivers/usb/storage/freecom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index c0a5d95..c7f886d 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -477,7 +477,7 @@ static int init_freecom(struct us_data *us)
 	usb_stor_dbg(us, "result from activate reset is %d\n", result);
 
 	/* wait 250ms */
-	mdelay(250);
+	msleep(250);
 
 	/* clear reset */
 	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
@@ -485,7 +485,7 @@ static int init_freecom(struct us_data *us)
 	usb_stor_dbg(us, "result from clear reset is %d\n", result);
 
 	/* wait 3 seconds */
-	mdelay(3 * 1000);
+	msleep(3 * 1000);
 
 	return USB_STOR_TRANSPORT_GOOD;
 }
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* usb: storage: Replace mdelay with msleep in init_freecom
@ 2018-04-10  1:29 ` Jia-Ju Bai
  0 siblings, 0 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2018-04-10  1:29 UTC (permalink / raw)
  To: stern, gregkh; +Cc: linux-usb, usb-storage, linux-kernel, Jia-Ju Bai

init_freecom() is never called in atomic context.

init_freecom() is set as ".initFunction" through UNUSUAL_DEV().
And ->initFunction() is only called by usb_stor_acquire_resources(), 
which is only called by usb_stor_probe2().
usb_stor_probe2() is called by *_probe() functions (like alauda_probe()) 
for each USB driver.
*_probe() functions are set ".probe" in struct usb_driver.
These functions are not called in atomic context.

Despite never getting called from atomic context, init_freecom()
calls mdelay() to busily wait.
This is not necessary and can be replaced with msleep() to
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.
And I also manually check it.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 drivers/usb/storage/freecom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
index c0a5d95..c7f886d 100644
--- a/drivers/usb/storage/freecom.c
+++ b/drivers/usb/storage/freecom.c
@@ -477,7 +477,7 @@ static int init_freecom(struct us_data *us)
 	usb_stor_dbg(us, "result from activate reset is %d\n", result);
 
 	/* wait 250ms */
-	mdelay(250);
+	msleep(250);
 
 	/* clear reset */
 	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
@@ -485,7 +485,7 @@ static int init_freecom(struct us_data *us)
 	usb_stor_dbg(us, "result from clear reset is %d\n", result);
 
 	/* wait 3 seconds */
-	mdelay(3 * 1000);
+	msleep(3 * 1000);
 
 	return USB_STOR_TRANSPORT_GOOD;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: storage: Replace mdelay with msleep in init_freecom
@ 2018-04-10 14:15   ` Alan Stern
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2018-04-10 14:15 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: gregkh, linux-usb, usb-storage, linux-kernel

On Tue, 10 Apr 2018, Jia-Ju Bai wrote:

> init_freecom() is never called in atomic context.
> 
> init_freecom() is set as ".initFunction" through UNUSUAL_DEV().
> And ->initFunction() is only called by usb_stor_acquire_resources(), 
> which is only called by usb_stor_probe2().
> usb_stor_probe2() is called by *_probe() functions (like alauda_probe()) 
> for each USB driver.
> *_probe() functions are set ".probe" in struct usb_driver.
> These functions are not called in atomic context.
> 
> Despite never getting called from atomic context, init_freecom()
> calls mdelay() to busily wait.
> This is not necessary and can be replaced with msleep() to
> avoid busy waiting.
> 
> This is found by a static analysis tool named DCNS written by myself.
> And I also manually check it.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>

Acked-by: Alan Stern <stern@rowland.harvard.edu>


> ---
>  drivers/usb/storage/freecom.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
> index c0a5d95..c7f886d 100644
> --- a/drivers/usb/storage/freecom.c
> +++ b/drivers/usb/storage/freecom.c
> @@ -477,7 +477,7 @@ static int init_freecom(struct us_data *us)
>  	usb_stor_dbg(us, "result from activate reset is %d\n", result);
>  
>  	/* wait 250ms */
> -	mdelay(250);
> +	msleep(250);
>  
>  	/* clear reset */
>  	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
> @@ -485,7 +485,7 @@ static int init_freecom(struct us_data *us)
>  	usb_stor_dbg(us, "result from clear reset is %d\n", result);
>  
>  	/* wait 3 seconds */
> -	mdelay(3 * 1000);
> +	msleep(3 * 1000);
>  
>  	return USB_STOR_TRANSPORT_GOOD;
>  }
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* usb: storage: Replace mdelay with msleep in init_freecom
@ 2018-04-10 14:15   ` Alan Stern
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2018-04-10 14:15 UTC (permalink / raw)
  To: Jia-Ju Bai; +Cc: gregkh, linux-usb, usb-storage, linux-kernel

On Tue, 10 Apr 2018, Jia-Ju Bai wrote:

> init_freecom() is never called in atomic context.
> 
> init_freecom() is set as ".initFunction" through UNUSUAL_DEV().
> And ->initFunction() is only called by usb_stor_acquire_resources(), 
> which is only called by usb_stor_probe2().
> usb_stor_probe2() is called by *_probe() functions (like alauda_probe()) 
> for each USB driver.
> *_probe() functions are set ".probe" in struct usb_driver.
> These functions are not called in atomic context.
> 
> Despite never getting called from atomic context, init_freecom()
> calls mdelay() to busily wait.
> This is not necessary and can be replaced with msleep() to
> avoid busy waiting.
> 
> This is found by a static analysis tool named DCNS written by myself.
> And I also manually check it.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>

Acked-by: Alan Stern <stern@rowland.harvard.edu>


> ---
>  drivers/usb/storage/freecom.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
> index c0a5d95..c7f886d 100644
> --- a/drivers/usb/storage/freecom.c
> +++ b/drivers/usb/storage/freecom.c
> @@ -477,7 +477,7 @@ static int init_freecom(struct us_data *us)
>  	usb_stor_dbg(us, "result from activate reset is %d\n", result);
>  
>  	/* wait 250ms */
> -	mdelay(250);
> +	msleep(250);
>  
>  	/* clear reset */
>  	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
> @@ -485,7 +485,7 @@ static int init_freecom(struct us_data *us)
>  	usb_stor_dbg(us, "result from clear reset is %d\n", result);
>  
>  	/* wait 3 seconds */
> -	mdelay(3 * 1000);
> +	msleep(3 * 1000);
>  
>  	return USB_STOR_TRANSPORT_GOOD;
>  }
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-10 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10  1:29 [PATCH] usb: storage: Replace mdelay with msleep in init_freecom Jia-Ju Bai
2018-04-10  1:29 ` Jia-Ju Bai
2018-04-10 14:15 ` [PATCH] " Alan Stern
2018-04-10 14:15   ` Alan Stern

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.