Commit 3a2c4895 authored by Ahmad Fatoum's avatar Ahmad Fatoum Committed by Wim Van Sebroeck

watchdog: f71808e_wdt: rename variant-independent identifiers appropriately

Code for the common parts of the driver either uses watchdog_ as
prefix for the watchdog API or f71808e_ for everything else.

The driver now supports 9 more variants besides the f71808e,
so let's rename the common parts to start with fintek_wdt_ instead.

This makes code browsing easier, because it's readily apparent
that functions are not variant-specific. Some watchdog_-prefixed
functions remain, but these will be dropped altogether with the move
to the kernel watchdog API in a later commit.
Signed-off-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/31805c6aeb8d161f852ddad7c32b91319f924988.1628525954.git-series.a.fatoum@pengutronix.deSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent c3a291e1
...@@ -112,7 +112,7 @@ MODULE_PARM_DESC(start_withtimeout, "Start watchdog timer on module load with" ...@@ -112,7 +112,7 @@ MODULE_PARM_DESC(start_withtimeout, "Start watchdog timer on module load with"
enum chips { f71808fg, f71858fg, f71862fg, f71868, f71869, f71882fg, f71889fg, enum chips { f71808fg, f71858fg, f71862fg, f71868, f71869, f71882fg, f71889fg,
f81803, f81865, f81866}; f81803, f81865, f81866};
static const char * const f71808e_names[] = { static const char * const fintek_wdt_names[] = {
"f71808fg", "f71808fg",
"f71858fg", "f71858fg",
"f71862fg", "f71862fg",
...@@ -135,7 +135,7 @@ static inline int superio_enter(int base); ...@@ -135,7 +135,7 @@ static inline int superio_enter(int base);
static inline void superio_select(int base, int ld); static inline void superio_select(int base, int ld);
static inline void superio_exit(int base); static inline void superio_exit(int base);
struct watchdog_data { struct fintek_wdt {
unsigned short sioaddr; unsigned short sioaddr;
enum chips type; enum chips type;
unsigned long opened; unsigned long opened;
...@@ -151,7 +151,7 @@ struct watchdog_data { ...@@ -151,7 +151,7 @@ struct watchdog_data {
char caused_reboot; /* last reboot was by the watchdog */ char caused_reboot; /* last reboot was by the watchdog */
}; };
static struct watchdog_data watchdog = { static struct fintek_wdt watchdog = {
.lock = __MUTEX_INITIALIZER(watchdog.lock), .lock = __MUTEX_INITIALIZER(watchdog.lock),
}; };
...@@ -217,7 +217,7 @@ static inline void superio_exit(int base) ...@@ -217,7 +217,7 @@ static inline void superio_exit(int base)
release_region(base, 2); release_region(base, 2);
} }
static int watchdog_set_timeout(int timeout) static int fintek_wdt_set_timeout(int timeout)
{ {
if (timeout <= 0 if (timeout <= 0
|| timeout > WATCHDOG_MAX_TIMEOUT) { || timeout > WATCHDOG_MAX_TIMEOUT) {
...@@ -243,7 +243,7 @@ static int watchdog_set_timeout(int timeout) ...@@ -243,7 +243,7 @@ static int watchdog_set_timeout(int timeout)
return 0; return 0;
} }
static int watchdog_set_pulse_width(unsigned int pw) static int fintek_wdt_set_pulse_width(unsigned int pw)
{ {
int err = 0; int err = 0;
unsigned int t1 = 25, t2 = 125, t3 = 5000; unsigned int t1 = 25, t2 = 125, t3 = 5000;
...@@ -277,7 +277,7 @@ static int watchdog_set_pulse_width(unsigned int pw) ...@@ -277,7 +277,7 @@ static int watchdog_set_pulse_width(unsigned int pw)
return err; return err;
} }
static int watchdog_keepalive(void) static int fintek_wdt_keepalive(void)
{ {
int err = 0; int err = 0;
...@@ -307,13 +307,13 @@ static int watchdog_keepalive(void) ...@@ -307,13 +307,13 @@ static int watchdog_keepalive(void)
return err; return err;
} }
static int watchdog_start(void) static int fintek_wdt_start(void)
{ {
int err; int err;
u8 tmp; u8 tmp;
/* Make sure we don't die as soon as the watchdog is enabled below */ /* Make sure we don't die as soon as the watchdog is enabled below */
err = watchdog_keepalive(); err = fintek_wdt_keepalive();
if (err) if (err)
return err; return err;
...@@ -434,7 +434,7 @@ static int watchdog_start(void) ...@@ -434,7 +434,7 @@ static int watchdog_start(void)
return err; return err;
} }
static int watchdog_stop(void) static int fintek_wdt_stop(void)
{ {
int err = 0; int err = 0;
...@@ -466,7 +466,7 @@ static int watchdog_get_status(void) ...@@ -466,7 +466,7 @@ static int watchdog_get_status(void)
return status; return status;
} }
static bool watchdog_is_running(void) static bool fintek_wdt_is_running(void)
{ {
/* /*
* if we fail to determine the watchdog's status assume it to be * if we fail to determine the watchdog's status assume it to be
...@@ -500,7 +500,7 @@ static int watchdog_open(struct inode *inode, struct file *file) ...@@ -500,7 +500,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
if (test_and_set_bit(0, &watchdog.opened)) if (test_and_set_bit(0, &watchdog.opened))
return -EBUSY; return -EBUSY;
err = watchdog_start(); err = fintek_wdt_start();
if (err) { if (err) {
clear_bit(0, &watchdog.opened); clear_bit(0, &watchdog.opened);
return err; return err;
...@@ -518,10 +518,10 @@ static int watchdog_release(struct inode *inode, struct file *file) ...@@ -518,10 +518,10 @@ static int watchdog_release(struct inode *inode, struct file *file)
clear_bit(0, &watchdog.opened); clear_bit(0, &watchdog.opened);
if (!watchdog.expect_close) { if (!watchdog.expect_close) {
watchdog_keepalive(); fintek_wdt_keepalive();
pr_crit("Unexpected close, not stopping watchdog!\n"); pr_crit("Unexpected close, not stopping watchdog!\n");
} else if (!nowayout) { } else if (!nowayout) {
watchdog_stop(); fintek_wdt_stop();
} }
return 0; return 0;
} }
...@@ -562,7 +562,7 @@ static ssize_t watchdog_write(struct file *file, const char __user *buf, ...@@ -562,7 +562,7 @@ static ssize_t watchdog_write(struct file *file, const char __user *buf,
} }
/* someone wrote to us, we should restart timer */ /* someone wrote to us, we should restart timer */
watchdog_keepalive(); fintek_wdt_keepalive();
} }
return count; return count;
} }
...@@ -609,24 +609,24 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, ...@@ -609,24 +609,24 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
return -EFAULT; return -EFAULT;
if (new_options & WDIOS_DISABLECARD) if (new_options & WDIOS_DISABLECARD)
watchdog_stop(); fintek_wdt_stop();
if (new_options & WDIOS_ENABLECARD) if (new_options & WDIOS_ENABLECARD)
return watchdog_start(); return fintek_wdt_start();
fallthrough; fallthrough;
case WDIOC_KEEPALIVE: case WDIOC_KEEPALIVE:
watchdog_keepalive(); fintek_wdt_keepalive();
return 0; return 0;
case WDIOC_SETTIMEOUT: case WDIOC_SETTIMEOUT:
if (get_user(new_timeout, uarg.i)) if (get_user(new_timeout, uarg.i))
return -EFAULT; return -EFAULT;
if (watchdog_set_timeout(new_timeout)) if (fintek_wdt_set_timeout(new_timeout))
return -EINVAL; return -EINVAL;
watchdog_keepalive(); fintek_wdt_keepalive();
fallthrough; fallthrough;
case WDIOC_GETTIMEOUT: case WDIOC_GETTIMEOUT:
...@@ -642,7 +642,7 @@ static int watchdog_notify_sys(struct notifier_block *this, unsigned long code, ...@@ -642,7 +642,7 @@ static int watchdog_notify_sys(struct notifier_block *this, unsigned long code,
void *unused) void *unused)
{ {
if (code == SYS_DOWN || code == SYS_HALT) if (code == SYS_DOWN || code == SYS_HALT)
watchdog_stop(); fintek_wdt_stop();
return NOTIFY_DONE; return NOTIFY_DONE;
} }
...@@ -680,7 +680,7 @@ static int __init watchdog_init(int sioaddr) ...@@ -680,7 +680,7 @@ static int __init watchdog_init(int sioaddr)
snprintf(watchdog.ident.identity, snprintf(watchdog.ident.identity,
sizeof(watchdog.ident.identity), "%s watchdog", sizeof(watchdog.ident.identity), "%s watchdog",
f71808e_names[watchdog.type]); fintek_wdt_names[watchdog.type]);
err = superio_enter(sioaddr); err = superio_enter(sioaddr);
if (err) if (err)
...@@ -699,10 +699,10 @@ static int __init watchdog_init(int sioaddr) ...@@ -699,10 +699,10 @@ static int __init watchdog_init(int sioaddr)
superio_exit(sioaddr); superio_exit(sioaddr);
err = watchdog_set_timeout(timeout); err = fintek_wdt_set_timeout(timeout);
if (err) if (err)
return err; return err;
err = watchdog_set_pulse_width(pulse_width); err = fintek_wdt_set_pulse_width(pulse_width);
if (err) if (err)
return err; return err;
...@@ -725,7 +725,7 @@ static int __init watchdog_init(int sioaddr) ...@@ -725,7 +725,7 @@ static int __init watchdog_init(int sioaddr)
goto exit_miscdev; goto exit_miscdev;
} }
err = watchdog_start(); err = fintek_wdt_start();
if (err) { if (err) {
pr_err("cannot start watchdog timer\n"); pr_err("cannot start watchdog timer\n");
goto exit_miscdev; goto exit_miscdev;
...@@ -773,7 +773,7 @@ static int __init watchdog_init(int sioaddr) ...@@ -773,7 +773,7 @@ static int __init watchdog_init(int sioaddr)
return err; return err;
} }
static int __init f71808e_find(int sioaddr) static int __init fintek_wdt_find(int sioaddr)
{ {
u16 devid; u16 devid;
int err = superio_enter(sioaddr); int err = superio_enter(sioaddr);
...@@ -829,14 +829,14 @@ static int __init f71808e_find(int sioaddr) ...@@ -829,14 +829,14 @@ static int __init f71808e_find(int sioaddr)
} }
pr_info("Found %s watchdog chip, revision %d\n", pr_info("Found %s watchdog chip, revision %d\n",
f71808e_names[watchdog.type], fintek_wdt_names[watchdog.type],
(int)superio_inb(sioaddr, SIO_REG_DEVREV)); (int)superio_inb(sioaddr, SIO_REG_DEVREV));
exit: exit:
superio_exit(sioaddr); superio_exit(sioaddr);
return err; return err;
} }
static int __init f71808e_init(void) static int __init fintek_wdt_init(void)
{ {
static const unsigned short addrs[] = { 0x2e, 0x4e }; static const unsigned short addrs[] = { 0x2e, 0x4e };
int err = -ENODEV; int err = -ENODEV;
...@@ -848,7 +848,7 @@ static int __init f71808e_init(void) ...@@ -848,7 +848,7 @@ static int __init f71808e_init(void)
} }
for (i = 0; i < ARRAY_SIZE(addrs); i++) { for (i = 0; i < ARRAY_SIZE(addrs); i++) {
err = f71808e_find(addrs[i]); err = fintek_wdt_find(addrs[i]);
if (err == 0) if (err == 0)
break; break;
} }
...@@ -858,11 +858,11 @@ static int __init f71808e_init(void) ...@@ -858,11 +858,11 @@ static int __init f71808e_init(void)
return watchdog_init(addrs[i]); return watchdog_init(addrs[i]);
} }
static void __exit f71808e_exit(void) static void __exit fintek_wdt_exit(void)
{ {
if (watchdog_is_running()) { if (fintek_wdt_is_running()) {
pr_warn("Watchdog timer still running, stopping it\n"); pr_warn("Watchdog timer still running, stopping it\n");
watchdog_stop(); fintek_wdt_stop();
} }
misc_deregister(&watchdog_miscdev); misc_deregister(&watchdog_miscdev);
unregister_reboot_notifier(&watchdog_notifier); unregister_reboot_notifier(&watchdog_notifier);
...@@ -872,5 +872,5 @@ MODULE_DESCRIPTION("F71808E Watchdog Driver"); ...@@ -872,5 +872,5 @@ MODULE_DESCRIPTION("F71808E Watchdog Driver");
MODULE_AUTHOR("Giel van Schijndel <me@mortis.eu>"); MODULE_AUTHOR("Giel van Schijndel <me@mortis.eu>");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_init(f71808e_init); module_init(fintek_wdt_init);
module_exit(f71808e_exit); module_exit(fintek_wdt_exit);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment