linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mmc: wbsd: Replace mdelay with usleep_range in wbsd_init
@ 2018-04-11  2:46 Jia-Ju Bai
  2018-04-11 15:04 ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2018-04-11  2:46 UTC (permalink / raw)
  To: pierre, ulf.hansson; +Cc: linux-mmc, linux-kernel, Jia-Ju Bai

wbsd_init() is never called in atomic context.

The call chains ending up at wbsd_init() are:
[1] wbsd_init() <- wbsd_probe()
[2] wbsd_init() <- wbsd_pnp_probe()

wbsd_probe() is set as ".probe" in struct platform_driver.
wbsd_pnp_probe() is set as ".probe" in struct pnp_driver.
These functions are not called in atomic context.

Despite never getting called from atomic context, wbsd_init()
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/mmc/host/wbsd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index 546aaf8..6224d12 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -1709,7 +1709,7 @@ static int wbsd_init(struct device *dev, int base, int irq, int dma,
 	/*
 	 * Allow device to initialise itself properly.
 	 */
-	mdelay(5);
+	usleep_range(5000, 6000);
 
 	/*
 	 * Reset the chip into a known state.
-- 
1.9.1

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

end of thread, other threads:[~2018-04-12  1:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11  2:46 [PATCH 1/3] mmc: wbsd: Replace mdelay with usleep_range in wbsd_init Jia-Ju Bai
2018-04-11 15:04 ` Ulf Hansson
2018-04-12  1:34   ` Jia-Ju Bai

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).