Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *	National Semiconductor PC87307/PC97307 (ala SC1200) WDT driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	(c) Copyright 2002 Zwane Mwaikambo <zwane@commfireservices.com>,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *			All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	Based on wdt.c and wdt977.c by Alan Cox and Woody Suwalski respectively.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	The author(s) of this software shall not be held liable for damages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *	of any nature resulting due to the use of this software. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *	software is provided AS-IS with no warranties.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *	Changelog:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *	20020220 Zwane Mwaikambo	Code based on datasheet, no hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *	20020221 Zwane Mwaikambo	Cleanups as suggested by Jeff Garzik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *					and Alan Cox.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *	20020222 Zwane Mwaikambo	Added probing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *	20020225 Zwane Mwaikambo	Added ISAPNP support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *	20020412 Rob Radez		Broke out start/stop functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *		 <rob@osinvestor.com>	Return proper status instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *					temperature warning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *					Add WDIOC_GETBOOTSTATUS and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *					WDIOC_SETOPTIONS ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *					Fix CONFIG_WATCHDOG_NOWAYOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *	20020530 Joel Becker		Add Matt Domsch's nowayout module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *					option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *	20030116 Adam Belay		Updated to the latest pnp code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/miscdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/watchdog.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #include <linux/pnp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include <linux/semaphore.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define SC1200_MODULE_VER	"build 20020303"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define SC1200_MODULE_NAME	"sc1200wdt"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define	MAX_TIMEOUT	255	/* 255 minutes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define PMIR		(io)	/* Power Management Index Register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define PMDR		(io+1)	/* Power Management Data Register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /* Data Register indexes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define FER1		0x00	/* Function enable register 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define FER2		0x01	/* Function enable register 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define PMC1		0x02	/* Power Management Ctrl 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define PMC2		0x03	/* Power Management Ctrl 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define PMC3		0x04	/* Power Management Ctrl 3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define WDTO		0x05	/* Watchdog timeout register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define	WDCF		0x06	/* Watchdog config register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define WDST		0x07	/* Watchdog status register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) /* WDCF bitfields - which devices assert WDO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define KBC_IRQ		0x01	/* Keyboard Controller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define MSE_IRQ		0x02	/* Mouse */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define UART1_IRQ	0x03	/* Serial0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #define UART2_IRQ	0x04	/* Serial1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /* 5 -7 are reserved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static int timeout = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) static int io = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static int io_len = 2;		/* for non plug and play */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static unsigned long open_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static char expect_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static DEFINE_SPINLOCK(sc1200wdt_lock);	/* io port access serialisation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #if defined CONFIG_PNP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static int isapnp = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static struct pnp_dev *wdt_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) module_param(isapnp, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) MODULE_PARM_DESC(isapnp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	"When set to 0 driver ISA PnP support will be disabled");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) module_param_hw(io, int, ioport, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) MODULE_PARM_DESC(io, "io port");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) module_param(timeout, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) MODULE_PARM_DESC(timeout, "range is 0-255 minutes, default is 1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) static bool nowayout = WATCHDOG_NOWAYOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) module_param(nowayout, bool, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) MODULE_PARM_DESC(nowayout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	"Watchdog cannot be stopped once started (default="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) /* Read from Data Register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static inline void __sc1200wdt_read_data(unsigned char index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 						unsigned char *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	outb_p(index, PMIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	*data = inb(PMDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static void sc1200wdt_read_data(unsigned char index, unsigned char *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	spin_lock(&sc1200wdt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	__sc1200wdt_read_data(index, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	spin_unlock(&sc1200wdt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /* Write to Data Register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static inline void __sc1200wdt_write_data(unsigned char index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 						unsigned char data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	outb_p(index, PMIR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	outb(data, PMDR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline void sc1200wdt_write_data(unsigned char index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 						unsigned char data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	spin_lock(&sc1200wdt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	__sc1200wdt_write_data(index, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	spin_unlock(&sc1200wdt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static void sc1200wdt_start(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	unsigned char reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	spin_lock(&sc1200wdt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	__sc1200wdt_read_data(WDCF, &reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	/* assert WDO when any of the following interrupts are triggered too */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	reg |= (KBC_IRQ | MSE_IRQ | UART1_IRQ | UART2_IRQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	__sc1200wdt_write_data(WDCF, reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/* set the timeout and get the ball rolling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	__sc1200wdt_write_data(WDTO, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	spin_unlock(&sc1200wdt_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static void sc1200wdt_stop(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	sc1200wdt_write_data(WDTO, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* This returns the status of the WDO signal, inactive high. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static inline int sc1200wdt_status(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	unsigned char ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	sc1200wdt_read_data(WDST, &ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	/* If the bit is inactive, the watchdog is enabled, so return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	 * KEEPALIVEPING which is a bit of a kludge because there's nothing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 * else for enabled/disabled status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	return (ret & 0x01) ? 0 : WDIOF_KEEPALIVEPING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static int sc1200wdt_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	/* allow one at a time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (test_and_set_bit(0, &open_flag))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if (timeout > MAX_TIMEOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		timeout = MAX_TIMEOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	sc1200wdt_start();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	pr_info("Watchdog enabled, timeout = %d min(s)", timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	return stream_open(inode, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) static long sc1200wdt_ioctl(struct file *file, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 						unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	int new_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	void __user *argp = (void __user *)arg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	int __user *p = argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	static const struct watchdog_info ident = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 							WDIOF_MAGICCLOSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		.firmware_version = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		.identity = "PC87307/PC97307",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	case WDIOC_GETSUPPORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		if (copy_to_user(argp, &ident, sizeof(ident)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	case WDIOC_GETSTATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		return put_user(sc1200wdt_status(), p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	case WDIOC_GETBOOTSTATUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		return put_user(0, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	case WDIOC_SETOPTIONS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		int options, retval = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		if (get_user(options, p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		if (options & WDIOS_DISABLECARD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			sc1200wdt_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		if (options & WDIOS_ENABLECARD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			sc1200wdt_start();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			retval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	case WDIOC_KEEPALIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		sc1200wdt_write_data(WDTO, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	case WDIOC_SETTIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		if (get_user(new_timeout, p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		/* the API states this is given in secs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		new_timeout /= 60;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		timeout = new_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		sc1200wdt_write_data(WDTO, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		fallthrough;	/* and return the new timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	case WDIOC_GETTIMEOUT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		return put_user(timeout * 60, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		return -ENOTTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static int sc1200wdt_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	if (expect_close == 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		sc1200wdt_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		pr_info("Watchdog disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		sc1200wdt_write_data(WDTO, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		pr_crit("Unexpected close!, timeout = %d min(s)\n", timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	clear_bit(0, &open_flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	expect_close = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) static ssize_t sc1200wdt_write(struct file *file, const char __user *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 						size_t len, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	if (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		if (!nowayout) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 			size_t i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 			expect_close = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			for (i = 0; i != len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 				char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 				if (get_user(c, data + i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 					return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 				if (c == 'V')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 					expect_close = 42;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		sc1200wdt_write_data(WDTO, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static int sc1200wdt_notify_sys(struct notifier_block *this,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 					unsigned long code, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (code == SYS_DOWN || code == SYS_HALT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		sc1200wdt_stop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	return NOTIFY_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) static struct notifier_block sc1200wdt_notifier = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	.notifier_call =	sc1200wdt_notify_sys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static const struct file_operations sc1200wdt_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	.llseek		= no_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	.write		= sc1200wdt_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	.unlocked_ioctl = sc1200wdt_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	.compat_ioctl	= compat_ptr_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	.open		= sc1200wdt_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	.release	= sc1200wdt_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static struct miscdevice sc1200wdt_miscdev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	.minor		= WATCHDOG_MINOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	.name		= "watchdog",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	.fops		= &sc1200wdt_fops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) static int __init sc1200wdt_probe(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	/* The probe works by reading the PMC3 register's default value of 0x0e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	 * there is one caveat, if the device disables the parallel port or any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	 * of the UARTs we won't be able to detect it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	 * NB. This could be done with accuracy by reading the SID registers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	 * but we don't have access to those io regions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	unsigned char reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	sc1200wdt_read_data(PMC3, &reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	reg &= 0x0f;		/* we don't want the UART busy bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	return (reg == 0x0e) ? 0 : -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) #if defined CONFIG_PNP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static const struct pnp_device_id scl200wdt_pnp_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	/* National Semiconductor PC87307/PC97307 watchdog component */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	{.id = "NSC0800", .driver_data = 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	{.id = ""},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) static int scl200wdt_pnp_probe(struct pnp_dev *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 					const struct pnp_device_id *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	/* this driver only supports one card at a time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	if (wdt_dev || !isapnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	wdt_dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	io = pnp_port_start(wdt_dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	io_len = pnp_port_len(wdt_dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		pr_err("Unable to register IO port %#x\n", io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	pr_info("PnP device found at io port %#x/%d\n", io, io_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static void scl200wdt_pnp_remove(struct pnp_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (wdt_dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		release_region(io, io_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		wdt_dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static struct pnp_driver scl200wdt_pnp_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	.name		= "scl200wdt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	.id_table	= scl200wdt_pnp_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	.probe		= scl200wdt_pnp_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	.remove		= scl200wdt_pnp_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #endif /* CONFIG_PNP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) static int __init sc1200wdt_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	pr_info("%s\n", SC1200_MODULE_VER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) #if defined CONFIG_PNP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (isapnp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		ret = pnp_register_driver(&scl200wdt_pnp_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			goto out_clean;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	if (io == -1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		pr_err("io parameter must be specified\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		goto out_pnp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) #if defined CONFIG_PNP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	/* now that the user has specified an IO port and we haven't detected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	 * any devices, disable pnp support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	if (isapnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		pnp_unregister_driver(&scl200wdt_pnp_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	isapnp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		pr_err("Unable to register IO port %#x\n", io);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		goto out_pnp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	ret = sc1200wdt_probe();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		goto out_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	ret = register_reboot_notifier(&sc1200wdt_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		pr_err("Unable to register reboot notifier err = %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		goto out_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	ret = misc_register(&sc1200wdt_miscdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 		pr_err("Unable to register miscdev on minor %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		       WATCHDOG_MINOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		goto out_rbt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	/* ret = 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) out_clean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) out_rbt:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	unregister_reboot_notifier(&sc1200wdt_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) out_io:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	release_region(io, io_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) out_pnp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) #if defined CONFIG_PNP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	if (isapnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		pnp_unregister_driver(&scl200wdt_pnp_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	goto out_clean;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) static void __exit sc1200wdt_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	misc_deregister(&sc1200wdt_miscdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	unregister_reboot_notifier(&sc1200wdt_notifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) #if defined CONFIG_PNP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	if (isapnp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		pnp_unregister_driver(&scl200wdt_pnp_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	release_region(io, io_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) module_init(sc1200wdt_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) module_exit(sc1200wdt_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) MODULE_AUTHOR("Zwane Mwaikambo <zwane@commfireservices.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) MODULE_DESCRIPTION(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	"Driver for National Semiconductor PC87307/PC97307 watchdog component");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) MODULE_LICENSE("GPL");