watchdog: wdat_wdt: Avoid unimplemented get_timeleft
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 22 Dec 2022 23:43:31 +0000 (23:43 +0000)
committerWim Van Sebroeck <wim@linux-watchdog.org>
Sun, 12 Feb 2023 14:32:53 +0000 (15:32 +0100)
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>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20221221-wdat_wdt-timeleft-v1-1-8e8a314c36cc@weissschuh.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
drivers/watchdog/wdat_wdt.c

index ce7a4a9e4b03ca8d2ae4d70390190d4780c62a76..0ba99bed59fc4d6ef821f0494ac9daaeeb3591ea 100644 (file)
@@ -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);