diff mbox series

[1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function

Message ID 20210412083214.21149-1-Meng.Li@windriver.com
State Superseded
Delegated to: Stefan Roese
Headers show
Series [1/2] driver: watchdog: reset watchdog in designware_wdt_stop() function | expand

Commit Message

Li, Meng April 12, 2021, 8:32 a.m. UTC
From: MengLi <meng.li@windriver.com>

In uboot command line environment, watchdog is not able to be
stopped with below commands:
SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
SOCFPGA_STRATIX10 # wdt stop
Refer to watchdog driver in linux kernel, it is also need to reset
watchdog after disable it so that the disable action takes effect.

Signed-off-by: Meng Li <Meng.Li@windriver.com>
---
 drivers/watchdog/designware_wdt.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Stefan Roese April 27, 2021, 6:21 a.m. UTC | #1
On 12.04.21 10:32, Meng.Li@windriver.com wrote:
> From: MengLi <meng.li@windriver.com>
> 
> In uboot command line environment, watchdog is not able to be
> stopped with below commands:
> SOCFPGA_STRATIX10 # wdt dev watchdog@ffd00200
> SOCFPGA_STRATIX10 # wdt stop
> Refer to watchdog driver in linux kernel, it is also need to reset
> watchdog after disable it so that the disable action takes effect.
> 
> Signed-off-by: Meng Li <Meng.Li@windriver.com>
> ---
>   drivers/watchdog/designware_wdt.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
> index 12f09a7a39..63e89d38c4 100644
> --- a/drivers/watchdog/designware_wdt.c
> +++ b/drivers/watchdog/designware_wdt.c
> @@ -92,10 +92,27 @@ static int designware_wdt_reset(struct udevice *dev)
>   static int designware_wdt_stop(struct udevice *dev)
>   {
>   	struct designware_wdt_priv *priv = dev_get_priv(dev);
> +	__maybe_unused int ret;

You add "ret" here as "__maybe_unused" and ...

>   
>   	designware_wdt_reset(dev);
>   	writel(0, priv->base + DW_WDT_CR);
>   
> +#if CONFIG_IS_ENABLED(DM_RESET)
> +	struct reset_ctl_bulk resets;

... here this struct. Please add both above as __maybe_unsed. I assume
that checkpatch and other tools will complain about variable
declarations in the code path.

BTW: It should be possible to change the above #if CONFIG_ to this

	if (CONFIG_IS_ENABLED(DM_RESET)) {

Then you can put both variable declarations in here:

	if (CONFIG_IS_ENABLED(DM_RESET)) {
		struct reset_ctl_bulk resets;
		int ret;

Please check if this works and resubmit.

Thanks,
Stefan

> +
> +	ret = reset_get_bulk(dev, &resets);
> +	if (ret)
> +		return ret;
> +
> +	ret = reset_assert_bulk(&resets);
> +	if (ret)
> +		return ret;
> +
> +	ret = reset_deassert_bulk(&resets);
> +	if (ret)
> +		return ret;
> +#endif
> +
>   	return 0;
>   }
>   
>
diff mbox series

Patch

diff --git a/drivers/watchdog/designware_wdt.c b/drivers/watchdog/designware_wdt.c
index 12f09a7a39..63e89d38c4 100644
--- a/drivers/watchdog/designware_wdt.c
+++ b/drivers/watchdog/designware_wdt.c
@@ -92,10 +92,27 @@  static int designware_wdt_reset(struct udevice *dev)
 static int designware_wdt_stop(struct udevice *dev)
 {
 	struct designware_wdt_priv *priv = dev_get_priv(dev);
+	__maybe_unused int ret;
 
 	designware_wdt_reset(dev);
 	writel(0, priv->base + DW_WDT_CR);
 
+#if CONFIG_IS_ENABLED(DM_RESET)
+	struct reset_ctl_bulk resets;
+
+	ret = reset_get_bulk(dev, &resets);
+	if (ret)
+		return ret;
+
+	ret = reset_assert_bulk(&resets);
+	if (ret)
+		return ret;
+
+	ret = reset_deassert_bulk(&resets);
+	if (ret)
+		return ret;
+#endif
+
 	return 0;
 }