aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/intel-agp.h1
-rw-r--r--drivers/char/agp/intel-gtt.c3
-rw-r--r--drivers/char/apm-emulation.c3
-rw-r--r--drivers/char/ds1302.c1
-rw-r--r--drivers/char/efirtc.c1
-rw-r--r--drivers/char/genrtc.c1
-rw-r--r--drivers/char/hpet.c1
-rw-r--r--drivers/char/hw_random/omap-rng.c2
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c1
-rw-r--r--drivers/char/ipmi/ipmi_kcs_sm.c4
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c243
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c73
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c25
-rw-r--r--drivers/char/lp.c6
-rw-r--r--drivers/char/mbcs.c1
-rw-r--r--drivers/char/mspec.c1
-rw-r--r--drivers/char/mwave/3780i.c1
-rw-r--r--drivers/char/nvram.c1
-rw-r--r--drivers/char/nwflash.c1
-rw-r--r--drivers/char/pcmcia/synclink_cs.c1
-rw-r--r--drivers/char/rtc.c1
-rw-r--r--drivers/char/sonypi.c1
-rw-r--r--drivers/char/tile-srom.c12
-rw-r--r--drivers/char/virtio_console.c8
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c1
25 files changed, 187 insertions, 207 deletions
diff --git a/drivers/char/agp/intel-agp.h b/drivers/char/agp/intel-agp.h
index 5da67f165afa..7ea18a5fe71c 100644
--- a/drivers/char/agp/intel-agp.h
+++ b/drivers/char/agp/intel-agp.h
@@ -234,6 +234,7 @@
234#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG 0x0166 234#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG 0x0166
235#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_HB 0x0158 /* Server */ 235#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_HB 0x0158 /* Server */
236#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG 0x015A 236#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG 0x015A
237#define PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT2_IG 0x016A
237 238
238int intel_gmch_probe(struct pci_dev *pdev, 239int intel_gmch_probe(struct pci_dev *pdev,
239 struct agp_bridge_data *bridge); 240 struct agp_bridge_data *bridge);
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 5cf47ac2d401..7f025fb620de 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -1190,7 +1190,6 @@ static inline int needs_idle_maps(void)
1190{ 1190{
1191#ifdef CONFIG_INTEL_IOMMU 1191#ifdef CONFIG_INTEL_IOMMU
1192 const unsigned short gpu_devid = intel_private.pcidev->device; 1192 const unsigned short gpu_devid = intel_private.pcidev->device;
1193 extern int intel_iommu_gfx_mapped;
1194 1193
1195 /* Query intel_iommu to see if we need the workaround. Presumably that 1194 /* Query intel_iommu to see if we need the workaround. Presumably that
1196 * was loaded first. 1195 * was loaded first.
@@ -1459,6 +1458,8 @@ static const struct intel_gtt_driver_description {
1459 "Ivybridge", &sandybridge_gtt_driver }, 1458 "Ivybridge", &sandybridge_gtt_driver },
1460 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG, 1459 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG,
1461 "Ivybridge", &sandybridge_gtt_driver }, 1460 "Ivybridge", &sandybridge_gtt_driver },
1461 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT2_IG,
1462 "Ivybridge", &sandybridge_gtt_driver },
1462 { 0, NULL, NULL } 1463 { 0, NULL, NULL }
1463}; 1464};
1464 1465
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index f4837a893dfa..46118f845948 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -31,7 +31,6 @@
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33 33
34#include <asm/system.h>
35 34
36/* 35/*
37 * The apm_bios device is one of the misc char devices. 36 * The apm_bios device is one of the misc char devices.
@@ -302,7 +301,7 @@ apm_ioctl(struct file *filp, u_int cmd, u_long arg)
302 * anything critical, chill a bit on each iteration. 301 * anything critical, chill a bit on each iteration.
303 */ 302 */
304 while (wait_event_freezable(apm_suspend_waitqueue, 303 while (wait_event_freezable(apm_suspend_waitqueue,
305 as->suspend_state == SUSPEND_DONE)) 304 as->suspend_state != SUSPEND_ACKED))
306 msleep(10); 305 msleep(10);
307 break; 306 break;
308 case SUSPEND_ACKTO: 307 case SUSPEND_ACKTO:
diff --git a/drivers/char/ds1302.c b/drivers/char/ds1302.c
index ed8303f9890c..7d34b203718a 100644
--- a/drivers/char/ds1302.c
+++ b/drivers/char/ds1302.c
@@ -24,7 +24,6 @@
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/io.h> 25#include <linux/io.h>
26 26
27#include <asm/system.h>
28#include <asm/rtc.h> 27#include <asm/rtc.h>
29#if defined(CONFIG_M32R) 28#if defined(CONFIG_M32R)
30#include <asm/m32r.h> 29#include <asm/m32r.h>
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c
index 53c524e7b829..a082d00b0f11 100644
--- a/drivers/char/efirtc.c
+++ b/drivers/char/efirtc.c
@@ -37,7 +37,6 @@
37#include <linux/efi.h> 37#include <linux/efi.h>
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39 39
40#include <asm/system.h>
41 40
42#define EFI_RTC_VERSION "0.4" 41#define EFI_RTC_VERSION "0.4"
43 42
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index f773a9dd14f3..21cb980f1157 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -56,7 +56,6 @@
56#include <linux/workqueue.h> 56#include <linux/workqueue.h>
57 57
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
59#include <asm/system.h>
60#include <asm/rtc.h> 59#include <asm/rtc.h>
61 60
62/* 61/*
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 0833896cf6f2..3845ab44c330 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -36,7 +36,6 @@
36#include <linux/io.h> 36#include <linux/io.h>
37 37
38#include <asm/current.h> 38#include <asm/current.h>
39#include <asm/system.h>
40#include <asm/irq.h> 39#include <asm/irq.h>
41#include <asm/div64.h> 40#include <asm/div64.h>
42 41
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index b757fac3cd1f..a07a5caa599c 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -26,6 +26,8 @@
26 26
27#include <asm/io.h> 27#include <asm/io.h>
28 28
29#include <plat/cpu.h>
30
29#define RNG_OUT_REG 0x00 /* Output register */ 31#define RNG_OUT_REG 0x00 /* Output register */
30#define RNG_STAT_REG 0x04 /* Status register 32#define RNG_STAT_REG 0x04 /* Status register
31 [0] = STAT_BUSY */ 33 [0] = STAT_BUSY */
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 2aa3977aae5e..9eb360ff8cab 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -34,7 +34,6 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <asm/system.h>
38#include <linux/poll.h> 37#include <linux/poll.h>
39#include <linux/sched.h> 38#include <linux/sched.h>
40#include <linux/spinlock.h> 39#include <linux/spinlock.h>
diff --git a/drivers/char/ipmi/ipmi_kcs_sm.c b/drivers/char/ipmi/ipmi_kcs_sm.c
index cf82fedae099..e53fc24c6af3 100644
--- a/drivers/char/ipmi/ipmi_kcs_sm.c
+++ b/drivers/char/ipmi/ipmi_kcs_sm.c
@@ -118,8 +118,8 @@ enum kcs_states {
118#define MAX_KCS_WRITE_SIZE IPMI_MAX_MSG_LENGTH 118#define MAX_KCS_WRITE_SIZE IPMI_MAX_MSG_LENGTH
119 119
120/* Timeouts in microseconds. */ 120/* Timeouts in microseconds. */
121#define IBF_RETRY_TIMEOUT 1000000 121#define IBF_RETRY_TIMEOUT 5000000
122#define OBF_RETRY_TIMEOUT 1000000 122#define OBF_RETRY_TIMEOUT 5000000
123#define MAX_ERROR_RETRIES 10 123#define MAX_ERROR_RETRIES 10
124#define ERROR0_OBF_WAIT_JIFFIES (2*HZ) 124#define ERROR0_OBF_WAIT_JIFFIES (2*HZ)
125 125
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 58c0e6387cf7..2c29942b1326 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -33,7 +33,6 @@
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/errno.h> 35#include <linux/errno.h>
36#include <asm/system.h>
37#include <linux/poll.h> 36#include <linux/poll.h>
38#include <linux/sched.h> 37#include <linux/sched.h>
39#include <linux/seq_file.h> 38#include <linux/seq_file.h>
@@ -46,6 +45,7 @@
46#include <linux/init.h> 45#include <linux/init.h>
47#include <linux/proc_fs.h> 46#include <linux/proc_fs.h>
48#include <linux/rcupdate.h> 47#include <linux/rcupdate.h>
48#include <linux/interrupt.h>
49 49
50#define PFX "IPMI message handler: " 50#define PFX "IPMI message handler: "
51 51
@@ -53,6 +53,8 @@
53 53
54static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 54static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
55static int ipmi_init_msghandler(void); 55static int ipmi_init_msghandler(void);
56static void smi_recv_tasklet(unsigned long);
57static void handle_new_recv_msgs(ipmi_smi_t intf);
56 58
57static int initialized; 59static int initialized;
58 60
@@ -355,12 +357,15 @@ struct ipmi_smi {
355 int curr_seq; 357 int curr_seq;
356 358
357 /* 359 /*
358 * Messages that were delayed for some reason (out of memory, 360 * Messages queued for delivery. If delivery fails (out of memory
359 * for instance), will go in here to be processed later in a 361 * for instance), They will stay in here to be processed later in a
360 * periodic timer interrupt. 362 * periodic timer interrupt. The tasklet is for handling received
363 * messages directly from the handler.
361 */ 364 */
362 spinlock_t waiting_msgs_lock; 365 spinlock_t waiting_msgs_lock;
363 struct list_head waiting_msgs; 366 struct list_head waiting_msgs;
367 atomic_t watchdog_pretimeouts_to_deliver;
368 struct tasklet_struct recv_tasklet;
364 369
365 /* 370 /*
366 * The list of command receivers that are registered for commands 371 * The list of command receivers that are registered for commands
@@ -493,6 +498,8 @@ static void clean_up_interface_data(ipmi_smi_t intf)
493 struct cmd_rcvr *rcvr, *rcvr2; 498 struct cmd_rcvr *rcvr, *rcvr2;
494 struct list_head list; 499 struct list_head list;
495 500
501 tasklet_kill(&intf->recv_tasklet);
502
496 free_smi_msg_list(&intf->waiting_msgs); 503 free_smi_msg_list(&intf->waiting_msgs);
497 free_recv_msg_list(&intf->waiting_events); 504 free_recv_msg_list(&intf->waiting_events);
498 505
@@ -2786,12 +2793,17 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
2786 return; 2793 return;
2787} 2794}
2788 2795
2789void ipmi_poll_interface(ipmi_user_t user) 2796static void ipmi_poll(ipmi_smi_t intf)
2790{ 2797{
2791 ipmi_smi_t intf = user->intf;
2792
2793 if (intf->handlers->poll) 2798 if (intf->handlers->poll)
2794 intf->handlers->poll(intf->send_info); 2799 intf->handlers->poll(intf->send_info);
2800 /* In case something came in */
2801 handle_new_recv_msgs(intf);
2802}
2803
2804void ipmi_poll_interface(ipmi_user_t user)
2805{
2806 ipmi_poll(user->intf);
2795} 2807}
2796EXPORT_SYMBOL(ipmi_poll_interface); 2808EXPORT_SYMBOL(ipmi_poll_interface);
2797 2809
@@ -2860,6 +2872,10 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2860#endif 2872#endif
2861 spin_lock_init(&intf->waiting_msgs_lock); 2873 spin_lock_init(&intf->waiting_msgs_lock);
2862 INIT_LIST_HEAD(&intf->waiting_msgs); 2874 INIT_LIST_HEAD(&intf->waiting_msgs);
2875 tasklet_init(&intf->recv_tasklet,
2876 smi_recv_tasklet,
2877 (unsigned long) intf);
2878 atomic_set(&intf->watchdog_pretimeouts_to_deliver, 0);
2863 spin_lock_init(&intf->events_lock); 2879 spin_lock_init(&intf->events_lock);
2864 INIT_LIST_HEAD(&intf->waiting_events); 2880 INIT_LIST_HEAD(&intf->waiting_events);
2865 intf->waiting_events_count = 0; 2881 intf->waiting_events_count = 0;
@@ -3622,11 +3638,11 @@ static int handle_bmc_rsp(ipmi_smi_t intf,
3622} 3638}
3623 3639
3624/* 3640/*
3625 * Handle a new message. Return 1 if the message should be requeued, 3641 * Handle a received message. Return 1 if the message should be requeued,
3626 * 0 if the message should be freed, or -1 if the message should not 3642 * 0 if the message should be freed, or -1 if the message should not
3627 * be freed or requeued. 3643 * be freed or requeued.
3628 */ 3644 */
3629static int handle_new_recv_msg(ipmi_smi_t intf, 3645static int handle_one_recv_msg(ipmi_smi_t intf,
3630 struct ipmi_smi_msg *msg) 3646 struct ipmi_smi_msg *msg)
3631{ 3647{
3632 int requeue; 3648 int requeue;
@@ -3784,12 +3800,72 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3784 return requeue; 3800 return requeue;
3785} 3801}
3786 3802
3803/*
3804 * If there are messages in the queue or pretimeouts, handle them.
3805 */
3806static void handle_new_recv_msgs(ipmi_smi_t intf)
3807{
3808 struct ipmi_smi_msg *smi_msg;
3809 unsigned long flags = 0;
3810 int rv;
3811 int run_to_completion = intf->run_to_completion;
3812
3813 /* See if any waiting messages need to be processed. */
3814 if (!run_to_completion)
3815 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3816 while (!list_empty(&intf->waiting_msgs)) {
3817 smi_msg = list_entry(intf->waiting_msgs.next,
3818 struct ipmi_smi_msg, link);
3819 list_del(&smi_msg->link);
3820 if (!run_to_completion)
3821 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3822 rv = handle_one_recv_msg(intf, smi_msg);
3823 if (!run_to_completion)
3824 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3825 if (rv == 0) {
3826 /* Message handled */
3827 ipmi_free_smi_msg(smi_msg);
3828 } else if (rv < 0) {
3829 /* Fatal error on the message, del but don't free. */
3830 } else {
3831 /*
3832 * To preserve message order, quit if we
3833 * can't handle a message.
3834 */
3835 list_add(&smi_msg->link, &intf->waiting_msgs);
3836 break;
3837 }
3838 }
3839 if (!run_to_completion)
3840 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3841
3842 /*
3843 * If the pretimout count is non-zero, decrement one from it and
3844 * deliver pretimeouts to all the users.
3845 */
3846 if (atomic_add_unless(&intf->watchdog_pretimeouts_to_deliver, -1, 0)) {
3847 ipmi_user_t user;
3848
3849 rcu_read_lock();
3850 list_for_each_entry_rcu(user, &intf->users, link) {
3851 if (user->handler->ipmi_watchdog_pretimeout)
3852 user->handler->ipmi_watchdog_pretimeout(
3853 user->handler_data);
3854 }
3855 rcu_read_unlock();
3856 }
3857}
3858
3859static void smi_recv_tasklet(unsigned long val)
3860{
3861 handle_new_recv_msgs((ipmi_smi_t) val);
3862}
3863
3787/* Handle a new message from the lower layer. */ 3864/* Handle a new message from the lower layer. */
3788void ipmi_smi_msg_received(ipmi_smi_t intf, 3865void ipmi_smi_msg_received(ipmi_smi_t intf,
3789 struct ipmi_smi_msg *msg) 3866 struct ipmi_smi_msg *msg)
3790{ 3867{
3791 unsigned long flags = 0; /* keep us warning-free. */ 3868 unsigned long flags = 0; /* keep us warning-free. */
3792 int rv;
3793 int run_to_completion; 3869 int run_to_completion;
3794 3870
3795 3871
@@ -3843,31 +3919,11 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3843 run_to_completion = intf->run_to_completion; 3919 run_to_completion = intf->run_to_completion;
3844 if (!run_to_completion) 3920 if (!run_to_completion)
3845 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 3921 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3846 if (!list_empty(&intf->waiting_msgs)) { 3922 list_add_tail(&msg->link, &intf->waiting_msgs);
3847 list_add_tail(&msg->link, &intf->waiting_msgs);
3848 if (!run_to_completion)
3849 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3850 goto out;
3851 }
3852 if (!run_to_completion) 3923 if (!run_to_completion)
3853 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); 3924 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3854 3925
3855 rv = handle_new_recv_msg(intf, msg); 3926 tasklet_schedule(&intf->recv_tasklet);
3856 if (rv > 0) {
3857 /*
3858 * Could not handle the message now, just add it to a
3859 * list to handle later.
3860 */
3861 run_to_completion = intf->run_to_completion;
3862 if (!run_to_completion)
3863 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3864 list_add_tail(&msg->link, &intf->waiting_msgs);
3865 if (!run_to_completion)
3866 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3867 } else if (rv == 0) {
3868 ipmi_free_smi_msg(msg);
3869 }
3870
3871 out: 3927 out:
3872 return; 3928 return;
3873} 3929}
@@ -3875,16 +3931,8 @@ EXPORT_SYMBOL(ipmi_smi_msg_received);
3875 3931
3876void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf) 3932void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
3877{ 3933{
3878 ipmi_user_t user; 3934 atomic_set(&intf->watchdog_pretimeouts_to_deliver, 1);
3879 3935 tasklet_schedule(&intf->recv_tasklet);
3880 rcu_read_lock();
3881 list_for_each_entry_rcu(user, &intf->users, link) {
3882 if (!user->handler->ipmi_watchdog_pretimeout)
3883 continue;
3884
3885 user->handler->ipmi_watchdog_pretimeout(user->handler_data);
3886 }
3887 rcu_read_unlock();
3888} 3936}
3889EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout); 3937EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout);
3890 3938
@@ -3998,28 +4046,12 @@ static void ipmi_timeout_handler(long timeout_period)
3998 ipmi_smi_t intf; 4046 ipmi_smi_t intf;
3999 struct list_head timeouts; 4047 struct list_head timeouts;
4000 struct ipmi_recv_msg *msg, *msg2; 4048 struct ipmi_recv_msg *msg, *msg2;
4001 struct ipmi_smi_msg *smi_msg, *smi_msg2;
4002 unsigned long flags; 4049 unsigned long flags;
4003 int i; 4050 int i;
4004 4051
4005 rcu_read_lock(); 4052 rcu_read_lock();
4006 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 4053 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
4007 /* See if any waiting messages need to be processed. */ 4054 tasklet_schedule(&intf->recv_tasklet);
4008 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
4009 list_for_each_entry_safe(smi_msg, smi_msg2,
4010 &intf->waiting_msgs, link) {
4011 if (!handle_new_recv_msg(intf, smi_msg)) {
4012 list_del(&smi_msg->link);
4013 ipmi_free_smi_msg(smi_msg);
4014 } else {
4015 /*
4016 * To preserve message order, quit if we
4017 * can't handle a message.
4018 */
4019 break;
4020 }
4021 }
4022 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
4023 4055
4024 /* 4056 /*
4025 * Go through the seq table and find any messages that 4057 * Go through the seq table and find any messages that
@@ -4173,12 +4205,48 @@ EXPORT_SYMBOL(ipmi_free_recv_msg);
4173 4205
4174#ifdef CONFIG_IPMI_PANIC_EVENT 4206#ifdef CONFIG_IPMI_PANIC_EVENT
4175 4207
4208static atomic_t panic_done_count = ATOMIC_INIT(0);
4209
4176static void dummy_smi_done_handler(struct ipmi_smi_msg *msg) 4210static void dummy_smi_done_handler(struct ipmi_smi_msg *msg)
4177{ 4211{
4212 atomic_dec(&panic_done_count);
4178} 4213}
4179 4214
4180static void dummy_recv_done_handler(struct ipmi_recv_msg *msg) 4215static void dummy_recv_done_handler(struct ipmi_recv_msg *msg)
4181{ 4216{
4217 atomic_dec(&panic_done_count);
4218}
4219
4220/*
4221 * Inside a panic, send a message and wait for a response.
4222 */
4223static void ipmi_panic_request_and_wait(ipmi_smi_t intf,
4224 struct ipmi_addr *addr,
4225 struct kernel_ipmi_msg *msg)
4226{
4227 struct ipmi_smi_msg smi_msg;
4228 struct ipmi_recv_msg recv_msg;
4229 int rv;
4230
4231 smi_msg.done = dummy_smi_done_handler;
4232 recv_msg.done = dummy_recv_done_handler;
4233 atomic_add(2, &panic_done_count);
4234 rv = i_ipmi_request(NULL,
4235 intf,
4236 addr,
4237 0,
4238 msg,
4239 intf,
4240 &smi_msg,
4241 &recv_msg,
4242 0,
4243 intf->channels[0].address,
4244 intf->channels[0].lun,
4245 0, 1); /* Don't retry, and don't wait. */
4246 if (rv)
4247 atomic_sub(2, &panic_done_count);
4248 while (atomic_read(&panic_done_count) != 0)
4249 ipmi_poll(intf);
4182} 4250}
4183 4251
4184#ifdef CONFIG_IPMI_PANIC_STRING 4252#ifdef CONFIG_IPMI_PANIC_STRING
@@ -4217,8 +4285,6 @@ static void send_panic_events(char *str)
4217 unsigned char data[16]; 4285 unsigned char data[16];
4218 struct ipmi_system_interface_addr *si; 4286 struct ipmi_system_interface_addr *si;
4219 struct ipmi_addr addr; 4287 struct ipmi_addr addr;
4220 struct ipmi_smi_msg smi_msg;
4221 struct ipmi_recv_msg recv_msg;
4222 4288
4223 si = (struct ipmi_system_interface_addr *) &addr; 4289 si = (struct ipmi_system_interface_addr *) &addr;
4224 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 4290 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
@@ -4246,9 +4312,6 @@ static void send_panic_events(char *str)
4246 data[7] = str[2]; 4312 data[7] = str[2];
4247 } 4313 }
4248 4314
4249 smi_msg.done = dummy_smi_done_handler;
4250 recv_msg.done = dummy_recv_done_handler;
4251
4252 /* For every registered interface, send the event. */ 4315 /* For every registered interface, send the event. */
4253 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 4316 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
4254 if (!intf->handlers) 4317 if (!intf->handlers)
@@ -4258,18 +4321,7 @@ static void send_panic_events(char *str)
4258 intf->run_to_completion = 1; 4321 intf->run_to_completion = 1;
4259 /* Send the event announcing the panic. */ 4322 /* Send the event announcing the panic. */
4260 intf->handlers->set_run_to_completion(intf->send_info, 1); 4323 intf->handlers->set_run_to_completion(intf->send_info, 1);
4261 i_ipmi_request(NULL, 4324 ipmi_panic_request_and_wait(intf, &addr, &msg);
4262 intf,
4263 &addr,
4264 0,
4265 &msg,
4266 intf,
4267 &smi_msg,
4268 &recv_msg,
4269 0,
4270 intf->channels[0].address,
4271 intf->channels[0].lun,
4272 0, 1); /* Don't retry, and don't wait. */
4273 } 4325 }
4274 4326
4275#ifdef CONFIG_IPMI_PANIC_STRING 4327#ifdef CONFIG_IPMI_PANIC_STRING
@@ -4317,18 +4369,7 @@ static void send_panic_events(char *str)
4317 msg.data = NULL; 4369 msg.data = NULL;
4318 msg.data_len = 0; 4370 msg.data_len = 0;
4319 intf->null_user_handler = device_id_fetcher; 4371 intf->null_user_handler = device_id_fetcher;
4320 i_ipmi_request(NULL, 4372 ipmi_panic_request_and_wait(intf, &addr, &msg);
4321 intf,
4322 &addr,
4323 0,
4324 &msg,
4325 intf,
4326 &smi_msg,
4327 &recv_msg,
4328 0,
4329 intf->channels[0].address,
4330 intf->channels[0].lun,
4331 0, 1); /* Don't retry, and don't wait. */
4332 4373
4333 if (intf->local_event_generator) { 4374 if (intf->local_event_generator) {
4334 /* Request the event receiver from the local MC. */ 4375 /* Request the event receiver from the local MC. */
@@ -4337,18 +4378,7 @@ static void send_panic_events(char *str)
4337 msg.data = NULL; 4378 msg.data = NULL;
4338 msg.data_len = 0; 4379 msg.data_len = 0;
4339 intf->null_user_handler = event_receiver_fetcher; 4380 intf->null_user_handler = event_receiver_fetcher;
4340 i_ipmi_request(NULL, 4381 ipmi_panic_request_and_wait(intf, &addr, &msg);
4341 intf,
4342 &addr,
4343 0,
4344 &msg,
4345 intf,
4346 &smi_msg,
4347 &recv_msg,
4348 0,
4349 intf->channels[0].address,
4350 intf->channels[0].lun,
4351 0, 1); /* no retry, and no wait. */
4352 } 4382 }
4353 intf->null_user_handler = NULL; 4383 intf->null_user_handler = NULL;
4354 4384
@@ -4405,18 +4435,7 @@ static void send_panic_events(char *str)
4405 strncpy(data+5, p, 11); 4435 strncpy(data+5, p, 11);
4406 p += size; 4436 p += size;
4407 4437
4408 i_ipmi_request(NULL, 4438 ipmi_panic_request_and_wait(intf, &addr, &msg);
4409 intf,
4410 &addr,
4411 0,
4412 &msg,
4413 intf,
4414 &smi_msg,
4415 &recv_msg,
4416 0,
4417 intf->channels[0].address,
4418 intf->channels[0].lun,
4419 0, 1); /* no retry, and no wait. */
4420 } 4439 }
4421 } 4440 }
4422#endif /* CONFIG_IPMI_PANIC_STRING */ 4441#endif /* CONFIG_IPMI_PANIC_STRING */
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 50fcf9c04569..1e638fff40ea 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -41,7 +41,6 @@
41 41
42#include <linux/module.h> 42#include <linux/module.h>
43#include <linux/moduleparam.h> 43#include <linux/moduleparam.h>
44#include <asm/system.h>
45#include <linux/sched.h> 44#include <linux/sched.h>
46#include <linux/seq_file.h> 45#include <linux/seq_file.h>
47#include <linux/timer.h> 46#include <linux/timer.h>
@@ -171,7 +170,6 @@ struct smi_info {
171 struct si_sm_handlers *handlers; 170 struct si_sm_handlers *handlers;
172 enum si_type si_type; 171 enum si_type si_type;
173 spinlock_t si_lock; 172 spinlock_t si_lock;
174 spinlock_t msg_lock;
175 struct list_head xmit_msgs; 173 struct list_head xmit_msgs;
176 struct list_head hp_xmit_msgs; 174 struct list_head hp_xmit_msgs;
177 struct ipmi_smi_msg *curr_msg; 175 struct ipmi_smi_msg *curr_msg;
@@ -320,16 +318,8 @@ static int register_xaction_notifier(struct notifier_block *nb)
320static void deliver_recv_msg(struct smi_info *smi_info, 318static void deliver_recv_msg(struct smi_info *smi_info,
321 struct ipmi_smi_msg *msg) 319 struct ipmi_smi_msg *msg)
322{ 320{
323 /* Deliver the message to the upper layer with the lock 321 /* Deliver the message to the upper layer. */
324 released. */ 322 ipmi_smi_msg_received(smi_info->intf, msg);
325
326 if (smi_info->run_to_completion) {
327 ipmi_smi_msg_received(smi_info->intf, msg);
328 } else {
329 spin_unlock(&(smi_info->si_lock));
330 ipmi_smi_msg_received(smi_info->intf, msg);
331 spin_lock(&(smi_info->si_lock));
332 }
333} 323}
334 324
335static void return_hosed_msg(struct smi_info *smi_info, int cCode) 325static void return_hosed_msg(struct smi_info *smi_info, int cCode)
@@ -358,13 +348,6 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
358 struct timeval t; 348 struct timeval t;
359#endif 349#endif
360 350
361 /*
362 * No need to save flags, we aleady have interrupts off and we
363 * already hold the SMI lock.
364 */
365 if (!smi_info->run_to_completion)
366 spin_lock(&(smi_info->msg_lock));
367
368 /* Pick the high priority queue first. */ 351 /* Pick the high priority queue first. */
369 if (!list_empty(&(smi_info->hp_xmit_msgs))) { 352 if (!list_empty(&(smi_info->hp_xmit_msgs))) {
370 entry = smi_info->hp_xmit_msgs.next; 353 entry = smi_info->hp_xmit_msgs.next;
@@ -402,9 +385,6 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
402 rv = SI_SM_CALL_WITHOUT_DELAY; 385 rv = SI_SM_CALL_WITHOUT_DELAY;
403 } 386 }
404 out: 387 out:
405 if (!smi_info->run_to_completion)
406 spin_unlock(&(smi_info->msg_lock));
407
408 return rv; 388 return rv;
409} 389}
410 390
@@ -481,9 +461,7 @@ static void handle_flags(struct smi_info *smi_info)
481 461
482 start_clear_flags(smi_info); 462 start_clear_flags(smi_info);
483 smi_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT; 463 smi_info->msg_flags &= ~WDT_PRE_TIMEOUT_INT;
484 spin_unlock(&(smi_info->si_lock));
485 ipmi_smi_watchdog_pretimeout(smi_info->intf); 464 ipmi_smi_watchdog_pretimeout(smi_info->intf);
486 spin_lock(&(smi_info->si_lock));
487 } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) { 465 } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) {
488 /* Messages available. */ 466 /* Messages available. */
489 smi_info->curr_msg = ipmi_alloc_smi_msg(); 467 smi_info->curr_msg = ipmi_alloc_smi_msg();
@@ -889,19 +867,6 @@ static void sender(void *send_info,
889 printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec); 867 printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec);
890#endif 868#endif
891 869
892 /*
893 * last_timeout_jiffies is updated here to avoid
894 * smi_timeout() handler passing very large time_diff
895 * value to smi_event_handler() that causes
896 * the send command to abort.
897 */
898 smi_info->last_timeout_jiffies = jiffies;
899
900 mod_timer(&smi_info->si_timer, jiffies + SI_TIMEOUT_JIFFIES);
901
902 if (smi_info->thread)
903 wake_up_process(smi_info->thread);
904
905 if (smi_info->run_to_completion) { 870 if (smi_info->run_to_completion) {
906 /* 871 /*
907 * If we are running to completion, then throw it in 872 * If we are running to completion, then throw it in
@@ -924,16 +889,29 @@ static void sender(void *send_info,
924 return; 889 return;
925 } 890 }
926 891
927 spin_lock_irqsave(&smi_info->msg_lock, flags); 892 spin_lock_irqsave(&smi_info->si_lock, flags);
928 if (priority > 0) 893 if (priority > 0)
929 list_add_tail(&msg->link, &smi_info->hp_xmit_msgs); 894 list_add_tail(&msg->link, &smi_info->hp_xmit_msgs);
930 else 895 else
931 list_add_tail(&msg->link, &smi_info->xmit_msgs); 896 list_add_tail(&msg->link, &smi_info->xmit_msgs);
932 spin_unlock_irqrestore(&smi_info->msg_lock, flags);
933 897
934 spin_lock_irqsave(&smi_info->si_lock, flags); 898 if (smi_info->si_state == SI_NORMAL && smi_info->curr_msg == NULL) {
935 if (smi_info->si_state == SI_NORMAL && smi_info->curr_msg == NULL) 899 /*
900 * last_timeout_jiffies is updated here to avoid
901 * smi_timeout() handler passing very large time_diff
902 * value to smi_event_handler() that causes
903 * the send command to abort.
904 */
905 smi_info->last_timeout_jiffies = jiffies;
906
907 mod_timer(&smi_info->si_timer, jiffies + SI_TIMEOUT_JIFFIES);
908
909 if (smi_info->thread)
910 wake_up_process(smi_info->thread);
911
936 start_next_msg(smi_info); 912 start_next_msg(smi_info);
913 smi_event_handler(smi_info, 0);
914 }
937 spin_unlock_irqrestore(&smi_info->si_lock, flags); 915 spin_unlock_irqrestore(&smi_info->si_lock, flags);
938} 916}
939 917
@@ -1034,16 +1012,19 @@ static int ipmi_thread(void *data)
1034static void poll(void *send_info) 1012static void poll(void *send_info)
1035{ 1013{
1036 struct smi_info *smi_info = send_info; 1014 struct smi_info *smi_info = send_info;
1037 unsigned long flags; 1015 unsigned long flags = 0;
1016 int run_to_completion = smi_info->run_to_completion;
1038 1017
1039 /* 1018 /*
1040 * Make sure there is some delay in the poll loop so we can 1019 * Make sure there is some delay in the poll loop so we can
1041 * drive time forward and timeout things. 1020 * drive time forward and timeout things.
1042 */ 1021 */
1043 udelay(10); 1022 udelay(10);
1044 spin_lock_irqsave(&smi_info->si_lock, flags); 1023 if (!run_to_completion)
1024 spin_lock_irqsave(&smi_info->si_lock, flags);
1045 smi_event_handler(smi_info, 10); 1025 smi_event_handler(smi_info, 10);
1046 spin_unlock_irqrestore(&smi_info->si_lock, flags); 1026 if (!run_to_completion)
1027 spin_unlock_irqrestore(&smi_info->si_lock, flags);
1047} 1028}
1048 1029
1049static void request_events(void *send_info) 1030static void request_events(void *send_info)
@@ -1680,10 +1661,8 @@ static struct smi_info *smi_info_alloc(void)
1680{ 1661{
1681 struct smi_info *info = kzalloc(sizeof(*info), GFP_KERNEL); 1662 struct smi_info *info = kzalloc(sizeof(*info), GFP_KERNEL);
1682 1663
1683 if (info) { 1664 if (info)
1684 spin_lock_init(&info->si_lock); 1665 spin_lock_init(&info->si_lock);
1685 spin_lock_init(&info->msg_lock);
1686 }
1687 return info; 1666 return info;
1688} 1667}
1689 1668
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 34767a6d7f42..7ed356e52035 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -153,7 +153,7 @@
153#endif 153#endif
154 154
155static DEFINE_MUTEX(ipmi_watchdog_mutex); 155static DEFINE_MUTEX(ipmi_watchdog_mutex);
156static int nowayout = WATCHDOG_NOWAYOUT; 156static bool nowayout = WATCHDOG_NOWAYOUT;
157 157
158static ipmi_user_t watchdog_user; 158static ipmi_user_t watchdog_user;
159static int watchdog_ifnum; 159static int watchdog_ifnum;
@@ -320,7 +320,7 @@ module_param(start_now, int, 0444);
320MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as" 320MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
321 "soon as the driver is loaded."); 321 "soon as the driver is loaded.");
322 322
323module_param(nowayout, int, 0644); 323module_param(nowayout, bool, 0644);
324MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " 324MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
325 "(default=CONFIG_WATCHDOG_NOWAYOUT)"); 325 "(default=CONFIG_WATCHDOG_NOWAYOUT)");
326 326
@@ -520,6 +520,7 @@ static void panic_halt_ipmi_heartbeat(void)
520 msg.cmd = IPMI_WDOG_RESET_TIMER; 520 msg.cmd = IPMI_WDOG_RESET_TIMER;
521 msg.data = NULL; 521 msg.data = NULL;
522 msg.data_len = 0; 522 msg.data_len = 0;
523 atomic_add(2, &panic_done_count);
523 rv = ipmi_request_supply_msgs(watchdog_user, 524 rv = ipmi_request_supply_msgs(watchdog_user,
524 (struct ipmi_addr *) &addr, 525 (struct ipmi_addr *) &addr,
525 0, 526 0,
@@ -528,8 +529,8 @@ static void panic_halt_ipmi_heartbeat(void)
528 &panic_halt_heartbeat_smi_msg, 529 &panic_halt_heartbeat_smi_msg,
529 &panic_halt_heartbeat_recv_msg, 530 &panic_halt_heartbeat_recv_msg,
530 1); 531 1);
531 if (!rv) 532 if (rv)
532 atomic_add(2, &panic_done_count); 533 atomic_sub(2, &panic_done_count);
533} 534}
534 535
535static struct ipmi_smi_msg panic_halt_smi_msg = { 536static struct ipmi_smi_msg panic_halt_smi_msg = {
@@ -553,16 +554,18 @@ static void panic_halt_ipmi_set_timeout(void)
553 /* Wait for the messages to be free. */ 554 /* Wait for the messages to be free. */
554 while (atomic_read(&panic_done_count) != 0) 555 while (atomic_read(&panic_done_count) != 0)
555 ipmi_poll_interface(watchdog_user); 556 ipmi_poll_interface(watchdog_user);
557 atomic_add(2, &panic_done_count);
556 rv = i_ipmi_set_timeout(&panic_halt_smi_msg, 558 rv = i_ipmi_set_timeout(&panic_halt_smi_msg,
557 &panic_halt_recv_msg, 559 &panic_halt_recv_msg,
558 &send_heartbeat_now); 560 &send_heartbeat_now);
559 if (!rv) { 561 if (rv) {
560 atomic_add(2, &panic_done_count); 562 atomic_sub(2, &panic_done_count);
561 if (send_heartbeat_now)
562 panic_halt_ipmi_heartbeat();
563 } else
564 printk(KERN_WARNING PFX 563 printk(KERN_WARNING PFX
565 "Unable to extend the watchdog timeout."); 564 "Unable to extend the watchdog timeout.");
565 } else {
566 if (send_heartbeat_now)
567 panic_halt_ipmi_heartbeat();
568 }
566 while (atomic_read(&panic_done_count) != 0) 569 while (atomic_read(&panic_done_count) != 0)
567 ipmi_poll_interface(watchdog_user); 570 ipmi_poll_interface(watchdog_user);
568} 571}
@@ -1164,7 +1167,7 @@ static int wdog_reboot_handler(struct notifier_block *this,
1164 if (code == SYS_POWER_OFF || code == SYS_HALT) { 1167 if (code == SYS_POWER_OFF || code == SYS_HALT) {
1165 /* Disable the WDT if we are shutting down. */ 1168 /* Disable the WDT if we are shutting down. */
1166 ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 1169 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
1167 panic_halt_ipmi_set_timeout(); 1170 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
1168 } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { 1171 } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
1169 /* Set a long timer to let the reboot happens, but 1172 /* Set a long timer to let the reboot happens, but
1170 reboot if it hangs, but only if the watchdog 1173 reboot if it hangs, but only if the watchdog
@@ -1172,7 +1175,7 @@ static int wdog_reboot_handler(struct notifier_block *this,
1172 timeout = 120; 1175 timeout = 120;
1173 pretimeout = 0; 1176 pretimeout = 0;
1174 ipmi_watchdog_state = WDOG_TIMEOUT_RESET; 1177 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
1175 panic_halt_ipmi_set_timeout(); 1178 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
1176 } 1179 }
1177 } 1180 }
1178 return NOTIFY_OK; 1181 return NOTIFY_OK;
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index f43485607063..a741e418b456 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -135,7 +135,6 @@
135 135
136#include <asm/irq.h> 136#include <asm/irq.h>
137#include <asm/uaccess.h> 137#include <asm/uaccess.h>
138#include <asm/system.h>
139 138
140/* if you have more than 8 printers, remember to increase LP_NO */ 139/* if you have more than 8 printers, remember to increase LP_NO */
141#define LP_NO 8 140#define LP_NO 8
@@ -706,16 +705,13 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
706{ 705{
707 unsigned int minor; 706 unsigned int minor;
708 struct timeval par_timeout; 707 struct timeval par_timeout;
709 struct compat_timeval __user *tc;
710 int ret; 708 int ret;
711 709
712 minor = iminor(file->f_path.dentry->d_inode); 710 minor = iminor(file->f_path.dentry->d_inode);
713 mutex_lock(&lp_mutex); 711 mutex_lock(&lp_mutex);
714 switch (cmd) { 712 switch (cmd) {
715 case LPSETTIMEOUT: 713 case LPSETTIMEOUT:
716 tc = compat_ptr(arg); 714 if (compat_get_timeval(&par_timeout, compat_ptr(arg))) {
717 if (get_user(par_timeout.tv_sec, &tc->tv_sec) ||
718 get_user(par_timeout.tv_usec, &tc->tv_usec)) {
719 ret = -EFAULT; 715 ret = -EFAULT;
720 break; 716 break;
721 } 717 }
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
index 1aeaaba680d2..47ff7e470d87 100644
--- a/drivers/char/mbcs.c
+++ b/drivers/char/mbcs.c
@@ -28,7 +28,6 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
31#include <asm/system.h>
32#include <asm/pgtable.h> 31#include <asm/pgtable.h>
33#include <asm/sn/addrs.h> 32#include <asm/sn/addrs.h>
34#include <asm/sn/intr.h> 33#include <asm/sn/intr.h>
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 5c0d96a820fa..8b78750f1efe 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -44,7 +44,6 @@
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/numa.h> 45#include <linux/numa.h>
46#include <asm/page.h> 46#include <asm/page.h>
47#include <asm/system.h>
48#include <asm/pgtable.h> 47#include <asm/pgtable.h>
49#include <linux/atomic.h> 48#include <linux/atomic.h>
50#include <asm/tlbflush.h> 49#include <asm/tlbflush.h>
diff --git a/drivers/char/mwave/3780i.c b/drivers/char/mwave/3780i.c
index 492dbfb2efd6..881c9e595939 100644
--- a/drivers/char/mwave/3780i.c
+++ b/drivers/char/mwave/3780i.c
@@ -56,7 +56,6 @@
56 56
57#include <asm/io.h> 57#include <asm/io.h>
58#include <asm/uaccess.h> 58#include <asm/uaccess.h>
59#include <asm/system.h>
60#include <asm/irq.h> 59#include <asm/irq.h>
61#include "smapi.h" 60#include "smapi.h"
62#include "mwavedd.h" 61#include "mwavedd.h"
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index eaade8a1ecd7..9df78e2cc45d 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -111,7 +111,6 @@
111#include <linux/uaccess.h> 111#include <linux/uaccess.h>
112#include <linux/mutex.h> 112#include <linux/mutex.h>
113 113
114#include <asm/system.h>
115 114
116static DEFINE_MUTEX(nvram_mutex); 115static DEFINE_MUTEX(nvram_mutex);
117static DEFINE_SPINLOCK(nvram_state_lock); 116static DEFINE_SPINLOCK(nvram_state_lock);
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index bf586ae1ee83..d45c3345b4af 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -32,7 +32,6 @@
32#include <asm/io.h> 32#include <asm/io.h>
33#include <asm/leds.h> 33#include <asm/leds.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35#include <asm/system.h>
36#include <asm/uaccess.h> 35#include <asm/uaccess.h>
37 36
38/*****************************************************************************/ 37/*****************************************************************************/
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index f6453df4921c..0a484b4a1b02 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -60,7 +60,6 @@
60#include <linux/ioctl.h> 60#include <linux/ioctl.h>
61#include <linux/synclink.h> 61#include <linux/synclink.h>
62 62
63#include <asm/system.h>
64#include <asm/io.h> 63#include <asm/io.h>
65#include <asm/irq.h> 64#include <asm/irq.h>
66#include <asm/dma.h> 65#include <asm/dma.h>
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 872e09a02d23..af9437488b6c 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -83,7 +83,6 @@
83#include <linux/ratelimit.h> 83#include <linux/ratelimit.h>
84 84
85#include <asm/current.h> 85#include <asm/current.h>
86#include <asm/system.h>
87 86
88#ifdef CONFIG_X86 87#ifdef CONFIG_X86
89#include <asm/hpet.h> 88#include <asm/hpet.h>
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 1ee8ce7d2762..45713f0e7d61 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -54,7 +54,6 @@
54 54
55#include <asm/uaccess.h> 55#include <asm/uaccess.h>
56#include <asm/io.h> 56#include <asm/io.h>
57#include <asm/system.h>
58 57
59#include <linux/sonypi.h> 58#include <linux/sonypi.h>
60 59
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 4dc019408fac..3b22a606f79d 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -194,17 +194,17 @@ static ssize_t srom_read(struct file *filp, char __user *buf,
194 194
195 hv_retval = _srom_read(srom->hv_devhdl, kernbuf, 195 hv_retval = _srom_read(srom->hv_devhdl, kernbuf,
196 *f_pos, bytes_this_pass); 196 *f_pos, bytes_this_pass);
197 if (hv_retval > 0) { 197 if (hv_retval <= 0) {
198 if (copy_to_user(buf, kernbuf, hv_retval) != 0) {
199 retval = -EFAULT;
200 break;
201 }
202 } else if (hv_retval <= 0) {
203 if (retval == 0) 198 if (retval == 0)
204 retval = hv_retval; 199 retval = hv_retval;
205 break; 200 break;
206 } 201 }
207 202
203 if (copy_to_user(buf, kernbuf, hv_retval) != 0) {
204 retval = -EFAULT;
205 break;
206 }
207
208 retval += hv_retval; 208 retval += hv_retval;
209 *f_pos += hv_retval; 209 *f_pos += hv_retval;
210 buf += hv_retval; 210 buf += hv_retval;
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index b58b56187065..ddf86b6500b7 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1038,12 +1038,6 @@ static struct attribute_group port_attribute_group = {
1038 .attrs = port_sysfs_entries, 1038 .attrs = port_sysfs_entries,
1039}; 1039};
1040 1040
1041static int debugfs_open(struct inode *inode, struct file *filp)
1042{
1043 filp->private_data = inode->i_private;
1044 return 0;
1045}
1046
1047static ssize_t debugfs_read(struct file *filp, char __user *ubuf, 1041static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
1048 size_t count, loff_t *offp) 1042 size_t count, loff_t *offp)
1049{ 1043{
@@ -1087,7 +1081,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
1087 1081
1088static const struct file_operations port_debugfs_ops = { 1082static const struct file_operations port_debugfs_ops = {
1089 .owner = THIS_MODULE, 1083 .owner = THIS_MODULE,
1090 .open = debugfs_open, 1084 .open = simple_open,
1091 .read = debugfs_read, 1085 .read = debugfs_read,
1092}; 1086};
1093 1087
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index e90e1c74fd4c..31ba11ca75e1 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -89,7 +89,6 @@
89 89
90#include <asm/io.h> 90#include <asm/io.h>
91#include <asm/uaccess.h> 91#include <asm/uaccess.h>
92#include <asm/system.h>
93 92
94#ifdef CONFIG_OF 93#ifdef CONFIG_OF
95/* For open firmware. */ 94/* For open firmware. */