2018-07-30 13:52:11

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] power: reset: syscon-poweroff: Replace mdelay() with msleep() in syscon_poweroff()

syscon_poweroff() is never called in atomic context.
It calls mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep().

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/power/reset/syscon-poweroff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c
index f9f1cb54fbf9..b8b154606dbe 100644
--- a/drivers/power/reset/syscon-poweroff.c
+++ b/drivers/power/reset/syscon-poweroff.c
@@ -36,7 +36,7 @@ static void syscon_poweroff(void)
/* Issue the poweroff */
regmap_update_bits(map, offset, mask, value);

- mdelay(1000);
+ msleep(1000);

pr_emerg("Unable to poweroff system\n");
}
--
2.17.0



2018-08-29 22:48:25

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH] power: reset: syscon-poweroff: Replace mdelay() with msleep() in syscon_poweroff()

Hi,

On Mon, Jul 30, 2018 at 09:50:29PM +0800, Jia-Ju Bai wrote:
> syscon_poweroff() is never called in atomic context.
> It calls mdelay() to busily wait, which is not necessary.
> mdelay() can be replaced with msleep().
>
> This is found by a static analysis tool named DCNS written by myself.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> ---

This is also a shutdown driver, not applying.

-- Sebastian

> drivers/power/reset/syscon-poweroff.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/reset/syscon-poweroff.c b/drivers/power/reset/syscon-poweroff.c
> index f9f1cb54fbf9..b8b154606dbe 100644
> --- a/drivers/power/reset/syscon-poweroff.c
> +++ b/drivers/power/reset/syscon-poweroff.c
> @@ -36,7 +36,7 @@ static void syscon_poweroff(void)
> /* Issue the poweroff */
> regmap_update_bits(map, offset, mask, value);
>
> - mdelay(1000);
> + msleep(1000);
>
> pr_emerg("Unable to poweroff system\n");
> }
> --
> 2.17.0
>


Attachments:
(No filename) (1.00 kB)
signature.asc (849.00 B)
Download all attachments