diff options
Diffstat (limited to 'drivers/watchdog/booke_wdt.c')
-rw-r--r-- | drivers/watchdog/booke_wdt.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index 770824458d45..c3b78a76f173 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
@@ -18,9 +18,9 @@ | |||
18 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
19 | #include <linux/notifier.h> | 19 | #include <linux/notifier.h> |
20 | #include <linux/watchdog.h> | 20 | #include <linux/watchdog.h> |
21 | #include <linux/uaccess.h> | ||
21 | 22 | ||
22 | #include <asm/reg_booke.h> | 23 | #include <asm/reg_booke.h> |
23 | #include <asm/uaccess.h> | ||
24 | #include <asm/system.h> | 24 | #include <asm/system.h> |
25 | 25 | ||
26 | /* If the kernel parameter wdt=1, the watchdog will be enabled at boot. | 26 | /* If the kernel parameter wdt=1, the watchdog will be enabled at boot. |
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifdef CONFIG_FSL_BOOKE | 34 | #ifdef CONFIG_FSL_BOOKE |
35 | #define WDT_PERIOD_DEFAULT 63 /* Ex. wdt_period=28 bus=333Mhz , reset=~40sec */ | 35 | #define WDT_PERIOD_DEFAULT 63 /* Ex. wdt_period=28 bus=333Mhz,reset=~40sec */ |
36 | #else | 36 | #else |
37 | #define WDT_PERIOD_DEFAULT 3 /* Refer to the PPC40x and PPC4xx manuals */ | 37 | #define WDT_PERIOD_DEFAULT 3 /* Refer to the PPC40x and PPC4xx manuals */ |
38 | #endif /* for timing information */ | 38 | #endif /* for timing information */ |
@@ -82,16 +82,15 @@ static struct watchdog_info ident = { | |||
82 | .identity = "PowerPC Book-E Watchdog", | 82 | .identity = "PowerPC Book-E Watchdog", |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static int booke_wdt_ioctl(struct inode *inode, struct file *file, | 85 | static long booke_wdt_ioctl(struct file *file, |
86 | unsigned int cmd, unsigned long arg) | 86 | unsigned int cmd, unsigned long arg) |
87 | { | 87 | { |
88 | u32 tmp = 0; | 88 | u32 tmp = 0; |
89 | u32 __user *p = (u32 __user *)arg; | 89 | u32 __user *p = (u32 __user *)arg; |
90 | 90 | ||
91 | switch (cmd) { | 91 | switch (cmd) { |
92 | case WDIOC_GETSUPPORT: | 92 | case WDIOC_GETSUPPORT: |
93 | if (copy_to_user((struct watchdog_info __user *)arg, &ident, | 93 | if (copy_to_user(arg, &ident, sizeof(struct watchdog_info))) |
94 | sizeof(struct watchdog_info))) | ||
95 | return -EFAULT; | 94 | return -EFAULT; |
96 | case WDIOC_GETSTATUS: | 95 | case WDIOC_GETSTATUS: |
97 | return put_user(ident.options, p); | 96 | return put_user(ident.options, p); |
@@ -100,16 +99,6 @@ static int booke_wdt_ioctl(struct inode *inode, struct file *file, | |||
100 | tmp = mfspr(SPRN_TSR) & TSR_WRS(3); | 99 | tmp = mfspr(SPRN_TSR) & TSR_WRS(3); |
101 | /* returns 1 if last reset was caused by the WDT */ | 100 | /* returns 1 if last reset was caused by the WDT */ |
102 | return (tmp ? 1 : 0); | 101 | return (tmp ? 1 : 0); |
103 | case WDIOC_KEEPALIVE: | ||
104 | booke_wdt_ping(); | ||
105 | return 0; | ||
106 | case WDIOC_SETTIMEOUT: | ||
107 | if (get_user(booke_wdt_period, p)) | ||
108 | return -EFAULT; | ||
109 | mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period)); | ||
110 | return 0; | ||
111 | case WDIOC_GETTIMEOUT: | ||
112 | return put_user(booke_wdt_period, p); | ||
113 | case WDIOC_SETOPTIONS: | 102 | case WDIOC_SETOPTIONS: |
114 | if (get_user(tmp, p)) | 103 | if (get_user(tmp, p)) |
115 | return -EINVAL; | 104 | return -EINVAL; |
@@ -119,6 +108,17 @@ static int booke_wdt_ioctl(struct inode *inode, struct file *file, | |||
119 | } else | 108 | } else |
120 | return -EINVAL; | 109 | return -EINVAL; |
121 | return 0; | 110 | return 0; |
111 | case WDIOC_KEEPALIVE: | ||
112 | booke_wdt_ping(); | ||
113 | return 0; | ||
114 | case WDIOC_SETTIMEOUT: | ||
115 | if (get_user(booke_wdt_period, p)) | ||
116 | return -EFAULT; | ||
117 | mtspr(SPRN_TCR, (mfspr(SPRN_TCR) & ~WDTP(0)) | | ||
118 | WDTP(booke_wdt_period)); | ||
119 | return 0; | ||
120 | case WDIOC_GETTIMEOUT: | ||
121 | return put_user(booke_wdt_period, p); | ||
122 | default: | 122 | default: |
123 | return -ENOTTY; | 123 | return -ENOTTY; |
124 | } | 124 | } |
@@ -132,8 +132,9 @@ static int booke_wdt_open(struct inode *inode, struct file *file) | |||
132 | if (booke_wdt_enabled == 0) { | 132 | if (booke_wdt_enabled == 0) { |
133 | booke_wdt_enabled = 1; | 133 | booke_wdt_enabled = 1; |
134 | on_each_cpu(__booke_wdt_enable, NULL, 0); | 134 | on_each_cpu(__booke_wdt_enable, NULL, 0); |
135 | printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled " | 135 | printk(KERN_INFO |
136 | "(wdt_period=%d)\n", booke_wdt_period); | 136 | "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", |
137 | booke_wdt_period); | ||
137 | } | 138 | } |
138 | spin_unlock(&booke_wdt_lock); | 139 | spin_unlock(&booke_wdt_lock); |
139 | 140 | ||
@@ -144,7 +145,7 @@ static const struct file_operations booke_wdt_fops = { | |||
144 | .owner = THIS_MODULE, | 145 | .owner = THIS_MODULE, |
145 | .llseek = no_llseek, | 146 | .llseek = no_llseek, |
146 | .write = booke_wdt_write, | 147 | .write = booke_wdt_write, |
147 | .ioctl = booke_wdt_ioctl, | 148 | .unlocked_ioctl = booke_wdt_ioctl, |
148 | .open = booke_wdt_open, | 149 | .open = booke_wdt_open, |
149 | }; | 150 | }; |
150 | 151 | ||
@@ -175,8 +176,9 @@ static int __init booke_wdt_init(void) | |||
175 | 176 | ||
176 | spin_lock(&booke_wdt_lock); | 177 | spin_lock(&booke_wdt_lock); |
177 | if (booke_wdt_enabled == 1) { | 178 | if (booke_wdt_enabled == 1) { |
178 | printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled " | 179 | printk(KERN_INFO |
179 | "(wdt_period=%d)\n", booke_wdt_period); | 180 | "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", |
181 | booke_wdt_period); | ||
180 | on_each_cpu(__booke_wdt_enable, NULL, 0); | 182 | on_each_cpu(__booke_wdt_enable, NULL, 0); |
181 | } | 183 | } |
182 | spin_unlock(&booke_wdt_lock); | 184 | spin_unlock(&booke_wdt_lock); |