[WATCHDOG 30/57] omap_wdt: locking, unlocked_ioctl, tidy
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:
committed by
Wim Van Sebroeck
parent
a86b849868
commit
12b9df7d21
@@ -41,9 +41,9 @@
|
|||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
|
|
||||||
#include <asm/io.h>
|
#include </io.h>
|
||||||
#include <asm/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/hardware.h>
|
#include <linux/hardware.h>
|
||||||
|
|
||||||
#include <asm/arch/prcm.h>
|
#include <asm/arch/prcm.h>
|
||||||
|
|
||||||
@@ -54,11 +54,12 @@ module_param(timer_margin, uint, 0);
|
|||||||
MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
|
MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
|
||||||
|
|
||||||
static int omap_wdt_users;
|
static int omap_wdt_users;
|
||||||
static struct clk *armwdt_ck = NULL;
|
static struct clk *armwdt_ck;
|
||||||
static struct clk *mpu_wdt_ick = NULL;
|
static struct clk *mpu_wdt_ick;
|
||||||
static struct clk *mpu_wdt_fck = NULL;
|
static struct clk *mpu_wdt_fck;
|
||||||
|
|
||||||
static unsigned int wdt_trgr_pattern = 0x1234;
|
static unsigned int wdt_trgr_pattern = 0x1234;
|
||||||
|
static spinlock_t wdt_lock;
|
||||||
|
|
||||||
static void omap_wdt_ping(void)
|
static void omap_wdt_ping(void)
|
||||||
{
|
{
|
||||||
@@ -174,22 +175,23 @@ static int omap_wdt_release(struct inode *inode, struct file *file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t omap_wdt_write(struct file *file, const char __user *data,
|
||||||
omap_wdt_write(struct file *file, const char __user *data,
|
|
||||||
size_t len, loff_t *ppos)
|
size_t len, loff_t *ppos)
|
||||||
{
|
{
|
||||||
/* Refresh LOAD_TIME. */
|
/* Refresh LOAD_TIME. */
|
||||||
if (len)
|
if (len) {
|
||||||
|
spin_lock(&wdt_lock);
|
||||||
omap_wdt_ping();
|
omap_wdt_ping();
|
||||||
|
spin_unlock(&wdt_lock);
|
||||||
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
|
||||||
omap_wdt_ioctl(struct inode *inode, struct file *file,
|
unsigned long arg)
|
||||||
unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
{
|
||||||
int new_margin;
|
int new_margin;
|
||||||
static struct watchdog_info ident = {
|
static const struct watchdog_info ident = {
|
||||||
.identity = "OMAP Watchdog",
|
.identity = "OMAP Watchdog",
|
||||||
.options = WDIOF_SETTIMEOUT,
|
.options = WDIOF_SETTIMEOUT,
|
||||||
.firmware_version = 0,
|
.firmware_version = 0,
|
||||||
@@ -211,18 +213,22 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
|
|||||||
return put_user(omap_prcm_get_reset_sources(),
|
return put_user(omap_prcm_get_reset_sources(),
|
||||||
(int __user *)arg);
|
(int __user *)arg);
|
||||||
case WDIOC_KEEPALIVE:
|
case WDIOC_KEEPALIVE:
|
||||||
|
spin_lock(&wdt_lock);
|
||||||
omap_wdt_ping();
|
omap_wdt_ping();
|
||||||
|
spin_unlock(&wdt_lock);
|
||||||
return 0;
|
return 0;
|
||||||
case WDIOC_SETTIMEOUT:
|
case WDIOC_SETTIMEOUT:
|
||||||
if (get_user(new_margin, (int __user *)arg))
|
if (get_user(new_margin, (int __user *)arg))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
omap_wdt_adjust_timeout(new_margin);
|
omap_wdt_adjust_timeout(new_margin);
|
||||||
|
|
||||||
|
spin_lock(&wdt_lock);
|
||||||
omap_wdt_disable();
|
omap_wdt_disable();
|
||||||
omap_wdt_set_timeout();
|
omap_wdt_set_timeout();
|
||||||
omap_wdt_enable();
|
omap_wdt_enable();
|
||||||
|
|
||||||
omap_wdt_ping();
|
omap_wdt_ping();
|
||||||
|
spin_unlock(&wdt_lock);
|
||||||
/* Fall */
|
/* Fall */
|
||||||
case WDIOC_GETTIMEOUT:
|
case WDIOC_GETTIMEOUT:
|
||||||
return put_user(timer_margin, (int __user *)arg);
|
return put_user(timer_margin, (int __user *)arg);
|
||||||
@@ -232,7 +238,7 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
|
|||||||
static const struct file_operations omap_wdt_fops = {
|
static const struct file_operations omap_wdt_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.write = omap_wdt_write,
|
.write = omap_wdt_write,
|
||||||
.ioctl = omap_wdt_ioctl,
|
.unlocked_ioctl = omap_wdt_ioctl,
|
||||||
.open = omap_wdt_open,
|
.open = omap_wdt_open,
|
||||||
.release = omap_wdt_release,
|
.release = omap_wdt_release,
|
||||||
};
|
};
|
||||||
@@ -373,6 +379,7 @@ static struct platform_driver omap_wdt_driver = {
|
|||||||
|
|
||||||
static int __init omap_wdt_init(void)
|
static int __init omap_wdt_init(void)
|
||||||
{
|
{
|
||||||
|
spin_lock_init(&wdt_lock);
|
||||||
return platform_driver_register(&omap_wdt_driver);
|
return platform_driver_register(&omap_wdt_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user