aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/omap_wdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/watchdog/omap_wdt.c')
-rw-r--r--drivers/watchdog/omap_wdt.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 74bc39aa1ce8..ccdf069792d9 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -41,9 +41,9 @@
41#include <linux/clk.h> 41#include <linux/clk.h>
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43 43
44#include <asm/io.h> 44#include </io.h>
45#include <asm/uaccess.h> 45#include <linux/uaccess.h>
46#include <asm/hardware.h> 46#include <linux/hardware.h>
47 47
48#include <asm/arch/prcm.h> 48#include <asm/arch/prcm.h>
49 49
@@ -54,11 +54,12 @@ module_param(timer_margin, uint, 0);
54MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)"); 54MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
55 55
56static int omap_wdt_users; 56static int omap_wdt_users;
57static struct clk *armwdt_ck = NULL; 57static struct clk *armwdt_ck;
58static struct clk *mpu_wdt_ick = NULL; 58static struct clk *mpu_wdt_ick;
59static struct clk *mpu_wdt_fck = NULL; 59static struct clk *mpu_wdt_fck;
60 60
61static unsigned int wdt_trgr_pattern = 0x1234; 61static unsigned int wdt_trgr_pattern = 0x1234;
62static spinlock_t wdt_lock;
62 63
63static void omap_wdt_ping(void) 64static void omap_wdt_ping(void)
64{ 65{
@@ -174,22 +175,23 @@ static int omap_wdt_release(struct inode *inode, struct file *file)
174 return 0; 175 return 0;
175} 176}
176 177
177static ssize_t 178static ssize_t omap_wdt_write(struct file *file, const char __user *data,
178omap_wdt_write(struct file *file, const char __user *data,
179 size_t len, loff_t *ppos) 179 size_t len, loff_t *ppos)
180{ 180{
181 /* Refresh LOAD_TIME. */ 181 /* Refresh LOAD_TIME. */
182 if (len) 182 if (len) {
183 spin_lock(&wdt_lock);
183 omap_wdt_ping(); 184 omap_wdt_ping();
185 spin_unlock(&wdt_lock);
186 }
184 return len; 187 return len;
185} 188}
186 189
187static int 190static long omap_wdt_ioctl(struct file *file, unsigned int cmd,
188omap_wdt_ioctl(struct inode *inode, struct file *file, 191 unsigned long arg)
189 unsigned int cmd, unsigned long arg)
190{ 192{
191 int new_margin; 193 int new_margin;
192 static struct watchdog_info ident = { 194 static const struct watchdog_info ident = {
193 .identity = "OMAP Watchdog", 195 .identity = "OMAP Watchdog",
194 .options = WDIOF_SETTIMEOUT, 196 .options = WDIOF_SETTIMEOUT,
195 .firmware_version = 0, 197 .firmware_version = 0,
@@ -211,18 +213,22 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
211 return put_user(omap_prcm_get_reset_sources(), 213 return put_user(omap_prcm_get_reset_sources(),
212 (int __user *)arg); 214 (int __user *)arg);
213 case WDIOC_KEEPALIVE: 215 case WDIOC_KEEPALIVE:
216 spin_lock(&wdt_lock);
214 omap_wdt_ping(); 217 omap_wdt_ping();
218 spin_unlock(&wdt_lock);
215 return 0; 219 return 0;
216 case WDIOC_SETTIMEOUT: 220 case WDIOC_SETTIMEOUT:
217 if (get_user(new_margin, (int __user *)arg)) 221 if (get_user(new_margin, (int __user *)arg))
218 return -EFAULT; 222 return -EFAULT;
219 omap_wdt_adjust_timeout(new_margin); 223 omap_wdt_adjust_timeout(new_margin);
220 224
225 spin_lock(&wdt_lock);
221 omap_wdt_disable(); 226 omap_wdt_disable();
222 omap_wdt_set_timeout(); 227 omap_wdt_set_timeout();
223 omap_wdt_enable(); 228 omap_wdt_enable();
224 229
225 omap_wdt_ping(); 230 omap_wdt_ping();
231 spin_unlock(&wdt_lock);
226 /* Fall */ 232 /* Fall */
227 case WDIOC_GETTIMEOUT: 233 case WDIOC_GETTIMEOUT:
228 return put_user(timer_margin, (int __user *)arg); 234 return put_user(timer_margin, (int __user *)arg);
@@ -232,7 +238,7 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
232static const struct file_operations omap_wdt_fops = { 238static const struct file_operations omap_wdt_fops = {
233 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
234 .write = omap_wdt_write, 240 .write = omap_wdt_write,
235 .ioctl = omap_wdt_ioctl, 241 .unlocked_ioctl = omap_wdt_ioctl,
236 .open = omap_wdt_open, 242 .open = omap_wdt_open,
237 .release = omap_wdt_release, 243 .release = omap_wdt_release,
238}; 244};
@@ -373,6 +379,7 @@ static struct platform_driver omap_wdt_driver = {
373 379
374static int __init omap_wdt_init(void) 380static int __init omap_wdt_init(void)
375{ 381{
382 spin_lock_init(&wdt_lock);
376 return platform_driver_register(&omap_wdt_driver); 383 return platform_driver_register(&omap_wdt_driver);
377} 384}
378 385