mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: wdat_wdt: Avoid unimplemented get_timeleft
@ 2022-12-22 23:43 Thomas Weißschuh
  2022-12-23  0:55 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2022-12-22 23:43 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Thomas Weißschuh

As per the specification the action QUERY_COUNTDOWN_PERIOD is optional.
If the action is not implemented by the physical device the driver would
always report "0" from get_timeleft().
Avoid confusing userspace by only providing get_timeleft() when
implemented by the hardware.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/watchdog/wdat_wdt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
index ce7a4a9e4b03..0ba99bed59fc 100644
--- a/drivers/watchdog/wdat_wdt.c
+++ b/drivers/watchdog/wdat_wdt.c
@@ -301,13 +301,12 @@ static const struct watchdog_info wdat_wdt_info = {
 	.identity = "wdat_wdt",
 };
 
-static const struct watchdog_ops wdat_wdt_ops = {
+static struct watchdog_ops wdat_wdt_ops = {
 	.owner = THIS_MODULE,
 	.start = wdat_wdt_start,
 	.stop = wdat_wdt_stop,
 	.ping = wdat_wdt_ping,
 	.set_timeout = wdat_wdt_set_timeout,
-	.get_timeleft = wdat_wdt_get_timeleft,
 };
 
 static int wdat_wdt_probe(struct platform_device *pdev)
@@ -436,6 +435,9 @@ static int wdat_wdt_probe(struct platform_device *pdev)
 		list_add_tail(&instr->node, instructions);
 	}
 
+	if (wdat->instructions[ACPI_WDAT_GET_CURRENT_COUNTDOWN])
+		wdat_wdt_ops.get_timeleft = wdat_wdt_get_timeleft;
+
 	wdat_wdt_boot_status(wdat);
 	wdat_wdt_set_running(wdat);
 

---
base-commit: 0a924817d2ed9396401e0557c6134276d2e26382
change-id: 20221221-wdat_wdt-timeleft-b38d0db39d9f

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>

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

* Re: [PATCH] watchdog: wdat_wdt: Avoid unimplemented get_timeleft
  2022-12-22 23:43 [PATCH] watchdog: wdat_wdt: Avoid unimplemented get_timeleft Thomas Weißschuh
@ 2022-12-23  0:55 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-12-23  0:55 UTC (permalink / raw)
  To: Thomas Weißschuh; +Cc: Wim Van Sebroeck, linux-watchdog, linux-kernel

On Thu, Dec 22, 2022 at 11:43:31PM +0000, Thomas Weißschuh wrote:
> As per the specification the action QUERY_COUNTDOWN_PERIOD is optional.
> If the action is not implemented by the physical device the driver would
> always report "0" from get_timeleft().
> Avoid confusing userspace by only providing get_timeleft() when
> implemented by the hardware.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Assuming that there can be only one of those watchdogs in the system,

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

Guenter

> ---
>  drivers/watchdog/wdat_wdt.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
> index ce7a4a9e4b03..0ba99bed59fc 100644
> --- a/drivers/watchdog/wdat_wdt.c
> +++ b/drivers/watchdog/wdat_wdt.c
> @@ -301,13 +301,12 @@ static const struct watchdog_info wdat_wdt_info = {
>  	.identity = "wdat_wdt",
>  };
>  
> -static const struct watchdog_ops wdat_wdt_ops = {
> +static struct watchdog_ops wdat_wdt_ops = {
>  	.owner = THIS_MODULE,
>  	.start = wdat_wdt_start,
>  	.stop = wdat_wdt_stop,
>  	.ping = wdat_wdt_ping,
>  	.set_timeout = wdat_wdt_set_timeout,
> -	.get_timeleft = wdat_wdt_get_timeleft,
>  };
>  
>  static int wdat_wdt_probe(struct platform_device *pdev)
> @@ -436,6 +435,9 @@ static int wdat_wdt_probe(struct platform_device *pdev)
>  		list_add_tail(&instr->node, instructions);
>  	}
>  
> +	if (wdat->instructions[ACPI_WDAT_GET_CURRENT_COUNTDOWN])
> +		wdat_wdt_ops.get_timeleft = wdat_wdt_get_timeleft;
> +
>  	wdat_wdt_boot_status(wdat);
>  	wdat_wdt_set_running(wdat);
>  
> 
> ---
> base-commit: 0a924817d2ed9396401e0557c6134276d2e26382
> change-id: 20221221-wdat_wdt-timeleft-b38d0db39d9f
> 
> Best regards,
> -- 
> Thomas Weißschuh <linux@weissschuh.net>

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

end of thread, other threads:[~2022-12-23  0:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-22 23:43 [PATCH] watchdog: wdat_wdt: Avoid unimplemented get_timeleft Thomas Weißschuh
2022-12-23  0:55 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®