Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

watchdog: ftwdt010_wdt: implement _restart() function

Implement ftwdt010_wdt_restart(). It enables watchdog with timeout = 0
and disabled IRQ. Since it needs code similar to ftwdt010_wdt_start(),
add a new function ftwdt010_enable() and move common code there.

Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220829090436.452742-1-saproj@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Sergei Antonov and committed by
Wim Van Sebroeck
64ee9375 5a9fbf8b

+19 -4
+19 -4
drivers/watchdog/ftwdt010_wdt.c
··· 47 47 return container_of(wdd, struct ftwdt010_wdt, wdd); 48 48 } 49 49 50 - static int ftwdt010_wdt_start(struct watchdog_device *wdd) 50 + static void ftwdt010_enable(struct ftwdt010_wdt *gwdt, 51 + unsigned int timeout, 52 + bool need_irq) 51 53 { 52 - struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); 53 54 u32 enable; 54 55 55 - writel(wdd->timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); 56 + writel(timeout * WDT_CLOCK, gwdt->base + FTWDT010_WDLOAD); 56 57 writel(WDRESTART_MAGIC, gwdt->base + FTWDT010_WDRESTART); 57 58 /* set clock before enabling */ 58 59 enable = WDCR_CLOCK_5MHZ | WDCR_SYS_RST; 59 60 writel(enable, gwdt->base + FTWDT010_WDCR); 60 - if (gwdt->has_irq) 61 + if (need_irq) 61 62 enable |= WDCR_WDINTR; 62 63 enable |= WDCR_ENABLE; 63 64 writel(enable, gwdt->base + FTWDT010_WDCR); 65 + } 64 66 67 + static int ftwdt010_wdt_start(struct watchdog_device *wdd) 68 + { 69 + struct ftwdt010_wdt *gwdt = to_ftwdt010_wdt(wdd); 70 + 71 + ftwdt010_enable(gwdt, wdd->timeout, gwdt->has_irq); 65 72 return 0; 66 73 } 67 74 ··· 100 93 return 0; 101 94 } 102 95 96 + static int ftwdt010_wdt_restart(struct watchdog_device *wdd, 97 + unsigned long action, void *data) 98 + { 99 + ftwdt010_enable(to_ftwdt010_wdt(wdd), 0, false); 100 + return 0; 101 + } 102 + 103 103 static irqreturn_t ftwdt010_wdt_interrupt(int irq, void *data) 104 104 { 105 105 struct ftwdt010_wdt *gwdt = data; ··· 121 107 .stop = ftwdt010_wdt_stop, 122 108 .ping = ftwdt010_wdt_ping, 123 109 .set_timeout = ftwdt010_wdt_set_timeout, 110 + .restart = ftwdt010_wdt_restart, 124 111 .owner = THIS_MODULE, 125 112 }; 126 113