diff options
Diffstat (limited to 'drivers/watchdog/at91rm9200_wdt.c')
-rw-r--r-- | drivers/watchdog/at91rm9200_wdt.c | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c index 9ff9a9565320..bb79f649dc7e 100644 --- a/drivers/watchdog/at91rm9200_wdt.c +++ b/drivers/watchdog/at91rm9200_wdt.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
22 | #include <linux/watchdog.h> | 22 | #include <linux/watchdog.h> |
23 | #include <asm/uaccess.h> | 23 | #include <linux/uaccess.h> |
24 | #include <asm/arch/at91_st.h> | 24 | #include <asm/arch/at91_st.h> |
25 | 25 | ||
26 | 26 | ||
@@ -31,11 +31,14 @@ static int wdt_time = WDT_DEFAULT_TIME; | |||
31 | static int nowayout = WATCHDOG_NOWAYOUT; | 31 | static int nowayout = WATCHDOG_NOWAYOUT; |
32 | 32 | ||
33 | module_param(wdt_time, int, 0); | 33 | module_param(wdt_time, int, 0); |
34 | MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")"); | 34 | MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" |
35 | __MODULE_STRING(WDT_DEFAULT_TIME) ")"); | ||
35 | 36 | ||
36 | #ifdef CONFIG_WATCHDOG_NOWAYOUT | 37 | #ifdef CONFIG_WATCHDOG_NOWAYOUT |
37 | module_param(nowayout, int, 0); | 38 | module_param(nowayout, int, 0); |
38 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | 39 | MODULE_PARM_DESC(nowayout, |
40 | "Watchdog cannot be stopped once started (default=" | ||
41 | __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
39 | #endif | 42 | #endif |
40 | 43 | ||
41 | 44 | ||
@@ -46,7 +49,7 @@ static unsigned long at91wdt_busy; | |||
46 | /* | 49 | /* |
47 | * Disable the watchdog. | 50 | * Disable the watchdog. |
48 | */ | 51 | */ |
49 | static void inline at91_wdt_stop(void) | 52 | static inline void at91_wdt_stop(void) |
50 | { | 53 | { |
51 | at91_sys_write(AT91_ST_WDMR, AT91_ST_EXTEN); | 54 | at91_sys_write(AT91_ST_WDMR, AT91_ST_EXTEN); |
52 | } | 55 | } |
@@ -54,16 +57,17 @@ static void inline at91_wdt_stop(void) | |||
54 | /* | 57 | /* |
55 | * Enable and reset the watchdog. | 58 | * Enable and reset the watchdog. |
56 | */ | 59 | */ |
57 | static void inline at91_wdt_start(void) | 60 | static inline void at91_wdt_start(void) |
58 | { | 61 | { |
59 | at91_sys_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN | (((65536 * wdt_time) >> 8) & AT91_ST_WDV)); | 62 | at91_sys_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN | |
63 | (((65536 * wdt_time) >> 8) & AT91_ST_WDV)); | ||
60 | at91_sys_write(AT91_ST_CR, AT91_ST_WDRST); | 64 | at91_sys_write(AT91_ST_CR, AT91_ST_WDRST); |
61 | } | 65 | } |
62 | 66 | ||
63 | /* | 67 | /* |
64 | * Reload the watchdog timer. (ie, pat the watchdog) | 68 | * Reload the watchdog timer. (ie, pat the watchdog) |
65 | */ | 69 | */ |
66 | static void inline at91_wdt_reload(void) | 70 | static inline void at91_wdt_reload(void) |
67 | { | 71 | { |
68 | at91_sys_write(AT91_ST_CR, AT91_ST_WDRST); | 72 | at91_sys_write(AT91_ST_CR, AT91_ST_WDRST); |
69 | } | 73 | } |
@@ -89,8 +93,9 @@ static int at91_wdt_open(struct inode *inode, struct file *file) | |||
89 | */ | 93 | */ |
90 | static int at91_wdt_close(struct inode *inode, struct file *file) | 94 | static int at91_wdt_close(struct inode *inode, struct file *file) |
91 | { | 95 | { |
96 | /* Disable the watchdog when file is closed */ | ||
92 | if (!nowayout) | 97 | if (!nowayout) |
93 | at91_wdt_stop(); /* Disable the watchdog when file is closed */ | 98 | at91_wdt_stop(); |
94 | 99 | ||
95 | clear_bit(0, &at91wdt_busy); | 100 | clear_bit(0, &at91wdt_busy); |
96 | return 0; | 101 | return 0; |
@@ -110,7 +115,8 @@ static int at91_wdt_settimeout(int new_time) | |||
110 | if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) | 115 | if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) |
111 | return -EINVAL; | 116 | return -EINVAL; |
112 | 117 | ||
113 | /* Set new watchdog time. It will be used when at91_wdt_start() is called. */ | 118 | /* Set new watchdog time. It will be used when |
119 | at91_wdt_start() is called. */ | ||
114 | wdt_time = new_time; | 120 | wdt_time = new_time; |
115 | return 0; | 121 | return 0; |
116 | } | 122 | } |
@@ -123,60 +129,52 @@ static struct watchdog_info at91_wdt_info = { | |||
123 | /* | 129 | /* |
124 | * Handle commands from user-space. | 130 | * Handle commands from user-space. |
125 | */ | 131 | */ |
126 | static int at91_wdt_ioctl(struct inode *inode, struct file *file, | 132 | static long at91_wdt_ioct(struct file *file, |
127 | unsigned int cmd, unsigned long arg) | 133 | unsigned int cmd, unsigned long arg) |
128 | { | 134 | { |
129 | void __user *argp = (void __user *)arg; | 135 | void __user *argp = (void __user *)arg; |
130 | int __user *p = argp; | 136 | int __user *p = argp; |
131 | int new_value; | 137 | int new_value; |
132 | 138 | ||
133 | switch(cmd) { | 139 | switch (cmd) { |
134 | case WDIOC_KEEPALIVE: | 140 | case WDIOC_KEEPALIVE: |
135 | at91_wdt_reload(); /* pat the watchdog */ | 141 | at91_wdt_reload(); /* pat the watchdog */ |
136 | return 0; | 142 | return 0; |
137 | 143 | case WDIOC_GETSUPPORT: | |
138 | case WDIOC_GETSUPPORT: | 144 | return copy_to_user(argp, &at91_wdt_info, |
139 | return copy_to_user(argp, &at91_wdt_info, sizeof(at91_wdt_info)) ? -EFAULT : 0; | 145 | sizeof(at91_wdt_info)) ? -EFAULT : 0; |
140 | 146 | case WDIOC_SETTIMEOUT: | |
141 | case WDIOC_SETTIMEOUT: | 147 | if (get_user(new_value, p)) |
142 | if (get_user(new_value, p)) | 148 | return -EFAULT; |
143 | return -EFAULT; | 149 | if (at91_wdt_settimeout(new_value)) |
144 | 150 | return -EINVAL; | |
145 | if (at91_wdt_settimeout(new_value)) | 151 | /* Enable new time value */ |
146 | return -EINVAL; | 152 | at91_wdt_start(); |
147 | 153 | /* Return current value */ | |
148 | /* Enable new time value */ | 154 | return put_user(wdt_time, p); |
155 | case WDIOC_GETTIMEOUT: | ||
156 | return put_user(wdt_time, p); | ||
157 | case WDIOC_GETSTATUS: | ||
158 | case WDIOC_GETBOOTSTATUS: | ||
159 | return put_user(0, p); | ||
160 | case WDIOC_SETOPTIONS: | ||
161 | if (get_user(new_value, p)) | ||
162 | return -EFAULT; | ||
163 | if (new_value & WDIOS_DISABLECARD) | ||
164 | at91_wdt_stop(); | ||
165 | if (new_value & WDIOS_ENABLECARD) | ||
149 | at91_wdt_start(); | 166 | at91_wdt_start(); |
150 | 167 | return 0; | |
151 | /* Return current value */ | 168 | default: |
152 | return put_user(wdt_time, p); | 169 | return -ENOTTY; |
153 | |||
154 | case WDIOC_GETTIMEOUT: | ||
155 | return put_user(wdt_time, p); | ||
156 | |||
157 | case WDIOC_GETSTATUS: | ||
158 | case WDIOC_GETBOOTSTATUS: | ||
159 | return put_user(0, p); | ||
160 | |||
161 | case WDIOC_SETOPTIONS: | ||
162 | if (get_user(new_value, p)) | ||
163 | return -EFAULT; | ||
164 | |||
165 | if (new_value & WDIOS_DISABLECARD) | ||
166 | at91_wdt_stop(); | ||
167 | if (new_value & WDIOS_ENABLECARD) | ||
168 | at91_wdt_start(); | ||
169 | return 0; | ||
170 | |||
171 | default: | ||
172 | return -ENOTTY; | ||
173 | } | 170 | } |
174 | } | 171 | } |
175 | 172 | ||
176 | /* | 173 | /* |
177 | * Pat the watchdog whenever device is written to. | 174 | * Pat the watchdog whenever device is written to. |
178 | */ | 175 | */ |
179 | static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) | 176 | static ssize_t at91_wdt_write(struct file *file, const char *data, |
177 | size_t len, loff_t *ppos) | ||
180 | { | 178 | { |
181 | at91_wdt_reload(); /* pat the watchdog */ | 179 | at91_wdt_reload(); /* pat the watchdog */ |
182 | return len; | 180 | return len; |
@@ -187,7 +185,7 @@ static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, l | |||
187 | static const struct file_operations at91wdt_fops = { | 185 | static const struct file_operations at91wdt_fops = { |
188 | .owner = THIS_MODULE, | 186 | .owner = THIS_MODULE, |
189 | .llseek = no_llseek, | 187 | .llseek = no_llseek, |
190 | .ioctl = at91_wdt_ioctl, | 188 | .unlocked_ioctl = at91_wdt_ioctl, |
191 | .open = at91_wdt_open, | 189 | .open = at91_wdt_open, |
192 | .release = at91_wdt_close, | 190 | .release = at91_wdt_close, |
193 | .write = at91_wdt_write, | 191 | .write = at91_wdt_write, |
@@ -211,7 +209,8 @@ static int __init at91wdt_probe(struct platform_device *pdev) | |||
211 | if (res) | 209 | if (res) |
212 | return res; | 210 | return res; |
213 | 211 | ||
214 | printk("AT91 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : ""); | 212 | printk(KERN_INFO "AT91 Watchdog Timer enabled (%d seconds%s)\n", |
213 | wdt_time, nowayout ? ", nowayout" : ""); | ||
215 | return 0; | 214 | return 0; |
216 | } | 215 | } |
217 | 216 | ||
@@ -265,7 +264,8 @@ static struct platform_driver at91wdt_driver = { | |||
265 | 264 | ||
266 | static int __init at91_wdt_init(void) | 265 | static int __init at91_wdt_init(void) |
267 | { | 266 | { |
268 | /* Check that the heartbeat value is within range; if not reset to the default */ | 267 | /* Check that the heartbeat value is within range; |
268 | if not reset to the default */ | ||
269 | if (at91_wdt_settimeout(wdt_time)) { | 269 | if (at91_wdt_settimeout(wdt_time)) { |
270 | at91_wdt_settimeout(WDT_DEFAULT_TIME); | 270 | at91_wdt_settimeout(WDT_DEFAULT_TIME); |
271 | pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time); | 271 | pr_info("at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time); |