* [PATCH] power: reset: piix4-poweroff: Replace mdelay() with msleep() and usleep_range() in piix4_poweroff()
@ 2018-07-30 13:48 Jia-Ju Bai
2018-08-29 22:44 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2018-07-30 13:48 UTC (permalink / raw)
To: sre; +Cc: linux-pm, linux-kernel, Jia-Ju Bai
piix4_poweroff() is never called in atomic context.
It calls mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep() and usleep_range().
This is found by a static analysis tool named DCNS written by myself.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/power/reset/piix4-poweroff.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/reset/piix4-poweroff.c b/drivers/power/reset/piix4-poweroff.c
index 20ce3ff5e039..5d4c72992d2c 100644
--- a/drivers/power/reset/piix4-poweroff.c
+++ b/drivers/power/reset/piix4-poweroff.c
@@ -47,7 +47,7 @@ static void piix4_poweroff(void)
io_offset + PIIX4_FUNC3IO_PMCNTRL);
/* If the special cycle occurs too soon this doesn't work... */
- mdelay(10);
+ usleep_range(10000, 11000);
/*
* The PIIX4 will enter the suspend state only after seeing a special
@@ -59,7 +59,7 @@ static void piix4_poweroff(void)
PIIX4_SUSPEND_MAGIC);
/* Give the system some time to power down, then error */
- mdelay(1000);
+ msleep(1000);
pr_emerg("Unable to poweroff system\n");
}
--
2.17.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: reset: piix4-poweroff: Replace mdelay() with msleep() and usleep_range() in piix4_poweroff()
2018-07-30 13:48 [PATCH] power: reset: piix4-poweroff: Replace mdelay() with msleep() and usleep_range() in piix4_poweroff() Jia-Ju Bai
@ 2018-08-29 22:44 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2018-08-29 22:44 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]
Hi,
On Mon, Jul 30, 2018 at 09:48:38PM +0800, Jia-Ju Bai wrote:
> piix4_poweroff() is never called in atomic context.
> It calls mdelay() to busily wait, which is not necessary.
> mdelay() can be replaced with msleep() and usleep_range().
>
> This is found by a static analysis tool named DCNS written by myself.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
This is a shutdown driver, so busy waiting is ok.
-- Sebastian
> drivers/power/reset/piix4-poweroff.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/power/reset/piix4-poweroff.c b/drivers/power/reset/piix4-poweroff.c
> index 20ce3ff5e039..5d4c72992d2c 100644
> --- a/drivers/power/reset/piix4-poweroff.c
> +++ b/drivers/power/reset/piix4-poweroff.c
> @@ -47,7 +47,7 @@ static void piix4_poweroff(void)
> io_offset + PIIX4_FUNC3IO_PMCNTRL);
>
> /* If the special cycle occurs too soon this doesn't work... */
> - mdelay(10);
> + usleep_range(10000, 11000);
>
> /*
> * The PIIX4 will enter the suspend state only after seeing a special
> @@ -59,7 +59,7 @@ static void piix4_poweroff(void)
> PIIX4_SUSPEND_MAGIC);
>
> /* Give the system some time to power down, then error */
> - mdelay(1000);
> + msleep(1000);
> pr_emerg("Unable to poweroff system\n");
> }
>
> --
> 2.17.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-29 22:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 13:48 [PATCH] power: reset: piix4-poweroff: Replace mdelay() with msleep() and usleep_range() in piix4_poweroff() Jia-Ju Bai
2018-08-29 22:44 ` Sebastian Reichel
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).