mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-02-23 22:16:15 +00:00
[WATCHDOG 39/57] sbc8360: clean up
Review and switch to unlocked_ioctl Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
619a8a2bb1
commit
9f53c8de1a
@ -48,13 +48,12 @@
|
|||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
|
#include <linux/io.h>
|
||||||
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
#include <asm/io.h>
|
|
||||||
#include <asm/uaccess.h>
|
|
||||||
#include <asm/system.h>
|
#include <asm/system.h>
|
||||||
|
|
||||||
static unsigned long sbc8360_is_open;
|
static unsigned long sbc8360_is_open;
|
||||||
static DEFINE_SPINLOCK(sbc8360_lock);
|
|
||||||
static char expect_close;
|
static char expect_close;
|
||||||
|
|
||||||
#define PFX "sbc8360: "
|
#define PFX "sbc8360: "
|
||||||
@ -204,7 +203,8 @@ module_param(timeout, int, 0);
|
|||||||
MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))");
|
MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))");
|
||||||
module_param(nowayout, int, 0);
|
module_param(nowayout, int, 0);
|
||||||
MODULE_PARM_DESC(nowayout,
|
MODULE_PARM_DESC(nowayout,
|
||||||
"Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
"Watchdog cannot be stopped once started (default="
|
||||||
|
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Kernel methods.
|
* Kernel methods.
|
||||||
@ -232,8 +232,8 @@ static void sbc8360_ping(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Userspace pings kernel driver, or requests clean close */
|
/* Userspace pings kernel driver, or requests clean close */
|
||||||
static ssize_t sbc8360_write(struct file *file, const char __user * buf,
|
static ssize_t sbc8360_write(struct file *file, const char __user *buf,
|
||||||
size_t count, loff_t * ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
if (count) {
|
if (count) {
|
||||||
if (!nowayout) {
|
if (!nowayout) {
|
||||||
@ -257,16 +257,12 @@ static ssize_t sbc8360_write(struct file *file, const char __user * buf,
|
|||||||
|
|
||||||
static int sbc8360_open(struct inode *inode, struct file *file)
|
static int sbc8360_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
spin_lock(&sbc8360_lock);
|
if (test_and_set_bit(0, &sbc8360_is_open))
|
||||||
if (test_and_set_bit(0, &sbc8360_is_open)) {
|
|
||||||
spin_unlock(&sbc8360_lock);
|
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
|
||||||
if (nowayout)
|
if (nowayout)
|
||||||
__module_get(THIS_MODULE);
|
__module_get(THIS_MODULE);
|
||||||
|
|
||||||
/* Activate and ping once to start the countdown */
|
/* Activate and ping once to start the countdown */
|
||||||
spin_unlock(&sbc8360_lock);
|
|
||||||
sbc8360_activate();
|
sbc8360_activate();
|
||||||
sbc8360_ping();
|
sbc8360_ping();
|
||||||
return nonseekable_open(inode, file);
|
return nonseekable_open(inode, file);
|
||||||
@ -274,16 +270,14 @@ static int sbc8360_open(struct inode *inode, struct file *file)
|
|||||||
|
|
||||||
static int sbc8360_close(struct inode *inode, struct file *file)
|
static int sbc8360_close(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
spin_lock(&sbc8360_lock);
|
|
||||||
if (expect_close == 42)
|
if (expect_close == 42)
|
||||||
outb(0, SBC8360_ENABLE);
|
outb(0, SBC8360_ENABLE);
|
||||||
else
|
else
|
||||||
printk(KERN_CRIT PFX
|
printk(KERN_CRIT PFX
|
||||||
"SBC8360 device closed unexpectedly. SBC8360 will not stop!\n");
|
"SBC8360 device closed unexpectedly. SBC8360 will not stop!\n");
|
||||||
|
|
||||||
clear_bit(0, &sbc8360_is_open);
|
clear_bit(0, &sbc8360_is_open);
|
||||||
expect_close = 0;
|
expect_close = 0;
|
||||||
spin_unlock(&sbc8360_lock);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,13 +376,13 @@ static int __init sbc8360_init(void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_nomisc:
|
out_nomisc:
|
||||||
unregister_reboot_notifier(&sbc8360_notifier);
|
unregister_reboot_notifier(&sbc8360_notifier);
|
||||||
out_noreboot:
|
out_noreboot:
|
||||||
release_region(SBC8360_BASETIME, 1);
|
release_region(SBC8360_BASETIME, 1);
|
||||||
out_nobasetimereg:
|
out_nobasetimereg:
|
||||||
release_region(SBC8360_ENABLE, 1);
|
release_region(SBC8360_ENABLE, 1);
|
||||||
out:
|
out:
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user