aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/agp/frontend.c1
-rw-r--r--drivers/char/agp/generic.c1
-rw-r--r--drivers/char/cyclades.c1
-rw-r--r--drivers/char/drm/Kconfig2
-rw-r--r--drivers/char/drm/drm_drawable.c41
-rw-r--r--drivers/char/drm/drm_pciids.h7
-rw-r--r--drivers/char/drm/i915_irq.c2
-rw-r--r--drivers/char/hangcheck-timer.c2
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c134
-rw-r--r--drivers/char/n_tty.c1
-rw-r--r--drivers/char/random.c67
-rw-r--r--drivers/char/stallion.c81
-rw-r--r--drivers/char/tty_io.c3
-rw-r--r--drivers/char/watchdog/Kconfig7
-rw-r--r--drivers/char/watchdog/Makefile1
-rw-r--r--drivers/char/watchdog/booke_wdt.c2
-rw-r--r--drivers/char/watchdog/ixp2000_wdt.c2
-rw-r--r--drivers/char/watchdog/ks8695_wdt.c308
19 files changed, 481 insertions, 184 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index abcafac64738..ef683ebd367c 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -815,7 +815,7 @@ config SGI_IP27_RTC
815 815
816config GEN_RTC 816config GEN_RTC
817 tristate "Generic /dev/rtc emulation" 817 tristate "Generic /dev/rtc emulation"
818 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 818 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 && !SUPERH
819 ---help--- 819 ---help---
820 If you say Y here and create a character special file /dev/rtc with 820 If you say Y here and create a character special file /dev/rtc with
821 major number 10 and minor number 135 using mknod ("man mknod"), you 821 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index 679d7f972439..c7ed617aa7ff 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -37,6 +37,7 @@
37#include <linux/agpgart.h> 37#include <linux/agpgart.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/sched.h>
40#include <asm/uaccess.h> 41#include <asm/uaccess.h>
41#include <asm/pgtable.h> 42#include <asm/pgtable.h>
42#include "agp.h" 43#include "agp.h"
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 45aeb917ec63..d535c406b319 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -37,6 +37,7 @@
37#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
38#include <linux/dma-mapping.h> 38#include <linux/dma-mapping.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/sched.h>
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/cacheflush.h> 42#include <asm/cacheflush.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index c72ee97d3892..ca376b92162c 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1061,6 +1061,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1061 1061
1062 if (data & info->ignore_status_mask) { 1062 if (data & info->ignore_status_mask) {
1063 info->icount.rx++; 1063 info->icount.rx++;
1064 spin_unlock(&cinfo->card_lock);
1064 return; 1065 return;
1065 } 1066 }
1066 if (tty_buffer_request_room(tty, 1)) { 1067 if (tty_buffer_request_room(tty, 1)) {
diff --git a/drivers/char/drm/Kconfig b/drivers/char/drm/Kconfig
index ef833a1c27eb..0b7ffa5191c6 100644
--- a/drivers/char/drm/Kconfig
+++ b/drivers/char/drm/Kconfig
@@ -6,7 +6,7 @@
6# 6#
7config DRM 7config DRM
8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)" 8 tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
9 depends on (AGP || AGP=n) && PCI 9 depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG
10 help 10 help
11 Kernel-level support for the Direct Rendering Infrastructure (DRI) 11 Kernel-level support for the Direct Rendering Infrastructure (DRI)
12 introduced in XFree86 4.0. If you say Y here, you need to select 12 introduced in XFree86 4.0. If you say Y here, you need to select
diff --git a/drivers/char/drm/drm_drawable.c b/drivers/char/drm/drm_drawable.c
index de37d5f74563..b33313be2547 100644
--- a/drivers/char/drm/drm_drawable.c
+++ b/drivers/char/drm/drm_drawable.c
@@ -172,38 +172,49 @@ int drm_rmdraw(DRM_IOCTL_ARGS)
172 172
173 bitfield_length = idx + 1; 173 bitfield_length = idx + 1;
174 174
175 if (idx != id / (8 * sizeof(*bitfield))) 175 bitfield = NULL;
176 bitfield = drm_alloc(bitfield_length *
177 sizeof(*bitfield), DRM_MEM_BUFS);
178 176
179 if (!bitfield && bitfield_length) { 177 if (bitfield_length) {
180 bitfield = dev->drw_bitfield; 178 if (bitfield_length != dev->drw_bitfield_length)
181 bitfield_length = dev->drw_bitfield_length; 179 bitfield = drm_alloc(bitfield_length *
180 sizeof(*bitfield),
181 DRM_MEM_BUFS);
182
183 if (!bitfield) {
184 bitfield = dev->drw_bitfield;
185 bitfield_length = dev->drw_bitfield_length;
186 }
182 } 187 }
183 } 188 }
184 189
185 if (bitfield != dev->drw_bitfield) { 190 if (bitfield != dev->drw_bitfield) {
186 info_length = 8 * sizeof(*bitfield) * bitfield_length; 191 info_length = 8 * sizeof(*bitfield) * bitfield_length;
187 192
188 info = drm_alloc(info_length * sizeof(*info), DRM_MEM_BUFS); 193 if (info_length) {
194 info = drm_alloc(info_length * sizeof(*info),
195 DRM_MEM_BUFS);
189 196
190 if (!info && info_length) { 197 if (!info) {
191 info = dev->drw_info; 198 info = dev->drw_info;
192 info_length = dev->drw_info_length; 199 info_length = dev->drw_info_length;
193 } 200 }
201 } else
202 info = NULL;
194 203
195 spin_lock_irqsave(&dev->drw_lock, irqflags); 204 spin_lock_irqsave(&dev->drw_lock, irqflags);
196 205
197 memcpy(bitfield, dev->drw_bitfield, bitfield_length * 206 if (bitfield)
198 sizeof(*bitfield)); 207 memcpy(bitfield, dev->drw_bitfield, bitfield_length *
208 sizeof(*bitfield));
199 drm_free(dev->drw_bitfield, sizeof(*bitfield) * 209 drm_free(dev->drw_bitfield, sizeof(*bitfield) *
200 dev->drw_bitfield_length, DRM_MEM_BUFS); 210 dev->drw_bitfield_length, DRM_MEM_BUFS);
201 dev->drw_bitfield = bitfield; 211 dev->drw_bitfield = bitfield;
202 dev->drw_bitfield_length = bitfield_length; 212 dev->drw_bitfield_length = bitfield_length;
203 213
204 if (info != dev->drw_info) { 214 if (info != dev->drw_info) {
205 memcpy(info, dev->drw_info, info_length * 215 if (info)
206 sizeof(*info)); 216 memcpy(info, dev->drw_info, info_length *
217 sizeof(*info));
207 drm_free(dev->drw_info, sizeof(*info) * 218 drm_free(dev->drw_info, sizeof(*info) *
208 dev->drw_info_length, DRM_MEM_BUFS); 219 dev->drw_info_length, DRM_MEM_BUFS);
209 dev->drw_info = info; 220 dev->drw_info = info;
diff --git a/drivers/char/drm/drm_pciids.h b/drivers/char/drm/drm_pciids.h
index 31cdde83713b..177ccc07f968 100644
--- a/drivers/char/drm/drm_pciids.h
+++ b/drivers/char/drm/drm_pciids.h
@@ -102,13 +102,20 @@
102 {0x1002, 0x5653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 102 {0x1002, 0x5653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
103 {0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP}, \ 103 {0x1002, 0x5834, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP}, \
104 {0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \ 104 {0x1002, 0x5835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY}, \
105 {0x1002, 0x5954, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
105 {0x1002, 0x5955, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \ 106 {0x1002, 0x5955, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
107 {0x1002, 0x5974, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
108 {0x1002, 0x5975, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
106 {0x1002, 0x5960, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 109 {0x1002, 0x5960, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
107 {0x1002, 0x5961, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 110 {0x1002, 0x5961, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
108 {0x1002, 0x5962, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 111 {0x1002, 0x5962, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
109 {0x1002, 0x5964, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 112 {0x1002, 0x5964, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
110 {0x1002, 0x5965, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \ 113 {0x1002, 0x5965, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280}, \
111 {0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \ 114 {0x1002, 0x5969, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV100}, \
115 {0x1002, 0x5a41, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
116 {0x1002, 0x5a42, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
117 {0x1002, 0x5a61, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
118 {0x1002, 0x5a62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS400|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_IS_IGPGART}, \
112 {0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ 119 {0x1002, 0x5b60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
113 {0x1002, 0x5b62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ 120 {0x1002, 0x5b62, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
114 {0x1002, 0x5b63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \ 121 {0x1002, 0x5b63, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV380|RADEON_NEW_MEMMAP}, \
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index 78c1ae28f17c..b92062a239f1 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -582,7 +582,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
582{ 582{
583 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 583 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
584 584
585 dev_priv->swaps_lock = SPIN_LOCK_UNLOCKED; 585 spin_lock_init(&dev_priv->swaps_lock);
586 INIT_LIST_HEAD(&dev_priv->vbl_swaps.head); 586 INIT_LIST_HEAD(&dev_priv->vbl_swaps.head);
587 dev_priv->swaps_pending = 0; 587 dev_priv->swaps_pending = 0;
588 588
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index f0e7263dfcde..0e8ceea5ea78 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -48,7 +48,7 @@
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <linux/sysrq.h> 50#include <linux/sysrq.h>
51 51#include <linux/timer.h>
52 52
53#define VERSION_STR "0.9.0" 53#define VERSION_STR "0.9.0"
54 54
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 147c12047cf3..41f78e2c158f 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -50,18 +50,10 @@
50#include <linux/poll.h> 50#include <linux/poll.h>
51#include <linux/string.h> 51#include <linux/string.h>
52#include <linux/ctype.h> 52#include <linux/ctype.h>
53#include <linux/delay.h>
54#include <asm/atomic.h> 53#include <asm/atomic.h>
55 54
56#ifdef CONFIG_X86 55#ifdef CONFIG_X86_LOCAL_APIC
57/* This is ugly, but I've determined that x86 is the only architecture 56#include <asm/apic.h>
58 that can reasonably support the IPMI NMI watchdog timeout at this
59 time. If another architecture adds this capability somehow, it
60 will have to be a somewhat different mechanism and I have no idea
61 how it will work. So in the unlikely event that another
62 architecture supports this, we can figure out a good generic
63 mechanism for it at that time. */
64#define HAVE_DIE_NMI_POST
65#endif 57#endif
66 58
67#define PFX "IPMI Watchdog: " 59#define PFX "IPMI Watchdog: "
@@ -327,11 +319,6 @@ static unsigned char ipmi_version_minor;
327/* If a pretimeout occurs, this is used to allow only one panic to happen. */ 319/* If a pretimeout occurs, this is used to allow only one panic to happen. */
328static atomic_t preop_panic_excl = ATOMIC_INIT(-1); 320static atomic_t preop_panic_excl = ATOMIC_INIT(-1);
329 321
330#ifdef HAVE_DIE_NMI_POST
331static int testing_nmi;
332static int nmi_handler_registered;
333#endif
334
335static int ipmi_heartbeat(void); 322static int ipmi_heartbeat(void);
336static void panic_halt_ipmi_heartbeat(void); 323static void panic_halt_ipmi_heartbeat(void);
337 324
@@ -373,10 +360,6 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg,
373 int hbnow = 0; 360 int hbnow = 0;
374 361
375 362
376 /* These can be cleared as we are setting the timeout. */
377 ipmi_start_timer_on_heartbeat = 0;
378 pretimeout_since_last_heartbeat = 0;
379
380 data[0] = 0; 363 data[0] = 0;
381 WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); 364 WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS);
382 365
@@ -451,12 +434,13 @@ static int ipmi_set_timeout(int do_heartbeat)
451 434
452 wait_for_completion(&set_timeout_wait); 435 wait_for_completion(&set_timeout_wait);
453 436
454 mutex_unlock(&set_timeout_lock);
455
456 if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB) 437 if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB)
457 || ((send_heartbeat_now) 438 || ((send_heartbeat_now)
458 && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY))) 439 && (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY)))
440 {
459 rv = ipmi_heartbeat(); 441 rv = ipmi_heartbeat();
442 }
443 mutex_unlock(&set_timeout_lock);
460 444
461out: 445out:
462 return rv; 446 return rv;
@@ -536,10 +520,12 @@ static int ipmi_heartbeat(void)
536 int rv; 520 int rv;
537 struct ipmi_system_interface_addr addr; 521 struct ipmi_system_interface_addr addr;
538 522
539 if (ipmi_ignore_heartbeat) 523 if (ipmi_ignore_heartbeat) {
540 return 0; 524 return 0;
525 }
541 526
542 if (ipmi_start_timer_on_heartbeat) { 527 if (ipmi_start_timer_on_heartbeat) {
528 ipmi_start_timer_on_heartbeat = 0;
543 ipmi_watchdog_state = action_val; 529 ipmi_watchdog_state = action_val;
544 return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); 530 return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB);
545 } else if (pretimeout_since_last_heartbeat) { 531 } else if (pretimeout_since_last_heartbeat) {
@@ -547,6 +533,7 @@ static int ipmi_heartbeat(void)
547 We don't want to set the action, though, we want to 533 We don't want to set the action, though, we want to
548 leave that alone (thus it can't be combined with the 534 leave that alone (thus it can't be combined with the
549 above operation. */ 535 above operation. */
536 pretimeout_since_last_heartbeat = 0;
550 return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY); 537 return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
551 } 538 }
552 539
@@ -934,45 +921,6 @@ static void ipmi_register_watchdog(int ipmi_intf)
934 printk(KERN_CRIT PFX "Unable to register misc device\n"); 921 printk(KERN_CRIT PFX "Unable to register misc device\n");
935 } 922 }
936 923
937#ifdef HAVE_DIE_NMI_POST
938 if (nmi_handler_registered) {
939 int old_pretimeout = pretimeout;
940 int old_timeout = timeout;
941 int old_preop_val = preop_val;
942
943 /* Set the pretimeout to go off in a second and give
944 ourselves plenty of time to stop the timer. */
945 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
946 preop_val = WDOG_PREOP_NONE; /* Make sure nothing happens */
947 pretimeout = 99;
948 timeout = 100;
949
950 testing_nmi = 1;
951
952 rv = ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB);
953 if (rv) {
954 printk(KERN_WARNING PFX "Error starting timer to"
955 " test NMI: 0x%x. The NMI pretimeout will"
956 " likely not work\n", rv);
957 rv = 0;
958 goto out_restore;
959 }
960
961 msleep(1500);
962
963 if (testing_nmi != 2) {
964 printk(KERN_WARNING PFX "IPMI NMI didn't seem to"
965 " occur. The NMI pretimeout will"
966 " likely not work\n");
967 }
968 out_restore:
969 testing_nmi = 0;
970 preop_val = old_preop_val;
971 pretimeout = old_pretimeout;
972 timeout = old_timeout;
973 }
974#endif
975
976 out: 924 out:
977 up_write(&register_sem); 925 up_write(&register_sem);
978 926
@@ -982,10 +930,6 @@ static void ipmi_register_watchdog(int ipmi_intf)
982 ipmi_watchdog_state = action_val; 930 ipmi_watchdog_state = action_val;
983 ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB); 931 ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB);
984 printk(KERN_INFO PFX "Starting now!\n"); 932 printk(KERN_INFO PFX "Starting now!\n");
985 } else {
986 /* Stop the timer now. */
987 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
988 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
989 } 933 }
990} 934}
991 935
@@ -1022,28 +966,17 @@ static void ipmi_unregister_watchdog(int ipmi_intf)
1022 up_write(&register_sem); 966 up_write(&register_sem);
1023} 967}
1024 968
1025#ifdef HAVE_DIE_NMI_POST 969#ifdef HAVE_NMI_HANDLER
1026static int 970static int
1027ipmi_nmi(struct notifier_block *self, unsigned long val, void *data) 971ipmi_nmi(void *dev_id, int cpu, int handled)
1028{ 972{
1029 if (val != DIE_NMI_POST)
1030 return NOTIFY_OK;
1031
1032 if (testing_nmi) {
1033 testing_nmi = 2;
1034 return NOTIFY_STOP;
1035 }
1036
1037 /* If we are not expecting a timeout, ignore it. */ 973 /* If we are not expecting a timeout, ignore it. */
1038 if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) 974 if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE)
1039 return NOTIFY_OK; 975 return NOTIFY_DONE;
1040
1041 if (preaction_val != WDOG_PRETIMEOUT_NMI)
1042 return NOTIFY_OK;
1043 976
1044 /* If no one else handled the NMI, we assume it was the IPMI 977 /* If no one else handled the NMI, we assume it was the IPMI
1045 watchdog. */ 978 watchdog. */
1046 if (preop_val == WDOG_PREOP_PANIC) { 979 if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) {
1047 /* On some machines, the heartbeat will give 980 /* On some machines, the heartbeat will give
1048 an error and not work unless we re-enable 981 an error and not work unless we re-enable
1049 the timer. So do so. */ 982 the timer. So do so. */
@@ -1052,12 +985,18 @@ ipmi_nmi(struct notifier_block *self, unsigned long val, void *data)
1052 panic(PFX "pre-timeout"); 985 panic(PFX "pre-timeout");
1053 } 986 }
1054 987
1055 return NOTIFY_STOP; 988 return NOTIFY_DONE;
1056} 989}
1057 990
1058static struct notifier_block ipmi_nmi_handler = { 991static struct nmi_handler ipmi_nmi_handler =
1059 .notifier_call = ipmi_nmi 992{
993 .link = LIST_HEAD_INIT(ipmi_nmi_handler.link),
994 .dev_name = "ipmi_watchdog",
995 .dev_id = NULL,
996 .handler = ipmi_nmi,
997 .priority = 0, /* Call us last. */
1060}; 998};
999int nmi_handler_registered;
1061#endif 1000#endif
1062 1001
1063static int wdog_reboot_handler(struct notifier_block *this, 1002static int wdog_reboot_handler(struct notifier_block *this,
@@ -1174,7 +1113,7 @@ static int preaction_op(const char *inval, char *outval)
1174 preaction_val = WDOG_PRETIMEOUT_NONE; 1113 preaction_val = WDOG_PRETIMEOUT_NONE;
1175 else if (strcmp(inval, "pre_smi") == 0) 1114 else if (strcmp(inval, "pre_smi") == 0)
1176 preaction_val = WDOG_PRETIMEOUT_SMI; 1115 preaction_val = WDOG_PRETIMEOUT_SMI;
1177#ifdef HAVE_DIE_NMI_POST 1116#ifdef HAVE_NMI_HANDLER
1178 else if (strcmp(inval, "pre_nmi") == 0) 1117 else if (strcmp(inval, "pre_nmi") == 0)
1179 preaction_val = WDOG_PRETIMEOUT_NMI; 1118 preaction_val = WDOG_PRETIMEOUT_NMI;
1180#endif 1119#endif
@@ -1208,7 +1147,7 @@ static int preop_op(const char *inval, char *outval)
1208 1147
1209static void check_parms(void) 1148static void check_parms(void)
1210{ 1149{
1211#ifdef HAVE_DIE_NMI_POST 1150#ifdef HAVE_NMI_HANDLER
1212 int do_nmi = 0; 1151 int do_nmi = 0;
1213 int rv; 1152 int rv;
1214 1153
@@ -1221,9 +1160,20 @@ static void check_parms(void)
1221 preop_op("preop_none", NULL); 1160 preop_op("preop_none", NULL);
1222 do_nmi = 0; 1161 do_nmi = 0;
1223 } 1162 }
1163#ifdef CONFIG_X86_LOCAL_APIC
1164 if (nmi_watchdog == NMI_IO_APIC) {
1165 printk(KERN_WARNING PFX "nmi_watchdog is set to IO APIC"
1166 " mode (value is %d), that is incompatible"
1167 " with using NMI in the IPMI watchdog."
1168 " Disabling IPMI nmi pretimeout.\n",
1169 nmi_watchdog);
1170 preaction_val = WDOG_PRETIMEOUT_NONE;
1171 do_nmi = 0;
1172 }
1173#endif
1224 } 1174 }
1225 if (do_nmi && !nmi_handler_registered) { 1175 if (do_nmi && !nmi_handler_registered) {
1226 rv = register_die_notifier(&ipmi_nmi_handler); 1176 rv = request_nmi(&ipmi_nmi_handler);
1227 if (rv) { 1177 if (rv) {
1228 printk(KERN_WARNING PFX 1178 printk(KERN_WARNING PFX
1229 "Can't register nmi handler\n"); 1179 "Can't register nmi handler\n");
@@ -1231,7 +1181,7 @@ static void check_parms(void)
1231 } else 1181 } else
1232 nmi_handler_registered = 1; 1182 nmi_handler_registered = 1;
1233 } else if (!do_nmi && nmi_handler_registered) { 1183 } else if (!do_nmi && nmi_handler_registered) {
1234 unregister_die_notifier(&ipmi_nmi_handler); 1184 release_nmi(&ipmi_nmi_handler);
1235 nmi_handler_registered = 0; 1185 nmi_handler_registered = 0;
1236 } 1186 }
1237#endif 1187#endif
@@ -1267,9 +1217,9 @@ static int __init ipmi_wdog_init(void)
1267 1217
1268 rv = ipmi_smi_watcher_register(&smi_watcher); 1218 rv = ipmi_smi_watcher_register(&smi_watcher);
1269 if (rv) { 1219 if (rv) {
1270#ifdef HAVE_DIE_NMI_POST 1220#ifdef HAVE_NMI_HANDLER
1271 if (nmi_handler_registered) 1221 if (preaction_val == WDOG_PRETIMEOUT_NMI)
1272 unregister_die_notifier(&ipmi_nmi_handler); 1222 release_nmi(&ipmi_nmi_handler);
1273#endif 1223#endif
1274 atomic_notifier_chain_unregister(&panic_notifier_list, 1224 atomic_notifier_chain_unregister(&panic_notifier_list,
1275 &wdog_panic_notifier); 1225 &wdog_panic_notifier);
@@ -1288,9 +1238,9 @@ static void __exit ipmi_wdog_exit(void)
1288 ipmi_smi_watcher_unregister(&smi_watcher); 1238 ipmi_smi_watcher_unregister(&smi_watcher);
1289 ipmi_unregister_watchdog(watchdog_ifnum); 1239 ipmi_unregister_watchdog(watchdog_ifnum);
1290 1240
1291#ifdef HAVE_DIE_NMI_POST 1241#ifdef HAVE_NMI_HANDLER
1292 if (nmi_handler_registered) 1242 if (nmi_handler_registered)
1293 unregister_die_notifier(&ipmi_nmi_handler); 1243 release_nmi(&ipmi_nmi_handler);
1294#endif 1244#endif
1295 1245
1296 atomic_notifier_chain_unregister(&panic_notifier_list, 1246 atomic_notifier_chain_unregister(&panic_notifier_list,
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index b3d4ccc33a47..154f42203b05 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1191,6 +1191,7 @@ static int job_control(struct tty_struct *tty, struct file *file)
1191 is_current_pgrp_orphaned()) 1191 is_current_pgrp_orphaned())
1192 return -EIO; 1192 return -EIO;
1193 kill_pgrp(task_pgrp(current), SIGTTIN, 1); 1193 kill_pgrp(task_pgrp(current), SIGTTIN, 1);
1194 set_thread_flag(TIF_SIGPENDING);
1194 return -ERESTARTSYS; 1195 return -ERESTARTSYS;
1195 } 1196 }
1196 } 1197 }
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 46c1b97748b6..0474cac4a84e 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -760,7 +760,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
760 760
761static void extract_buf(struct entropy_store *r, __u8 *out) 761static void extract_buf(struct entropy_store *r, __u8 *out)
762{ 762{
763 int i, x; 763 int i;
764 __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS]; 764 __u32 data[16], buf[5 + SHA_WORKSPACE_WORDS];
765 765
766 sha_init(buf); 766 sha_init(buf);
@@ -772,9 +772,11 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
772 * attempts to find previous ouputs), unless the hash 772 * attempts to find previous ouputs), unless the hash
773 * function can be inverted. 773 * function can be inverted.
774 */ 774 */
775 for (i = 0, x = 0; i < r->poolinfo->poolwords; i += 16, x+=2) { 775 for (i = 0; i < r->poolinfo->poolwords; i += 16) {
776 sha_transform(buf, (__u8 *)r->pool+i, buf + 5); 776 /* hash blocks of 16 words = 512 bits */
777 add_entropy_words(r, &buf[x % 5], 1); 777 sha_transform(buf, (__u8 *)(r->pool + i), buf + 5);
778 /* feed back portion of the resulting hash */
779 add_entropy_words(r, &buf[i % 5], 1);
778 } 780 }
779 781
780 /* 782 /*
@@ -782,7 +784,7 @@ static void extract_buf(struct entropy_store *r, __u8 *out)
782 * portion of the pool while mixing, and hash one 784 * portion of the pool while mixing, and hash one
783 * final time. 785 * final time.
784 */ 786 */
785 __add_entropy_words(r, &buf[x % 5], 1, data); 787 __add_entropy_words(r, &buf[i % 5], 1, data);
786 sha_transform(buf, (__u8 *)data, buf + 5); 788 sha_transform(buf, (__u8 *)data, buf + 5);
787 789
788 /* 790 /*
@@ -1018,37 +1020,44 @@ random_poll(struct file *file, poll_table * wait)
1018 return mask; 1020 return mask;
1019} 1021}
1020 1022
1021static ssize_t 1023static int
1022random_write(struct file * file, const char __user * buffer, 1024write_pool(struct entropy_store *r, const char __user *buffer, size_t count)
1023 size_t count, loff_t *ppos)
1024{ 1025{
1025 int ret = 0;
1026 size_t bytes; 1026 size_t bytes;
1027 __u32 buf[16]; 1027 __u32 buf[16];
1028 const char __user *p = buffer; 1028 const char __user *p = buffer;
1029 size_t c = count;
1030 1029
1031 while (c > 0) { 1030 while (count > 0) {
1032 bytes = min(c, sizeof(buf)); 1031 bytes = min(count, sizeof(buf));
1032 if (copy_from_user(&buf, p, bytes))
1033 return -EFAULT;
1033 1034
1034 bytes -= copy_from_user(&buf, p, bytes); 1035 count -= bytes;
1035 if (!bytes) {
1036 ret = -EFAULT;
1037 break;
1038 }
1039 c -= bytes;
1040 p += bytes; 1036 p += bytes;
1041 1037
1042 add_entropy_words(&input_pool, buf, (bytes + 3) / 4); 1038 add_entropy_words(r, buf, (bytes + 3) / 4);
1043 }
1044 if (p == buffer) {
1045 return (ssize_t)ret;
1046 } else {
1047 struct inode *inode = file->f_path.dentry->d_inode;
1048 inode->i_mtime = current_fs_time(inode->i_sb);
1049 mark_inode_dirty(inode);
1050 return (ssize_t)(p - buffer);
1051 } 1039 }
1040
1041 return 0;
1042}
1043
1044static ssize_t
1045random_write(struct file * file, const char __user * buffer,
1046 size_t count, loff_t *ppos)
1047{
1048 size_t ret;
1049 struct inode *inode = file->f_path.dentry->d_inode;
1050
1051 ret = write_pool(&blocking_pool, buffer, count);
1052 if (ret)
1053 return ret;
1054 ret = write_pool(&nonblocking_pool, buffer, count);
1055 if (ret)
1056 return ret;
1057
1058 inode->i_mtime = current_fs_time(inode->i_sb);
1059 mark_inode_dirty(inode);
1060 return (ssize_t)count;
1052} 1061}
1053 1062
1054static int 1063static int
@@ -1087,8 +1096,8 @@ random_ioctl(struct inode * inode, struct file * file,
1087 return -EINVAL; 1096 return -EINVAL;
1088 if (get_user(size, p++)) 1097 if (get_user(size, p++))
1089 return -EFAULT; 1098 return -EFAULT;
1090 retval = random_write(file, (const char __user *) p, 1099 retval = write_pool(&input_pool, (const char __user *)p,
1091 size, &file->f_pos); 1100 size);
1092 if (retval < 0) 1101 if (retval < 0)
1093 return retval; 1102 return retval;
1094 credit_entropy_store(&input_pool, ent_count); 1103 credit_entropy_store(&input_pool, ent_count);
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index e45113a7a472..45bf2a262a85 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -2172,11 +2172,12 @@ static int __devinit stl_initech(struct stlbrd *brdp)
2172 } 2172 }
2173 status = inb(ioaddr + ECH_PNLSTATUS); 2173 status = inb(ioaddr + ECH_PNLSTATUS);
2174 if ((status & ECH_PNLIDMASK) != nxtid) 2174 if ((status & ECH_PNLIDMASK) != nxtid)
2175 goto err_fr; 2175 break;
2176 panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL); 2176 panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
2177 if (!panelp) { 2177 if (!panelp) {
2178 printk("STALLION: failed to allocate memory " 2178 printk("STALLION: failed to allocate memory "
2179 "(size=%Zd)\n", sizeof(struct stlpanel)); 2179 "(size=%Zd)\n", sizeof(struct stlpanel));
2180 retval = -ENOMEM;
2180 goto err_fr; 2181 goto err_fr;
2181 } 2182 }
2182 panelp->magic = STL_PANELMAGIC; 2183 panelp->magic = STL_PANELMAGIC;
@@ -2223,8 +2224,10 @@ static int __devinit stl_initech(struct stlbrd *brdp)
2223 brdp->nrports += panelp->nrports; 2224 brdp->nrports += panelp->nrports;
2224 brdp->panels[panelnr++] = panelp; 2225 brdp->panels[panelnr++] = panelp;
2225 if ((brdp->brdtype != BRD_ECHPCI) && 2226 if ((brdp->brdtype != BRD_ECHPCI) &&
2226 (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) 2227 (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) {
2228 retval = -EINVAL;
2227 goto err_fr; 2229 goto err_fr;
2230 }
2228 } 2231 }
2229 2232
2230 brdp->nrpanels = panelnr; 2233 brdp->nrpanels = panelnr;
@@ -2371,6 +2374,7 @@ static int __devinit stl_pciprobe(struct pci_dev *pdev,
2371 dev_err(&pdev->dev, "too many boards found, " 2374 dev_err(&pdev->dev, "too many boards found, "
2372 "maximum supported %d\n", STL_MAXBRDS); 2375 "maximum supported %d\n", STL_MAXBRDS);
2373 mutex_unlock(&stl_brdslock); 2376 mutex_unlock(&stl_brdslock);
2377 retval = -ENODEV;
2374 goto err_fr; 2378 goto err_fr;
2375 } 2379 }
2376 brdp->brdnr = (unsigned int)brdnr; 2380 brdp->brdnr = (unsigned int)brdnr;
@@ -4710,6 +4714,29 @@ static int __init stallion_module_init(void)
4710 spin_lock_init(&stallion_lock); 4714 spin_lock_init(&stallion_lock);
4711 spin_lock_init(&brd_lock); 4715 spin_lock_init(&brd_lock);
4712 4716
4717 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4718 if (!stl_serial) {
4719 retval = -ENOMEM;
4720 goto err;
4721 }
4722
4723 stl_serial->owner = THIS_MODULE;
4724 stl_serial->driver_name = stl_drvname;
4725 stl_serial->name = "ttyE";
4726 stl_serial->major = STL_SERIALMAJOR;
4727 stl_serial->minor_start = 0;
4728 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4729 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4730 stl_serial->init_termios = stl_deftermios;
4731 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4732 tty_set_operations(stl_serial, &stl_ops);
4733
4734 retval = tty_register_driver(stl_serial);
4735 if (retval) {
4736 printk("STALLION: failed to register serial driver\n");
4737 goto err_frtty;
4738 }
4739
4713/* 4740/*
4714 * Find any dynamically supported boards. That is via module load 4741 * Find any dynamically supported boards. That is via module load
4715 * line options. 4742 * line options.
@@ -4739,13 +4766,9 @@ static int __init stallion_module_init(void)
4739 4766
4740 /* this has to be _after_ isa finding because of locking */ 4767 /* this has to be _after_ isa finding because of locking */
4741 retval = pci_register_driver(&stl_pcidriver); 4768 retval = pci_register_driver(&stl_pcidriver);
4742 if (retval && stl_nrbrds == 0) 4769 if (retval && stl_nrbrds == 0) {
4743 goto err; 4770 printk(KERN_ERR "STALLION: can't register pci driver\n");
4744 4771 goto err_unrtty;
4745 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
4746 if (!stl_serial) {
4747 retval = -ENOMEM;
4748 goto err_pcidr;
4749 } 4772 }
4750 4773
4751/* 4774/*
@@ -4756,43 +4779,18 @@ static int __init stallion_module_init(void)
4756 printk("STALLION: failed to register serial board device\n"); 4779 printk("STALLION: failed to register serial board device\n");
4757 4780
4758 stallion_class = class_create(THIS_MODULE, "staliomem"); 4781 stallion_class = class_create(THIS_MODULE, "staliomem");
4759 if (IS_ERR(stallion_class)) { 4782 if (IS_ERR(stallion_class))
4760 retval = PTR_ERR(stallion_class); 4783 printk("STALLION: failed to create class\n");
4761 goto err_reg;
4762 }
4763 for (i = 0; i < 4; i++) 4784 for (i = 0; i < 4; i++)
4764 class_device_create(stallion_class, NULL, 4785 class_device_create(stallion_class, NULL,
4765 MKDEV(STL_SIOMEMMAJOR, i), NULL, 4786 MKDEV(STL_SIOMEMMAJOR, i), NULL,
4766 "staliomem%d", i); 4787 "staliomem%d", i);
4767 4788
4768 stl_serial->owner = THIS_MODULE;
4769 stl_serial->driver_name = stl_drvname;
4770 stl_serial->name = "ttyE";
4771 stl_serial->major = STL_SERIALMAJOR;
4772 stl_serial->minor_start = 0;
4773 stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
4774 stl_serial->subtype = SERIAL_TYPE_NORMAL;
4775 stl_serial->init_termios = stl_deftermios;
4776 stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
4777 tty_set_operations(stl_serial, &stl_ops);
4778
4779 retval = tty_register_driver(stl_serial);
4780 if (retval) {
4781 printk("STALLION: failed to register serial driver\n");
4782 goto err_clsdev;
4783 }
4784
4785 return 0; 4789 return 0;
4786err_clsdev: 4790err_unrtty:
4787 for (i = 0; i < 4; i++) 4791 tty_unregister_driver(stl_serial);
4788 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4792err_frtty:
4789 class_destroy(stallion_class);
4790err_reg:
4791 unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
4792 put_tty_driver(stl_serial); 4793 put_tty_driver(stl_serial);
4793err_pcidr:
4794 pci_unregister_driver(&stl_pcidriver);
4795 stl_free_isabrds();
4796err: 4794err:
4797 return retval; 4795 return retval;
4798} 4796}
@@ -4821,8 +4819,6 @@ static void __exit stallion_module_exit(void)
4821 tty_unregister_device(stl_serial, 4819 tty_unregister_device(stl_serial,
4822 brdp->brdnr * STL_MAXPORTS + j); 4820 brdp->brdnr * STL_MAXPORTS + j);
4823 } 4821 }
4824 tty_unregister_driver(stl_serial);
4825 put_tty_driver(stl_serial);
4826 4822
4827 for (i = 0; i < 4; i++) 4823 for (i = 0; i < 4; i++)
4828 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i)); 4824 class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
@@ -4834,6 +4830,9 @@ static void __exit stallion_module_exit(void)
4834 pci_unregister_driver(&stl_pcidriver); 4830 pci_unregister_driver(&stl_pcidriver);
4835 4831
4836 stl_free_isabrds(); 4832 stl_free_isabrds();
4833
4834 tty_unregister_driver(stl_serial);
4835 put_tty_driver(stl_serial);
4837} 4836}
4838 4837
4839module_init(stallion_module_init); 4838module_init(stallion_module_init);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 75d2a46e106f..3752edc30c36 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1148,7 +1148,8 @@ int tty_check_change(struct tty_struct * tty)
1148 return 0; 1148 return 0;
1149 if (is_current_pgrp_orphaned()) 1149 if (is_current_pgrp_orphaned())
1150 return -EIO; 1150 return -EIO;
1151 (void) kill_pgrp(task_pgrp(current), SIGTTOU, 1); 1151 kill_pgrp(task_pgrp(current), SIGTTOU, 1);
1152 set_thread_flag(TIF_SIGPENDING);
1152 return -ERESTARTSYS; 1153 return -ERESTARTSYS;
1153} 1154}
1154 1155
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 1cad32c62ed3..53f5538c0c05 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -115,6 +115,13 @@ config IXP4XX_WATCHDOG
115 115
116 Say N if you are unsure. 116 Say N if you are unsure.
117 117
118config KS8695_WATCHDOG
119 tristate "KS8695 watchdog"
120 depends on ARCH_KS8695
121 help
122 Watchdog timer embedded into KS8695 processor. This will reboot your
123 system when the timeout is reached.
124
118config S3C2410_WATCHDOG 125config S3C2410_WATCHDOG
119 tristate "S3C2410 Watchdog" 126 tristate "S3C2410 Watchdog"
120 depends on ARCH_S3C2410 127 depends on ARCH_S3C2410
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 8bfc00cc7c2b..d90f649038c2 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_21285_WATCHDOG) += wdt285.o
29obj-$(CONFIG_977_WATCHDOG) += wdt977.o 29obj-$(CONFIG_977_WATCHDOG) += wdt977.o
30obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o 30obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o
31obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o 31obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
32obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o
32obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o 33obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
33obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o 34obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
34obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o 35obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c
index 0e23f29f71ab..0f5c77ddd39d 100644
--- a/drivers/char/watchdog/booke_wdt.c
+++ b/drivers/char/watchdog/booke_wdt.c
@@ -24,7 +24,7 @@
24#include <asm/uaccess.h> 24#include <asm/uaccess.h>
25#include <asm/system.h> 25#include <asm/system.h>
26 26
27/* If the kernel parameter wdt_enable=1, the watchdog will be enabled at boot. 27/* If the kernel parameter wdt=1, the watchdog will be enabled at boot.
28 * Also, the wdt_period sets the watchdog timer period timeout. 28 * Also, the wdt_period sets the watchdog timer period timeout.
29 * For E500 cpus the wdt_period sets which bit changing from 0->1 will 29 * For E500 cpus the wdt_period sets which bit changing from 0->1 will
30 * trigger a watchog timeout. This watchdog timeout will occur 3 times, the 30 * trigger a watchog timeout. This watchdog timeout will occur 3 times, the
diff --git a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c
index fd955dbd588c..dc7548dcaf35 100644
--- a/drivers/char/watchdog/ixp2000_wdt.c
+++ b/drivers/char/watchdog/ixp2000_wdt.c
@@ -205,7 +205,7 @@ static void __exit ixp2000_wdt_exit(void)
205module_init(ixp2000_wdt_init); 205module_init(ixp2000_wdt_init);
206module_exit(ixp2000_wdt_exit); 206module_exit(ixp2000_wdt_exit);
207 207
208MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net">); 208MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
209MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog"); 209MODULE_DESCRIPTION("IXP2000 Network Processor Watchdog");
210 210
211module_param(heartbeat, int, 0); 211module_param(heartbeat, int, 0);
diff --git a/drivers/char/watchdog/ks8695_wdt.c b/drivers/char/watchdog/ks8695_wdt.c
new file mode 100644
index 000000000000..7150fb945eaf
--- /dev/null
+++ b/drivers/char/watchdog/ks8695_wdt.c
@@ -0,0 +1,308 @@
1/*
2 * Watchdog driver for Kendin/Micrel KS8695.
3 *
4 * (C) 2007 Andrew Victor
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/errno.h>
12#include <linux/fs.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/miscdevice.h>
16#include <linux/module.h>
17#include <linux/moduleparam.h>
18#include <linux/platform_device.h>
19#include <linux/types.h>
20#include <linux/watchdog.h>
21#include <asm/bitops.h>
22#include <asm/io.h>
23#include <asm/uaccess.h>
24#include <asm/arch/regs-timer.h>
25
26
27#define WDT_DEFAULT_TIME 5 /* seconds */
28#define WDT_MAX_TIME 171 /* seconds */
29
30static int wdt_time = WDT_DEFAULT_TIME;
31static int nowayout = WATCHDOG_NOWAYOUT;
32
33module_param(wdt_time, int, 0);
34MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")");
35
36#ifdef CONFIG_WATCHDOG_NOWAYOUT
37module_param(nowayout, int, 0);
38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
39#endif
40
41
42static unsigned long ks8695wdt_busy;
43
44/* ......................................................................... */
45
46/*
47 * Disable the watchdog.
48 */
49static void inline ks8695_wdt_stop(void)
50{
51 unsigned long tmcon;
52
53 /* disable timer0 */
54 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
55 __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
56}
57
58/*
59 * Enable and reset the watchdog.
60 */
61static void inline ks8695_wdt_start(void)
62{
63 unsigned long tmcon;
64 unsigned long tval = wdt_time * CLOCK_TICK_RATE;
65
66 /* disable timer0 */
67 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
68 __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
69
70 /* program timer0 */
71 __raw_writel(tval | T0TC_WATCHDOG, KS8695_TMR_VA + KS8695_T0TC);
72
73 /* re-enable timer0 */
74 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
75 __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
76}
77
78/*
79 * Reload the watchdog timer. (ie, pat the watchdog)
80 */
81static void inline ks8695_wdt_reload(void)
82{
83 unsigned long tmcon;
84
85 /* disable, then re-enable timer0 */
86 tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON);
87 __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
88 __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON);
89}
90
91/*
92 * Change the watchdog time interval.
93 */
94static int ks8695_wdt_settimeout(int new_time)
95{
96 /*
97 * All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz
98 *
99 * Since WDV is a 16-bit counter, the maximum period is
100 * 65536 / 0.256 = 256 seconds.
101 */
102 if ((new_time <= 0) || (new_time > WDT_MAX_TIME))
103 return -EINVAL;
104
105 /* Set new watchdog time. It will be used when ks8695_wdt_start() is called. */
106 wdt_time = new_time;
107 return 0;
108}
109
110/* ......................................................................... */
111
112/*
113 * Watchdog device is opened, and watchdog starts running.
114 */
115static int ks8695_wdt_open(struct inode *inode, struct file *file)
116{
117 if (test_and_set_bit(0, &ks8695wdt_busy))
118 return -EBUSY;
119
120 ks8695_wdt_start();
121 return nonseekable_open(inode, file);
122}
123
124/*
125 * Close the watchdog device.
126 * If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also
127 * disabled.
128 */
129static int ks8695_wdt_close(struct inode *inode, struct file *file)
130{
131 if (!nowayout)
132 ks8695_wdt_stop(); /* Disable the watchdog when file is closed */
133
134 clear_bit(0, &ks8695wdt_busy);
135 return 0;
136}
137
138static struct watchdog_info ks8695_wdt_info = {
139 .identity = "ks8695 watchdog",
140 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
141};
142
143/*
144 * Handle commands from user-space.
145 */
146static int ks8695_wdt_ioctl(struct inode *inode, struct file *file,
147 unsigned int cmd, unsigned long arg)
148{
149 void __user *argp = (void __user *)arg;
150 int __user *p = argp;
151 int new_value;
152
153 switch(cmd) {
154 case WDIOC_KEEPALIVE:
155 ks8695_wdt_reload(); /* pat the watchdog */
156 return 0;
157
158 case WDIOC_GETSUPPORT:
159 return copy_to_user(argp, &ks8695_wdt_info, sizeof(ks8695_wdt_info)) ? -EFAULT : 0;
160
161 case WDIOC_SETTIMEOUT:
162 if (get_user(new_value, p))
163 return -EFAULT;
164
165 if (ks8695_wdt_settimeout(new_value))
166 return -EINVAL;
167
168 /* Enable new time value */
169 ks8695_wdt_start();
170
171 /* Return current value */
172 return put_user(wdt_time, p);
173
174 case WDIOC_GETTIMEOUT:
175 return put_user(wdt_time, p);
176
177 case WDIOC_GETSTATUS:
178 case WDIOC_GETBOOTSTATUS:
179 return put_user(0, p);
180
181 case WDIOC_SETOPTIONS:
182 if (get_user(new_value, p))
183 return -EFAULT;
184
185 if (new_value & WDIOS_DISABLECARD)
186 ks8695_wdt_stop();
187 if (new_value & WDIOS_ENABLECARD)
188 ks8695_wdt_start();
189 return 0;
190
191 default:
192 return -ENOTTY;
193 }
194}
195
196/*
197 * Pat the watchdog whenever device is written to.
198 */
199static ssize_t ks8695_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
200{
201 ks8695_wdt_reload(); /* pat the watchdog */
202 return len;
203}
204
205/* ......................................................................... */
206
207static const struct file_operations ks8695wdt_fops = {
208 .owner = THIS_MODULE,
209 .llseek = no_llseek,
210 .ioctl = ks8695_wdt_ioctl,
211 .open = ks8695_wdt_open,
212 .release = ks8695_wdt_close,
213 .write = ks8695_wdt_write,
214};
215
216static struct miscdevice ks8695wdt_miscdev = {
217 .minor = WATCHDOG_MINOR,
218 .name = "watchdog",
219 .fops = &ks8695wdt_fops,
220};
221
222static int __init ks8695wdt_probe(struct platform_device *pdev)
223{
224 int res;
225
226 if (ks8695wdt_miscdev.parent)
227 return -EBUSY;
228 ks8695wdt_miscdev.parent = &pdev->dev;
229
230 res = misc_register(&ks8695wdt_miscdev);
231 if (res)
232 return res;
233
234 printk("KS8695 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : "");
235 return 0;
236}
237
238static int __exit ks8695wdt_remove(struct platform_device *pdev)
239{
240 int res;
241
242 res = misc_deregister(&ks8695wdt_miscdev);
243 if (!res)
244 ks8695wdt_miscdev.parent = NULL;
245
246 return res;
247}
248
249static void ks8695wdt_shutdown(struct platform_device *pdev)
250{
251 ks8695_wdt_stop();
252}
253
254#ifdef CONFIG_PM
255
256static int ks8695wdt_suspend(struct platform_device *pdev, pm_message_t message)
257{
258 ks8695_wdt_stop();
259 return 0;
260}
261
262static int ks8695wdt_resume(struct platform_device *pdev)
263{
264 if (ks8695wdt_busy)
265 ks8695_wdt_start();
266 return 0;
267}
268
269#else
270#define ks8695wdt_suspend NULL
271#define ks8695wdt_resume NULL
272#endif
273
274static struct platform_driver ks8695wdt_driver = {
275 .probe = ks8695wdt_probe,
276 .remove = __exit_p(ks8695wdt_remove),
277 .shutdown = ks8695wdt_shutdown,
278 .suspend = ks8695wdt_suspend,
279 .resume = ks8695wdt_resume,
280 .driver = {
281 .name = "ks8695_wdt",
282 .owner = THIS_MODULE,
283 },
284};
285
286static int __init ks8695_wdt_init(void)
287{
288 /* Check that the heartbeat value is within range; if not reset to the default */
289 if (ks8695_wdt_settimeout(wdt_time)) {
290 ks8695_wdt_settimeout(WDT_DEFAULT_TIME);
291 pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i, using %d\n", wdt_time, WDT_MAX_TIME);
292 }
293
294 return platform_driver_register(&ks8695wdt_driver);
295}
296
297static void __exit ks8695_wdt_exit(void)
298{
299 platform_driver_unregister(&ks8695wdt_driver);
300}
301
302module_init(ks8695_wdt_init);
303module_exit(ks8695_wdt_exit);
304
305MODULE_AUTHOR("Andrew Victor");
306MODULE_DESCRIPTION("Watchdog driver for KS8695");
307MODULE_LICENSE("GPL");
308MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);