Skip to content

Commit

Permalink
[WATCHDOG 30/57] omap_wdt: locking, unlocked_ioctl, tidy
Browse files Browse the repository at this point in the history
Review and switch to unlocked_ioctl

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Alan Cox authored and Wim Van Sebroeck committed Jun 13, 2008
1 parent a86b849 commit 12b9df7
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions drivers/watchdog/omap_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
#include <linux/clk.h>
#include <linux/bitops.h>

#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/hardware.h>
#include </io.h>
#include <linux/uaccess.h>
#include <linux/hardware.h>

#include <asm/arch/prcm.h>

Expand All @@ -54,11 +54,12 @@ module_param(timer_margin, uint, 0);
MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");

static int omap_wdt_users;
static struct clk *armwdt_ck = NULL;
static struct clk *mpu_wdt_ick = NULL;
static struct clk *mpu_wdt_fck = NULL;
static struct clk *armwdt_ck;
static struct clk *mpu_wdt_ick;
static struct clk *mpu_wdt_fck;

static unsigned int wdt_trgr_pattern = 0x1234;
static spinlock_t wdt_lock;

static void omap_wdt_ping(void)
{
Expand Down Expand Up @@ -174,22 +175,23 @@ static int omap_wdt_release(struct inode *inode, struct file *file)
return 0;
}

static ssize_t
omap_wdt_write(struct file *file, const char __user *data,
static ssize_t omap_wdt_write(struct file *file, const char __user *data,
size_t len, loff_t *ppos)
{
/* Refresh LOAD_TIME. */
if (len)
if (len) {
spin_lock(&wdt_lock);
omap_wdt_ping();
spin_unlock(&wdt_lock);
}
return len;
}

static int
omap_wdt_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int new_margin;
static struct watchdog_info ident = {
static const struct watchdog_info ident = {
.identity = "OMAP Watchdog",
.options = WDIOF_SETTIMEOUT,
.firmware_version = 0,
Expand All @@ -211,18 +213,22 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
return put_user(omap_prcm_get_reset_sources(),
(int __user *)arg);
case WDIOC_KEEPALIVE:
spin_lock(&wdt_lock);
omap_wdt_ping();
spin_unlock(&wdt_lock);
return 0;
case WDIOC_SETTIMEOUT:
if (get_user(new_margin, (int __user *)arg))
return -EFAULT;
omap_wdt_adjust_timeout(new_margin);

spin_lock(&wdt_lock);
omap_wdt_disable();
omap_wdt_set_timeout();
omap_wdt_enable();

omap_wdt_ping();
spin_unlock(&wdt_lock);
/* Fall */
case WDIOC_GETTIMEOUT:
return put_user(timer_margin, (int __user *)arg);
Expand All @@ -232,7 +238,7 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
static const struct file_operations omap_wdt_fops = {
.owner = THIS_MODULE,
.write = omap_wdt_write,
.ioctl = omap_wdt_ioctl,
.unlocked_ioctl = omap_wdt_ioctl,
.open = omap_wdt_open,
.release = omap_wdt_release,
};
Expand Down Expand Up @@ -373,6 +379,7 @@ static struct platform_driver omap_wdt_driver = {

static int __init omap_wdt_init(void)
{
spin_lock_init(&wdt_lock);
return platform_driver_register(&omap_wdt_driver);
}

Expand Down

0 comments on commit 12b9df7

Please sign in to comment.