netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] staging: irda: Replace mdelay with usleep_range in irda_usb_probe
@ 2018-04-11  1:33 Jia-Ju Bai
  2018-04-11  7:08 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2018-04-11  1:33 UTC (permalink / raw)
  To: samuel, gregkh, davem, johan, arvind.yadav.cs
  Cc: netdev, devel, linux-kernel, Jia-Ju Bai

irda_usb_probe() is never called in atomic context.

irda_usb_probe() is only set as ".probe" in struct usb_driver.

Despite never getting called from atomic context, irda_usb_probe()
calls mdelay() to busily wait.
This is not necessary and can be replaced with usleep_range() 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/staging/irda/drivers/irda-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/irda/drivers/irda-usb.c b/drivers/staging/irda/drivers/irda-usb.c
index 723e49b..6ff5b08 100644
--- a/drivers/staging/irda/drivers/irda-usb.c
+++ b/drivers/staging/irda/drivers/irda-usb.c
@@ -1710,7 +1710,7 @@ static int irda_usb_probe(struct usb_interface *intf,
 			pr_debug("usb_control_msg failed %d\n", ret);
 			goto err_out_3;
 		} else {
-			mdelay(10);
+			usleep_range(10000, 11000);
 		}
 	}
 
-- 
1.9.1

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

* Re: [PATCH 2/2] staging: irda: Replace mdelay with usleep_range in irda_usb_probe
  2018-04-11  1:33 [PATCH 2/2] staging: irda: Replace mdelay with usleep_range in irda_usb_probe Jia-Ju Bai
@ 2018-04-11  7:08 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2018-04-11  7:08 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: samuel, gregkh, davem, johan, arvind.yadav.cs, netdev, devel,
	linux-kernel

On Wed, Apr 11, 2018 at 09:33:55AM +0800, Jia-Ju Bai wrote:
> irda_usb_probe() is never called in atomic context.
> 
> irda_usb_probe() is only set as ".probe" in struct usb_driver.
> 
> Despite never getting called from atomic context, irda_usb_probe()
> calls mdelay() to busily wait.
> This is not necessary and can be replaced with usleep_range() 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>

Reviewed-by: Johan Hovold <johan@kernel.org>

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

end of thread, other threads:[~2018-04-11  7:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11  1:33 [PATCH 2/2] staging: irda: Replace mdelay with usleep_range in irda_usb_probe Jia-Ju Bai
2018-04-11  7:08 ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).