[WATCHDOG 19/57] bfin: watchdog cleanup and unlocked_ioctl
Scan, tidy and check for 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
0e6fa3fb38
commit
9a5f50d34b
|
@ -25,7 +25,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <asm/blackfin.h>
|
#include <asm/blackfin.h>
|
||||||
#include <asm/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
#define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
|
#define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
|
||||||
#define stampit() stamp("here i am")
|
#define stampit() stamp("here i am")
|
||||||
|
@ -148,7 +148,8 @@ static int bfin_wdt_set_timeout(unsigned long t)
|
||||||
int run = bfin_wdt_running();
|
int run = bfin_wdt_running();
|
||||||
bfin_wdt_stop();
|
bfin_wdt_stop();
|
||||||
bfin_write_WDOG_CNT(cnt);
|
bfin_write_WDOG_CNT(cnt);
|
||||||
if (run) bfin_wdt_start();
|
if (run)
|
||||||
|
bfin_wdt_start();
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
|
spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
|
||||||
|
|
||||||
|
@ -191,16 +192,15 @@ static int bfin_wdt_release(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
stampit();
|
stampit();
|
||||||
|
|
||||||
if (expect_close == 42) {
|
if (expect_close == 42)
|
||||||
bfin_wdt_stop();
|
bfin_wdt_stop();
|
||||||
} else {
|
else {
|
||||||
printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
|
printk(KERN_CRIT PFX
|
||||||
|
"Unexpected close, not stopping watchdog!\n");
|
||||||
bfin_wdt_keepalive();
|
bfin_wdt_keepalive();
|
||||||
}
|
}
|
||||||
|
|
||||||
expect_close = 0;
|
expect_close = 0;
|
||||||
clear_bit(0, &open_check);
|
clear_bit(0, &open_check);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ static int bfin_wdt_release(struct inode *inode, struct file *file)
|
||||||
* Pings the watchdog on write.
|
* Pings the watchdog on write.
|
||||||
*/
|
*/
|
||||||
static ssize_t bfin_wdt_write(struct file *file, const char __user *data,
|
static ssize_t bfin_wdt_write(struct file *file, const char __user *data,
|
||||||
size_t len, loff_t *ppos)
|
size_t len, loff_t *ppos)
|
||||||
{
|
{
|
||||||
stampit();
|
stampit();
|
||||||
|
|
||||||
|
@ -241,7 +241,6 @@ static ssize_t bfin_wdt_write(struct file *file, const char __user *data,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bfin_wdt_ioctl - Query Device
|
* bfin_wdt_ioctl - Query Device
|
||||||
* @inode: inode of device
|
|
||||||
* @file: file handle of device
|
* @file: file handle of device
|
||||||
* @cmd: watchdog command
|
* @cmd: watchdog command
|
||||||
* @arg: argument
|
* @arg: argument
|
||||||
|
@ -249,8 +248,8 @@ static ssize_t bfin_wdt_write(struct file *file, const char __user *data,
|
||||||
* Query basic information from the device or ping it, as outlined by the
|
* Query basic information from the device or ping it, as outlined by the
|
||||||
* watchdog API.
|
* watchdog API.
|
||||||
*/
|
*/
|
||||||
static int bfin_wdt_ioctl(struct inode *inode, struct file *file,
|
static long bfin_wdt_ioctl(struct file *file,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
int __user *p = argp;
|
int __user *p = argp;
|
||||||
|
@ -258,59 +257,49 @@ static int bfin_wdt_ioctl(struct inode *inode, struct file *file,
|
||||||
stampit();
|
stampit();
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
default:
|
case WDIOC_GETSUPPORT:
|
||||||
return -ENOTTY;
|
if (copy_to_user(argp, &bfin_wdt_info, sizeof(bfin_wdt_info)))
|
||||||
|
return -EFAULT;
|
||||||
case WDIOC_GETSUPPORT:
|
else
|
||||||
if (copy_to_user(argp, &bfin_wdt_info, sizeof(bfin_wdt_info)))
|
|
||||||
return -EFAULT;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WDIOC_GETSTATUS:
|
|
||||||
case WDIOC_GETBOOTSTATUS:
|
|
||||||
return put_user(!!(_bfin_swrst & SWRST_RESET_WDOG), p);
|
|
||||||
|
|
||||||
case WDIOC_KEEPALIVE:
|
|
||||||
bfin_wdt_keepalive();
|
|
||||||
return 0;
|
return 0;
|
||||||
|
case WDIOC_GETSTATUS:
|
||||||
|
case WDIOC_GETBOOTSTATUS:
|
||||||
|
return put_user(!!(_bfin_swrst & SWRST_RESET_WDOG), p);
|
||||||
|
case WDIOC_KEEPALIVE:
|
||||||
|
bfin_wdt_keepalive();
|
||||||
|
return 0;
|
||||||
|
case WDIOC_SETTIMEOUT: {
|
||||||
|
int new_timeout;
|
||||||
|
|
||||||
case WDIOC_SETTIMEOUT: {
|
if (get_user(new_timeout, p))
|
||||||
int new_timeout;
|
return -EFAULT;
|
||||||
|
if (bfin_wdt_set_timeout(new_timeout))
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
/* Fall */
|
||||||
|
case WDIOC_GETTIMEOUT:
|
||||||
|
return put_user(timeout, p);
|
||||||
|
case WDIOC_SETOPTIONS: {
|
||||||
|
unsigned long flags;
|
||||||
|
int options, ret = -EINVAL;
|
||||||
|
|
||||||
if (get_user(new_timeout, p))
|
if (get_user(options, p))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (bfin_wdt_set_timeout(new_timeout))
|
spin_lock_irqsave(&bfin_wdt_spinlock, flags);
|
||||||
return -EINVAL;
|
if (options & WDIOS_DISABLECARD) {
|
||||||
|
bfin_wdt_stop();
|
||||||
|
ret = 0;
|
||||||
}
|
}
|
||||||
/* Fall */
|
if (options & WDIOS_ENABLECARD) {
|
||||||
case WDIOC_GETTIMEOUT:
|
bfin_wdt_start();
|
||||||
return put_user(timeout, p);
|
ret = 0;
|
||||||
|
|
||||||
case WDIOC_SETOPTIONS: {
|
|
||||||
unsigned long flags;
|
|
||||||
int options, ret = -EINVAL;
|
|
||||||
|
|
||||||
if (get_user(options, p))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&bfin_wdt_spinlock, flags);
|
|
||||||
|
|
||||||
if (options & WDIOS_DISABLECARD) {
|
|
||||||
bfin_wdt_stop();
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options & WDIOS_ENABLECARD) {
|
|
||||||
bfin_wdt_start();
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,8 +312,8 @@ static int bfin_wdt_ioctl(struct inode *inode, struct file *file,
|
||||||
* Handles specific events, such as turning off the watchdog during a
|
* Handles specific events, such as turning off the watchdog during a
|
||||||
* shutdown event.
|
* shutdown event.
|
||||||
*/
|
*/
|
||||||
static int bfin_wdt_notify_sys(struct notifier_block *this, unsigned long code,
|
static int bfin_wdt_notify_sys(struct notifier_block *this,
|
||||||
void *unused)
|
unsigned long code, void *unused)
|
||||||
{
|
{
|
||||||
stampit();
|
stampit();
|
||||||
|
|
||||||
|
@ -379,12 +368,12 @@ static int bfin_wdt_resume(struct platform_device *pdev)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct file_operations bfin_wdt_fops = {
|
static const struct file_operations bfin_wdt_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.llseek = no_llseek,
|
.llseek = no_llseek,
|
||||||
.write = bfin_wdt_write,
|
.write = bfin_wdt_write,
|
||||||
.ioctl = bfin_wdt_ioctl,
|
.unlocked_ioctl = bfin_wdt_ioctl,
|
||||||
.open = bfin_wdt_open,
|
.open = bfin_wdt_open,
|
||||||
.release = bfin_wdt_release,
|
.release = bfin_wdt_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct miscdevice bfin_wdt_miscdev = {
|
static struct miscdevice bfin_wdt_miscdev = {
|
||||||
|
@ -396,8 +385,8 @@ static struct miscdevice bfin_wdt_miscdev = {
|
||||||
static struct watchdog_info bfin_wdt_info = {
|
static struct watchdog_info bfin_wdt_info = {
|
||||||
.identity = "Blackfin Watchdog",
|
.identity = "Blackfin Watchdog",
|
||||||
.options = WDIOF_SETTIMEOUT |
|
.options = WDIOF_SETTIMEOUT |
|
||||||
WDIOF_KEEPALIVEPING |
|
WDIOF_KEEPALIVEPING |
|
||||||
WDIOF_MAGICCLOSE,
|
WDIOF_MAGICCLOSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct notifier_block bfin_wdt_notifier = {
|
static struct notifier_block bfin_wdt_notifier = {
|
||||||
|
@ -416,14 +405,16 @@ static int __devinit bfin_wdt_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
ret = register_reboot_notifier(&bfin_wdt_notifier);
|
ret = register_reboot_notifier(&bfin_wdt_notifier);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_devinit(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret);
|
pr_devinit(KERN_ERR PFX
|
||||||
|
"cannot register reboot notifier (err=%d)\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = misc_register(&bfin_wdt_miscdev);
|
ret = misc_register(&bfin_wdt_miscdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_devinit(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
|
pr_devinit(KERN_ERR PFX
|
||||||
WATCHDOG_MINOR, ret);
|
"cannot register miscdev on minor=%d (err=%d)\n",
|
||||||
|
WATCHDOG_MINOR, ret);
|
||||||
unregister_reboot_notifier(&bfin_wdt_notifier);
|
unregister_reboot_notifier(&bfin_wdt_notifier);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +507,11 @@ MODULE_LICENSE("GPL");
|
||||||
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
|
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
|
||||||
|
|
||||||
module_param(timeout, uint, 0);
|
module_param(timeout, uint, 0);
|
||||||
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=((2^32)/SCLK), default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
|
MODULE_PARM_DESC(timeout,
|
||||||
|
"Watchdog timeout in seconds. (1<=timeout<=((2^32)/SCLK), default="
|
||||||
|
__MODULE_STRING(WATCHDOG_TIMEOUT) ")");
|
||||||
|
|
||||||
module_param(nowayout, int, 0);
|
module_param(nowayout, int, 0);
|
||||||
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
MODULE_PARM_DESC(nowayout,
|
||||||
|
"Watchdog cannot be stopped once started (default="
|
||||||
|
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
|
||||||
|
|
Loading…
Reference in a new issue