aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/loop.c4
-rw-r--r--drivers/block/rd.c2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c7
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c67
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c18
-rw-r--r--drivers/char/istallion.c1819
-rw-r--r--drivers/char/mxser.c1
-rw-r--r--drivers/char/n_tty.c6
-rw-r--r--drivers/char/pty.c2
-rw-r--r--drivers/char/stallion.c3
-rw-r--r--drivers/char/tty_io.c68
-rw-r--r--drivers/char/watchdog/at91_wdt.c82
-rw-r--r--drivers/char/watchdog/i8xx_tco.c28
-rw-r--r--drivers/char/watchdog/pcwd_pci.c30
-rw-r--r--drivers/char/watchdog/pcwd_usb.c23
-rw-r--r--drivers/ide/ide-io.c2
-rw-r--r--drivers/ide/ide-iops.c4
-rw-r--r--drivers/ide/pci/aec62xx.c16
-rw-r--r--drivers/ide/pci/cmd64x.c15
-rw-r--r--drivers/ide/pci/pdc202xx_new.c2
-rw-r--r--drivers/ide/pci/pdc202xx_old.c115
-rw-r--r--drivers/ide/pci/sc1200.c4
-rw-r--r--drivers/ide/pci/serverworks.c53
-rw-r--r--drivers/ide/pci/siimage.c62
-rw-r--r--drivers/ide/pci/sl82c105.c4
-rw-r--r--drivers/ide/pci/slc90e66.c11
-rw-r--r--drivers/input/joystick/db9.c2
-rw-r--r--drivers/input/keyboard/atkbd.c2
-rw-r--r--drivers/input/misc/wistron_btns.c19
-rw-r--r--drivers/rtc/Kconfig10
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-rs5c348.c246
-rw-r--r--drivers/serial/68328serial.c102
-rw-r--r--drivers/serial/crisv10.c6
-rw-r--r--drivers/serial/jsm/jsm_tty.c7
-rw-r--r--drivers/spi/spi.c1
-rw-r--r--drivers/usb/serial/ir-usb.c3
-rw-r--r--drivers/video/aty/radeon_backlight.c6
38 files changed, 1247 insertions, 1606 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 3c74ea729fc7..18dd026f470d 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -210,7 +210,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
210{ 210{
211 struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */ 211 struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
212 struct address_space *mapping = file->f_mapping; 212 struct address_space *mapping = file->f_mapping;
213 struct address_space_operations *aops = mapping->a_ops; 213 const struct address_space_operations *aops = mapping->a_ops;
214 pgoff_t index; 214 pgoff_t index;
215 unsigned offset, bv_offs; 215 unsigned offset, bv_offs;
216 int len, ret; 216 int len, ret;
@@ -784,7 +784,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
784 784
785 error = -EINVAL; 785 error = -EINVAL;
786 if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) { 786 if (S_ISREG(inode->i_mode) || S_ISBLK(inode->i_mode)) {
787 struct address_space_operations *aops = mapping->a_ops; 787 const struct address_space_operations *aops = mapping->a_ops;
788 /* 788 /*
789 * If we can't read - sorry. If we only can't write - well, 789 * If we can't read - sorry. If we only can't write - well,
790 * it's going to be read-only. 790 * it's going to be read-only.
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 940bfd7951e5..0378da04cfa2 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -191,7 +191,7 @@ static int ramdisk_set_page_dirty(struct page *page)
191 return 0; 191 return 0;
192} 192}
193 193
194static struct address_space_operations ramdisk_aops = { 194static const struct address_space_operations ramdisk_aops = {
195 .readpage = ramdisk_readpage, 195 .readpage = ramdisk_readpage,
196 .prepare_write = ramdisk_prepare_write, 196 .prepare_write = ramdisk_prepare_write,
197 .commit_write = ramdisk_commit_write, 197 .commit_write = ramdisk_commit_write,
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 83ed6ae466a5..ad26f4b997c5 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -3738,11 +3738,8 @@ static int ipmi_init_msghandler(void)
3738 proc_ipmi_root->owner = THIS_MODULE; 3738 proc_ipmi_root->owner = THIS_MODULE;
3739#endif /* CONFIG_PROC_FS */ 3739#endif /* CONFIG_PROC_FS */
3740 3740
3741 init_timer(&ipmi_timer); 3741 setup_timer(&ipmi_timer, ipmi_timeout, 0);
3742 ipmi_timer.data = 0; 3742 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
3743 ipmi_timer.function = ipmi_timeout;
3744 ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES;
3745 add_timer(&ipmi_timer);
3746 3743
3747 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 3744 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
3748 3745
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 101c14b9b26d..bd4f2248b758 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -55,23 +55,6 @@
55#include <linux/mutex.h> 55#include <linux/mutex.h>
56#include <linux/kthread.h> 56#include <linux/kthread.h>
57#include <asm/irq.h> 57#include <asm/irq.h>
58#ifdef CONFIG_HIGH_RES_TIMERS
59#include <linux/hrtime.h>
60# if defined(schedule_next_int)
61/* Old high-res timer code, do translations. */
62# define get_arch_cycles(a) quick_update_jiffies_sub(a)
63# define arch_cycles_per_jiffy cycles_per_jiffies
64# endif
65static inline void add_usec_to_timer(struct timer_list *t, long v)
66{
67 t->arch_cycle_expires += nsec_to_arch_cycle(v * 1000);
68 while (t->arch_cycle_expires >= arch_cycles_per_jiffy)
69 {
70 t->expires++;
71 t->arch_cycle_expires -= arch_cycles_per_jiffy;
72 }
73}
74#endif
75#include <linux/interrupt.h> 58#include <linux/interrupt.h>
76#include <linux/rcupdate.h> 59#include <linux/rcupdate.h>
77#include <linux/ipmi_smi.h> 60#include <linux/ipmi_smi.h>
@@ -243,8 +226,6 @@ static int register_xaction_notifier(struct notifier_block * nb)
243 return atomic_notifier_chain_register(&xaction_notifier_list, nb); 226 return atomic_notifier_chain_register(&xaction_notifier_list, nb);
244} 227}
245 228
246static void si_restart_short_timer(struct smi_info *smi_info);
247
248static void deliver_recv_msg(struct smi_info *smi_info, 229static void deliver_recv_msg(struct smi_info *smi_info,
249 struct ipmi_smi_msg *msg) 230 struct ipmi_smi_msg *msg)
250{ 231{
@@ -768,7 +749,6 @@ static void sender(void *send_info,
768 && (smi_info->curr_msg == NULL)) 749 && (smi_info->curr_msg == NULL))
769 { 750 {
770 start_next_msg(smi_info); 751 start_next_msg(smi_info);
771 si_restart_short_timer(smi_info);
772 } 752 }
773 spin_unlock_irqrestore(&(smi_info->si_lock), flags); 753 spin_unlock_irqrestore(&(smi_info->si_lock), flags);
774} 754}
@@ -833,37 +813,6 @@ static void request_events(void *send_info)
833 813
834static int initialized = 0; 814static int initialized = 0;
835 815
836/* Must be called with interrupts off and with the si_lock held. */
837static void si_restart_short_timer(struct smi_info *smi_info)
838{
839#if defined(CONFIG_HIGH_RES_TIMERS)
840 unsigned long flags;
841 unsigned long jiffies_now;
842 unsigned long seq;
843
844 if (del_timer(&(smi_info->si_timer))) {
845 /* If we don't delete the timer, then it will go off
846 immediately, anyway. So we only process if we
847 actually delete the timer. */
848
849 do {
850 seq = read_seqbegin_irqsave(&xtime_lock, flags);
851 jiffies_now = jiffies;
852 smi_info->si_timer.expires = jiffies_now;
853 smi_info->si_timer.arch_cycle_expires
854 = get_arch_cycles(jiffies_now);
855 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
856
857 add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
858
859 add_timer(&(smi_info->si_timer));
860 spin_lock_irqsave(&smi_info->count_lock, flags);
861 smi_info->timeout_restarts++;
862 spin_unlock_irqrestore(&smi_info->count_lock, flags);
863 }
864#endif
865}
866
867static void smi_timeout(unsigned long data) 816static void smi_timeout(unsigned long data)
868{ 817{
869 struct smi_info *smi_info = (struct smi_info *) data; 818 struct smi_info *smi_info = (struct smi_info *) data;
@@ -904,31 +853,15 @@ static void smi_timeout(unsigned long data)
904 /* If the state machine asks for a short delay, then shorten 853 /* If the state machine asks for a short delay, then shorten
905 the timer timeout. */ 854 the timer timeout. */
906 if (smi_result == SI_SM_CALL_WITH_DELAY) { 855 if (smi_result == SI_SM_CALL_WITH_DELAY) {
907#if defined(CONFIG_HIGH_RES_TIMERS)
908 unsigned long seq;
909#endif
910 spin_lock_irqsave(&smi_info->count_lock, flags); 856 spin_lock_irqsave(&smi_info->count_lock, flags);
911 smi_info->short_timeouts++; 857 smi_info->short_timeouts++;
912 spin_unlock_irqrestore(&smi_info->count_lock, flags); 858 spin_unlock_irqrestore(&smi_info->count_lock, flags);
913#if defined(CONFIG_HIGH_RES_TIMERS)
914 do {
915 seq = read_seqbegin_irqsave(&xtime_lock, flags);
916 smi_info->si_timer.expires = jiffies;
917 smi_info->si_timer.arch_cycle_expires
918 = get_arch_cycles(smi_info->si_timer.expires);
919 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
920 add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC);
921#else
922 smi_info->si_timer.expires = jiffies + 1; 859 smi_info->si_timer.expires = jiffies + 1;
923#endif
924 } else { 860 } else {
925 spin_lock_irqsave(&smi_info->count_lock, flags); 861 spin_lock_irqsave(&smi_info->count_lock, flags);
926 smi_info->long_timeouts++; 862 smi_info->long_timeouts++;
927 spin_unlock_irqrestore(&smi_info->count_lock, flags); 863 spin_unlock_irqrestore(&smi_info->count_lock, flags);
928 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; 864 smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES;
929#if defined(CONFIG_HIGH_RES_TIMERS)
930 smi_info->si_timer.arch_cycle_expires = 0;
931#endif
932 } 865 }
933 866
934 do_add_timer: 867 do_add_timer:
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 8f8867170973..1a0a19c53605 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -949,9 +949,10 @@ static int wdog_reboot_handler(struct notifier_block *this,
949 /* Disable the WDT if we are shutting down. */ 949 /* Disable the WDT if we are shutting down. */
950 ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 950 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
951 panic_halt_ipmi_set_timeout(); 951 panic_halt_ipmi_set_timeout();
952 } else { 952 } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
953 /* Set a long timer to let the reboot happens, but 953 /* Set a long timer to let the reboot happens, but
954 reboot if it hangs. */ 954 reboot if it hangs, but only if the watchdog
955 timer was already running. */
955 timeout = 120; 956 timeout = 120;
956 pretimeout = 0; 957 pretimeout = 0;
957 ipmi_watchdog_state = WDOG_TIMEOUT_RESET; 958 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
@@ -973,16 +974,17 @@ static int wdog_panic_handler(struct notifier_block *this,
973{ 974{
974 static int panic_event_handled = 0; 975 static int panic_event_handled = 0;
975 976
976 /* On a panic, if we have a panic timeout, make sure that the thing 977 /* On a panic, if we have a panic timeout, make sure to extend
977 reboots, even if it hangs during that panic. */ 978 the watchdog timer to a reasonable value to complete the
978 if (watchdog_user && !panic_event_handled) { 979 panic, if the watchdog timer is running. Plus the
979 /* Make sure the panic doesn't hang, and make sure we 980 pretimeout is meaningless at panic time. */
980 do this only once. */ 981 if (watchdog_user && !panic_event_handled &&
982 ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
983 /* Make sure we do this only once. */
981 panic_event_handled = 1; 984 panic_event_handled = 1;
982 985
983 timeout = 255; 986 timeout = 255;
984 pretimeout = 0; 987 pretimeout = 0;
985 ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
986 panic_halt_ipmi_set_timeout(); 988 panic_halt_ipmi_set_timeout();
987 } 989 }
988 990
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ef20c1fc9c4c..216c79256de3 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -42,13 +42,12 @@
42#include <linux/devfs_fs_kernel.h> 42#include <linux/devfs_fs_kernel.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/wait.h> 44#include <linux/wait.h>
45#include <linux/eisa.h>
45 46
46#include <asm/io.h> 47#include <asm/io.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#ifdef CONFIG_PCI
50#include <linux/pci.h> 50#include <linux/pci.h>
51#endif
52 51
53/*****************************************************************************/ 52/*****************************************************************************/
54 53
@@ -137,6 +136,10 @@ static stlconf_t stli_brdconf[] = {
137 136
138static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); 137static int stli_nrbrds = ARRAY_SIZE(stli_brdconf);
139 138
139/* stli_lock must NOT be taken holding brd_lock */
140static spinlock_t stli_lock; /* TTY logic lock */
141static spinlock_t brd_lock; /* Board logic lock */
142
140/* 143/*
141 * There is some experimental EISA board detection code in this driver. 144 * There is some experimental EISA board detection code in this driver.
142 * By default it is disabled, but for those that want to try it out, 145 * By default it is disabled, but for those that want to try it out,
@@ -173,14 +176,6 @@ static char *stli_serialname = "ttyE";
173 176
174static struct tty_driver *stli_serial; 177static struct tty_driver *stli_serial;
175 178
176/*
177 * We will need to allocate a temporary write buffer for chars that
178 * come direct from user space. The problem is that a copy from user
179 * space might cause a page fault (typically on a system that is
180 * swapping!). All ports will share one buffer - since if the system
181 * is already swapping a shared buffer won't make things any worse.
182 */
183static char *stli_tmpwritebuf;
184 179
185#define STLI_TXBUFSIZE 4096 180#define STLI_TXBUFSIZE 4096
186 181
@@ -419,7 +414,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);
419#endif 414#endif
420 415
421static struct pci_device_id istallion_pci_tbl[] = { 416static struct pci_device_id istallion_pci_tbl[] = {
422 { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 417 { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA), },
423 { 0 } 418 { 0 }
424}; 419};
425MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); 420MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
@@ -682,7 +677,7 @@ static int stli_startbrd(stlibrd_t *brdp);
682static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); 677static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp);
683static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); 678static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp);
684static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); 679static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
685static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp); 680static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp);
686static void stli_poll(unsigned long arg); 681static void stli_poll(unsigned long arg);
687static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); 682static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp);
688static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); 683static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
@@ -693,7 +688,8 @@ static void stli_dohangup(void *arg);
693static int stli_setport(stliport_t *portp); 688static int stli_setport(stliport_t *portp);
694static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 689static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
695static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 690static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
696static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp); 691static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
692static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
697static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); 693static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
698static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); 694static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
699static long stli_mktiocm(unsigned long sigvalue); 695static long stli_mktiocm(unsigned long sigvalue);
@@ -799,18 +795,8 @@ static struct class *istallion_class;
799 795
800static int __init istallion_module_init(void) 796static int __init istallion_module_init(void)
801{ 797{
802 unsigned long flags;
803
804#ifdef DEBUG
805 printk("init_module()\n");
806#endif
807
808 save_flags(flags);
809 cli();
810 stli_init(); 798 stli_init();
811 restore_flags(flags); 799 return 0;
812
813 return(0);
814} 800}
815 801
816/*****************************************************************************/ 802/*****************************************************************************/
@@ -819,33 +805,24 @@ static void __exit istallion_module_exit(void)
819{ 805{
820 stlibrd_t *brdp; 806 stlibrd_t *brdp;
821 stliport_t *portp; 807 stliport_t *portp;
822 unsigned long flags;
823 int i, j; 808 int i, j;
824 809
825#ifdef DEBUG
826 printk("cleanup_module()\n");
827#endif
828
829 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, 810 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
830 stli_drvversion); 811 stli_drvversion);
831 812
832 save_flags(flags); 813 /*
833 cli(); 814 * Free up all allocated resources used by the ports. This includes
834 815 * memory and interrupts.
835/* 816 */
836 * Free up all allocated resources used by the ports. This includes
837 * memory and interrupts.
838 */
839 if (stli_timeron) { 817 if (stli_timeron) {
840 stli_timeron = 0; 818 stli_timeron = 0;
841 del_timer(&stli_timerlist); 819 del_timer_sync(&stli_timerlist);
842 } 820 }
843 821
844 i = tty_unregister_driver(stli_serial); 822 i = tty_unregister_driver(stli_serial);
845 if (i) { 823 if (i) {
846 printk("STALLION: failed to un-register tty driver, " 824 printk("STALLION: failed to un-register tty driver, "
847 "errno=%d\n", -i); 825 "errno=%d\n", -i);
848 restore_flags(flags);
849 return; 826 return;
850 } 827 }
851 put_tty_driver(stli_serial); 828 put_tty_driver(stli_serial);
@@ -859,16 +836,15 @@ static void __exit istallion_module_exit(void)
859 printk("STALLION: failed to un-register serial memory device, " 836 printk("STALLION: failed to un-register serial memory device, "
860 "errno=%d\n", -i); 837 "errno=%d\n", -i);
861 838
862 kfree(stli_tmpwritebuf);
863 kfree(stli_txcookbuf); 839 kfree(stli_txcookbuf);
864 840
865 for (i = 0; (i < stli_nrbrds); i++) { 841 for (i = 0; (i < stli_nrbrds); i++) {
866 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) 842 if ((brdp = stli_brds[i]) == NULL)
867 continue; 843 continue;
868 for (j = 0; (j < STL_MAXPORTS); j++) { 844 for (j = 0; (j < STL_MAXPORTS); j++) {
869 portp = brdp->ports[j]; 845 portp = brdp->ports[j];
870 if (portp != (stliport_t *) NULL) { 846 if (portp != NULL) {
871 if (portp->tty != (struct tty_struct *) NULL) 847 if (portp->tty != NULL)
872 tty_hangup(portp->tty); 848 tty_hangup(portp->tty);
873 kfree(portp); 849 kfree(portp);
874 } 850 }
@@ -878,10 +854,8 @@ static void __exit istallion_module_exit(void)
878 if (brdp->iosize > 0) 854 if (brdp->iosize > 0)
879 release_region(brdp->iobase, brdp->iosize); 855 release_region(brdp->iobase, brdp->iosize);
880 kfree(brdp); 856 kfree(brdp);
881 stli_brds[i] = (stlibrd_t *) NULL; 857 stli_brds[i] = NULL;
882 } 858 }
883
884 restore_flags(flags);
885} 859}
886 860
887module_init(istallion_module_init); 861module_init(istallion_module_init);
@@ -895,19 +869,15 @@ module_exit(istallion_module_exit);
895 869
896static void stli_argbrds(void) 870static void stli_argbrds(void)
897{ 871{
898 stlconf_t conf; 872 stlconf_t conf;
899 stlibrd_t *brdp; 873 stlibrd_t *brdp;
900 int i; 874 int i;
901
902#ifdef DEBUG
903 printk("stli_argbrds()\n");
904#endif
905 875
906 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { 876 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
907 memset(&conf, 0, sizeof(conf)); 877 memset(&conf, 0, sizeof(conf));
908 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) 878 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
909 continue; 879 continue;
910 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 880 if ((brdp = stli_allocbrd()) == NULL)
911 continue; 881 continue;
912 stli_nrbrds = i + 1; 882 stli_nrbrds = i + 1;
913 brdp->brdnr = i; 883 brdp->brdnr = i;
@@ -926,9 +896,9 @@ static void stli_argbrds(void)
926 896
927static unsigned long stli_atol(char *str) 897static unsigned long stli_atol(char *str)
928{ 898{
929 unsigned long val; 899 unsigned long val;
930 int base, c; 900 int base, c;
931 char *sp; 901 char *sp;
932 902
933 val = 0; 903 val = 0;
934 sp = str; 904 sp = str;
@@ -962,15 +932,11 @@ static unsigned long stli_atol(char *str)
962 932
963static int stli_parsebrd(stlconf_t *confp, char **argp) 933static int stli_parsebrd(stlconf_t *confp, char **argp)
964{ 934{
965 char *sp; 935 char *sp;
966 int i; 936 int i;
967
968#ifdef DEBUG
969 printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp);
970#endif
971 937
972 if ((argp[0] == (char *) NULL) || (*argp[0] == 0)) 938 if (argp[0] == NULL || *argp[0] == 0)
973 return(0); 939 return 0;
974 940
975 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) 941 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
976 *sp = TOLOWER(*sp); 942 *sp = TOLOWER(*sp);
@@ -985,9 +951,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
985 } 951 }
986 952
987 confp->brdtype = stli_brdstr[i].type; 953 confp->brdtype = stli_brdstr[i].type;
988 if ((argp[1] != (char *) NULL) && (*argp[1] != 0)) 954 if (argp[1] != NULL && *argp[1] != 0)
989 confp->ioaddr1 = stli_atol(argp[1]); 955 confp->ioaddr1 = stli_atol(argp[1]);
990 if ((argp[2] != (char *) NULL) && (*argp[2] != 0)) 956 if (argp[2] != NULL && *argp[2] != 0)
991 confp->memaddr = stli_atol(argp[2]); 957 confp->memaddr = stli_atol(argp[2]);
992 return(1); 958 return(1);
993} 959}
@@ -998,34 +964,29 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
998 964
999static int stli_open(struct tty_struct *tty, struct file *filp) 965static int stli_open(struct tty_struct *tty, struct file *filp)
1000{ 966{
1001 stlibrd_t *brdp; 967 stlibrd_t *brdp;
1002 stliport_t *portp; 968 stliport_t *portp;
1003 unsigned int minordev; 969 unsigned int minordev;
1004 int brdnr, portnr, rc; 970 int brdnr, portnr, rc;
1005
1006#ifdef DEBUG
1007 printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty,
1008 (int) filp, tty->name);
1009#endif
1010 971
1011 minordev = tty->index; 972 minordev = tty->index;
1012 brdnr = MINOR2BRD(minordev); 973 brdnr = MINOR2BRD(minordev);
1013 if (brdnr >= stli_nrbrds) 974 if (brdnr >= stli_nrbrds)
1014 return(-ENODEV); 975 return -ENODEV;
1015 brdp = stli_brds[brdnr]; 976 brdp = stli_brds[brdnr];
1016 if (brdp == (stlibrd_t *) NULL) 977 if (brdp == NULL)
1017 return(-ENODEV); 978 return -ENODEV;
1018 if ((brdp->state & BST_STARTED) == 0) 979 if ((brdp->state & BST_STARTED) == 0)
1019 return(-ENODEV); 980 return -ENODEV;
1020 portnr = MINOR2PORT(minordev); 981 portnr = MINOR2PORT(minordev);
1021 if ((portnr < 0) || (portnr > brdp->nrports)) 982 if ((portnr < 0) || (portnr > brdp->nrports))
1022 return(-ENODEV); 983 return -ENODEV;
1023 984
1024 portp = brdp->ports[portnr]; 985 portp = brdp->ports[portnr];
1025 if (portp == (stliport_t *) NULL) 986 if (portp == NULL)
1026 return(-ENODEV); 987 return -ENODEV;
1027 if (portp->devnr < 1) 988 if (portp->devnr < 1)
1028 return(-ENODEV); 989 return -ENODEV;
1029 990
1030 991
1031/* 992/*
@@ -1037,8 +998,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1037 if (portp->flags & ASYNC_CLOSING) { 998 if (portp->flags & ASYNC_CLOSING) {
1038 interruptible_sleep_on(&portp->close_wait); 999 interruptible_sleep_on(&portp->close_wait);
1039 if (portp->flags & ASYNC_HUP_NOTIFY) 1000 if (portp->flags & ASYNC_HUP_NOTIFY)
1040 return(-EAGAIN); 1001 return -EAGAIN;
1041 return(-ERESTARTSYS); 1002 return -ERESTARTSYS;
1042 } 1003 }
1043 1004
1044/* 1005/*
@@ -1054,7 +1015,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1054 wait_event_interruptible(portp->raw_wait, 1015 wait_event_interruptible(portp->raw_wait,
1055 !test_bit(ST_INITIALIZING, &portp->state)); 1016 !test_bit(ST_INITIALIZING, &portp->state));
1056 if (signal_pending(current)) 1017 if (signal_pending(current))
1057 return(-ERESTARTSYS); 1018 return -ERESTARTSYS;
1058 1019
1059 if ((portp->flags & ASYNC_INITIALIZED) == 0) { 1020 if ((portp->flags & ASYNC_INITIALIZED) == 0) {
1060 set_bit(ST_INITIALIZING, &portp->state); 1021 set_bit(ST_INITIALIZING, &portp->state);
@@ -1065,7 +1026,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1065 clear_bit(ST_INITIALIZING, &portp->state); 1026 clear_bit(ST_INITIALIZING, &portp->state);
1066 wake_up_interruptible(&portp->raw_wait); 1027 wake_up_interruptible(&portp->raw_wait);
1067 if (rc < 0) 1028 if (rc < 0)
1068 return(rc); 1029 return rc;
1069 } 1030 }
1070 1031
1071/* 1032/*
@@ -1077,8 +1038,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1077 if (portp->flags & ASYNC_CLOSING) { 1038 if (portp->flags & ASYNC_CLOSING) {
1078 interruptible_sleep_on(&portp->close_wait); 1039 interruptible_sleep_on(&portp->close_wait);
1079 if (portp->flags & ASYNC_HUP_NOTIFY) 1040 if (portp->flags & ASYNC_HUP_NOTIFY)
1080 return(-EAGAIN); 1041 return -EAGAIN;
1081 return(-ERESTARTSYS); 1042 return -ERESTARTSYS;
1082 } 1043 }
1083 1044
1084/* 1045/*
@@ -1088,38 +1049,33 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1088 */ 1049 */
1089 if (!(filp->f_flags & O_NONBLOCK)) { 1050 if (!(filp->f_flags & O_NONBLOCK)) {
1090 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0) 1051 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0)
1091 return(rc); 1052 return rc;
1092 } 1053 }
1093 portp->flags |= ASYNC_NORMAL_ACTIVE; 1054 portp->flags |= ASYNC_NORMAL_ACTIVE;
1094 return(0); 1055 return 0;
1095} 1056}
1096 1057
1097/*****************************************************************************/ 1058/*****************************************************************************/
1098 1059
1099static void stli_close(struct tty_struct *tty, struct file *filp) 1060static void stli_close(struct tty_struct *tty, struct file *filp)
1100{ 1061{
1101 stlibrd_t *brdp; 1062 stlibrd_t *brdp;
1102 stliport_t *portp; 1063 stliport_t *portp;
1103 unsigned long flags; 1064 unsigned long flags;
1104
1105#ifdef DEBUG
1106 printk("stli_close(tty=%x,filp=%x)\n", (int) tty, (int) filp);
1107#endif
1108 1065
1109 portp = tty->driver_data; 1066 portp = tty->driver_data;
1110 if (portp == (stliport_t *) NULL) 1067 if (portp == NULL)
1111 return; 1068 return;
1112 1069
1113 save_flags(flags); 1070 spin_lock_irqsave(&stli_lock, flags);
1114 cli();
1115 if (tty_hung_up_p(filp)) { 1071 if (tty_hung_up_p(filp)) {
1116 restore_flags(flags); 1072 spin_unlock_irqrestore(&stli_lock, flags);
1117 return; 1073 return;
1118 } 1074 }
1119 if ((tty->count == 1) && (portp->refcount != 1)) 1075 if ((tty->count == 1) && (portp->refcount != 1))
1120 portp->refcount = 1; 1076 portp->refcount = 1;
1121 if (portp->refcount-- > 1) { 1077 if (portp->refcount-- > 1) {
1122 restore_flags(flags); 1078 spin_unlock_irqrestore(&stli_lock, flags);
1123 return; 1079 return;
1124 } 1080 }
1125 1081
@@ -1134,6 +1090,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1134 if (tty == stli_txcooktty) 1090 if (tty == stli_txcooktty)
1135 stli_flushchars(tty); 1091 stli_flushchars(tty);
1136 tty->closing = 1; 1092 tty->closing = 1;
1093 spin_unlock_irqrestore(&stli_lock, flags);
1094
1137 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1095 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1138 tty_wait_until_sent(tty, portp->closing_wait); 1096 tty_wait_until_sent(tty, portp->closing_wait);
1139 1097
@@ -1157,7 +1115,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1157 stli_flushbuffer(tty); 1115 stli_flushbuffer(tty);
1158 1116
1159 tty->closing = 0; 1117 tty->closing = 0;
1160 portp->tty = (struct tty_struct *) NULL; 1118 portp->tty = NULL;
1161 1119
1162 if (portp->openwaitcnt) { 1120 if (portp->openwaitcnt) {
1163 if (portp->close_delay) 1121 if (portp->close_delay)
@@ -1167,7 +1125,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1167 1125
1168 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1126 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1169 wake_up_interruptible(&portp->close_wait); 1127 wake_up_interruptible(&portp->close_wait);
1170 restore_flags(flags);
1171} 1128}
1172 1129
1173/*****************************************************************************/ 1130/*****************************************************************************/
@@ -1182,45 +1139,41 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1182 1139
1183static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) 1140static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1184{ 1141{
1185 struct tty_struct *tty; 1142 struct tty_struct *tty;
1186 asynotify_t nt; 1143 asynotify_t nt;
1187 asyport_t aport; 1144 asyport_t aport;
1188 int rc; 1145 int rc;
1189
1190#ifdef DEBUG
1191 printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp, (int) portp);
1192#endif
1193 1146
1194 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0) 1147 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0)
1195 return(rc); 1148 return rc;
1196 1149
1197 memset(&nt, 0, sizeof(asynotify_t)); 1150 memset(&nt, 0, sizeof(asynotify_t));
1198 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK); 1151 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK);
1199 nt.signal = SG_DCD; 1152 nt.signal = SG_DCD;
1200 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt, 1153 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt,
1201 sizeof(asynotify_t), 0)) < 0) 1154 sizeof(asynotify_t), 0)) < 0)
1202 return(rc); 1155 return rc;
1203 1156
1204 tty = portp->tty; 1157 tty = portp->tty;
1205 if (tty == (struct tty_struct *) NULL) 1158 if (tty == NULL)
1206 return(-ENODEV); 1159 return -ENODEV;
1207 stli_mkasyport(portp, &aport, tty->termios); 1160 stli_mkasyport(portp, &aport, tty->termios);
1208 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport, 1161 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport,
1209 sizeof(asyport_t), 0)) < 0) 1162 sizeof(asyport_t), 0)) < 0)
1210 return(rc); 1163 return rc;
1211 1164
1212 set_bit(ST_GETSIGS, &portp->state); 1165 set_bit(ST_GETSIGS, &portp->state);
1213 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, 1166 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig,
1214 sizeof(asysigs_t), 1)) < 0) 1167 sizeof(asysigs_t), 1)) < 0)
1215 return(rc); 1168 return rc;
1216 if (test_and_clear_bit(ST_GETSIGS, &portp->state)) 1169 if (test_and_clear_bit(ST_GETSIGS, &portp->state))
1217 portp->sigs = stli_mktiocm(portp->asig.sigvalue); 1170 portp->sigs = stli_mktiocm(portp->asig.sigvalue);
1218 stli_mkasysigs(&portp->asig, 1, 1); 1171 stli_mkasysigs(&portp->asig, 1, 1);
1219 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, 1172 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
1220 sizeof(asysigs_t), 0)) < 0) 1173 sizeof(asysigs_t), 0)) < 0)
1221 return(rc); 1174 return rc;
1222 1175
1223 return(0); 1176 return 0;
1224} 1177}
1225 1178
1226/*****************************************************************************/ 1179/*****************************************************************************/
@@ -1234,22 +1187,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1234 1187
1235static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1188static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1236{ 1189{
1237 volatile cdkhdr_t *hdrp; 1190 cdkhdr_t __iomem *hdrp;
1238 volatile cdkctrl_t *cp; 1191 cdkctrl_t __iomem *cp;
1239 volatile unsigned char *bits; 1192 unsigned char __iomem *bits;
1240 unsigned long flags; 1193 unsigned long flags;
1241 int rc; 1194 int rc;
1242
1243#ifdef DEBUG
1244 printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1245 (int) brdp, (int) portp, (int) arg, wait);
1246#endif
1247 1195
1248/* 1196/*
1249 * Send a message to the slave to open this port. 1197 * Send a message to the slave to open this port.
1250 */ 1198 */
1251 save_flags(flags);
1252 cli();
1253 1199
1254/* 1200/*
1255 * Slave is already closing this port. This can happen if a hangup 1201 * Slave is already closing this port. This can happen if a hangup
@@ -1260,7 +1206,6 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1260 wait_event_interruptible(portp->raw_wait, 1206 wait_event_interruptible(portp->raw_wait,
1261 !test_bit(ST_CLOSING, &portp->state)); 1207 !test_bit(ST_CLOSING, &portp->state));
1262 if (signal_pending(current)) { 1208 if (signal_pending(current)) {
1263 restore_flags(flags);
1264 return -ERESTARTSYS; 1209 return -ERESTARTSYS;
1265 } 1210 }
1266 1211
@@ -1269,19 +1214,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1269 * memory. Once the message is in set the service bits to say that 1214 * memory. Once the message is in set the service bits to say that
1270 * this port wants service. 1215 * this port wants service.
1271 */ 1216 */
1217 spin_lock_irqsave(&brd_lock, flags);
1272 EBRDENABLE(brdp); 1218 EBRDENABLE(brdp);
1273 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1219 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1274 cp->openarg = arg; 1220 writel(arg, &cp->openarg);
1275 cp->open = 1; 1221 writeb(1, &cp->open);
1276 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1222 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1277 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1223 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1278 portp->portidx; 1224 portp->portidx;
1279 *bits |= portp->portbit; 1225 writeb(readb(bits) | portp->portbit, bits);
1280 EBRDDISABLE(brdp); 1226 EBRDDISABLE(brdp);
1281 1227
1282 if (wait == 0) { 1228 if (wait == 0) {
1283 restore_flags(flags); 1229 spin_unlock_irqrestore(&brd_lock, flags);
1284 return(0); 1230 return 0;
1285 } 1231 }
1286 1232
1287/* 1233/*
@@ -1290,15 +1236,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1290 */ 1236 */
1291 rc = 0; 1237 rc = 0;
1292 set_bit(ST_OPENING, &portp->state); 1238 set_bit(ST_OPENING, &portp->state);
1239 spin_unlock_irqrestore(&brd_lock, flags);
1240
1293 wait_event_interruptible(portp->raw_wait, 1241 wait_event_interruptible(portp->raw_wait,
1294 !test_bit(ST_OPENING, &portp->state)); 1242 !test_bit(ST_OPENING, &portp->state));
1295 if (signal_pending(current)) 1243 if (signal_pending(current))
1296 rc = -ERESTARTSYS; 1244 rc = -ERESTARTSYS;
1297 restore_flags(flags);
1298 1245
1299 if ((rc == 0) && (portp->rc != 0)) 1246 if ((rc == 0) && (portp->rc != 0))
1300 rc = -EIO; 1247 rc = -EIO;
1301 return(rc); 1248 return rc;
1302} 1249}
1303 1250
1304/*****************************************************************************/ 1251/*****************************************************************************/
@@ -1311,19 +1258,11 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1311 1258
1312static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1259static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1313{ 1260{
1314 volatile cdkhdr_t *hdrp; 1261 cdkhdr_t __iomem *hdrp;
1315 volatile cdkctrl_t *cp; 1262 cdkctrl_t __iomem *cp;
1316 volatile unsigned char *bits; 1263 unsigned char __iomem *bits;
1317 unsigned long flags; 1264 unsigned long flags;
1318 int rc; 1265 int rc;
1319
1320#ifdef DEBUG
1321 printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1322 (int) brdp, (int) portp, (int) arg, wait);
1323#endif
1324
1325 save_flags(flags);
1326 cli();
1327 1266
1328/* 1267/*
1329 * Slave is already closing this port. This can happen if a hangup 1268 * Slave is already closing this port. This can happen if a hangup
@@ -1333,7 +1272,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1333 wait_event_interruptible(portp->raw_wait, 1272 wait_event_interruptible(portp->raw_wait,
1334 !test_bit(ST_CLOSING, &portp->state)); 1273 !test_bit(ST_CLOSING, &portp->state));
1335 if (signal_pending(current)) { 1274 if (signal_pending(current)) {
1336 restore_flags(flags);
1337 return -ERESTARTSYS; 1275 return -ERESTARTSYS;
1338 } 1276 }
1339 } 1277 }
@@ -1341,21 +1279,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1341/* 1279/*
1342 * Write the close command into shared memory. 1280 * Write the close command into shared memory.
1343 */ 1281 */
1282 spin_lock_irqsave(&brd_lock, flags);
1344 EBRDENABLE(brdp); 1283 EBRDENABLE(brdp);
1345 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1284 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1346 cp->closearg = arg; 1285 writel(arg, &cp->closearg);
1347 cp->close = 1; 1286 writeb(1, &cp->close);
1348 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1287 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1349 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1288 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1350 portp->portidx; 1289 portp->portidx;
1351 *bits |= portp->portbit; 1290 writeb(readb(bits) |portp->portbit, bits);
1352 EBRDDISABLE(brdp); 1291 EBRDDISABLE(brdp);
1353 1292
1354 set_bit(ST_CLOSING, &portp->state); 1293 set_bit(ST_CLOSING, &portp->state);
1355 if (wait == 0) { 1294 spin_unlock_irqrestore(&brd_lock, flags);
1356 restore_flags(flags); 1295
1357 return(0); 1296 if (wait == 0)
1358 } 1297 return 0;
1359 1298
1360/* 1299/*
1361 * Slave is in action, so now we must wait for the open acknowledgment 1300 * Slave is in action, so now we must wait for the open acknowledgment
@@ -1366,11 +1305,10 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1366 !test_bit(ST_CLOSING, &portp->state)); 1305 !test_bit(ST_CLOSING, &portp->state));
1367 if (signal_pending(current)) 1306 if (signal_pending(current))
1368 rc = -ERESTARTSYS; 1307 rc = -ERESTARTSYS;
1369 restore_flags(flags);
1370 1308
1371 if ((rc == 0) && (portp->rc != 0)) 1309 if ((rc == 0) && (portp->rc != 0))
1372 rc = -EIO; 1310 rc = -EIO;
1373 return(rc); 1311 return rc;
1374} 1312}
1375 1313
1376/*****************************************************************************/ 1314/*****************************************************************************/
@@ -1384,36 +1322,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1384 1322
1385static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 1323static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
1386{ 1324{
1387 unsigned long flags;
1388
1389#ifdef DEBUG
1390 printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
1391 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
1392 (int) arg, size, copyback);
1393#endif
1394
1395 save_flags(flags);
1396 cli();
1397 wait_event_interruptible(portp->raw_wait, 1325 wait_event_interruptible(portp->raw_wait,
1398 !test_bit(ST_CMDING, &portp->state)); 1326 !test_bit(ST_CMDING, &portp->state));
1399 if (signal_pending(current)) { 1327 if (signal_pending(current))
1400 restore_flags(flags);
1401 return -ERESTARTSYS; 1328 return -ERESTARTSYS;
1402 }
1403 1329
1404 stli_sendcmd(brdp, portp, cmd, arg, size, copyback); 1330 stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
1405 1331
1406 wait_event_interruptible(portp->raw_wait, 1332 wait_event_interruptible(portp->raw_wait,
1407 !test_bit(ST_CMDING, &portp->state)); 1333 !test_bit(ST_CMDING, &portp->state));
1408 if (signal_pending(current)) { 1334 if (signal_pending(current))
1409 restore_flags(flags);
1410 return -ERESTARTSYS; 1335 return -ERESTARTSYS;
1411 }
1412 restore_flags(flags);
1413 1336
1414 if (portp->rc != 0) 1337 if (portp->rc != 0)
1415 return(-EIO); 1338 return -EIO;
1416 return(0); 1339 return 0;
1417} 1340}
1418 1341
1419/*****************************************************************************/ 1342/*****************************************************************************/
@@ -1425,22 +1348,18 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v
1425 1348
1426static int stli_setport(stliport_t *portp) 1349static int stli_setport(stliport_t *portp)
1427{ 1350{
1428 stlibrd_t *brdp; 1351 stlibrd_t *brdp;
1429 asyport_t aport; 1352 asyport_t aport;
1430
1431#ifdef DEBUG
1432 printk("stli_setport(portp=%x)\n", (int) portp);
1433#endif
1434 1353
1435 if (portp == (stliport_t *) NULL) 1354 if (portp == NULL)
1436 return(-ENODEV); 1355 return -ENODEV;
1437 if (portp->tty == (struct tty_struct *) NULL) 1356 if (portp->tty == NULL)
1438 return(-ENODEV); 1357 return -ENODEV;
1439 if ((portp->brdnr < 0) && (portp->brdnr >= stli_nrbrds)) 1358 if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds)
1440 return(-ENODEV); 1359 return -ENODEV;
1441 brdp = stli_brds[portp->brdnr]; 1360 brdp = stli_brds[portp->brdnr];
1442 if (brdp == (stlibrd_t *) NULL) 1361 if (brdp == NULL)
1443 return(-ENODEV); 1362 return -ENODEV;
1444 1363
1445 stli_mkasyport(portp, &aport, portp->tty->termios); 1364 stli_mkasyport(portp, &aport, portp->tty->termios);
1446 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)); 1365 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0));
@@ -1455,13 +1374,8 @@ static int stli_setport(stliport_t *portp)
1455 1374
1456static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp) 1375static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp)
1457{ 1376{
1458 unsigned long flags; 1377 unsigned long flags;
1459 int rc, doclocal; 1378 int rc, doclocal;
1460
1461#ifdef DEBUG
1462 printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n",
1463 (int) brdp, (int) portp, (int) filp);
1464#endif
1465 1379
1466 rc = 0; 1380 rc = 0;
1467 doclocal = 0; 1381 doclocal = 0;
@@ -1469,11 +1383,11 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1469 if (portp->tty->termios->c_cflag & CLOCAL) 1383 if (portp->tty->termios->c_cflag & CLOCAL)
1470 doclocal++; 1384 doclocal++;
1471 1385
1472 save_flags(flags); 1386 spin_lock_irqsave(&stli_lock, flags);
1473 cli();
1474 portp->openwaitcnt++; 1387 portp->openwaitcnt++;
1475 if (! tty_hung_up_p(filp)) 1388 if (! tty_hung_up_p(filp))
1476 portp->refcount--; 1389 portp->refcount--;
1390 spin_unlock_irqrestore(&stli_lock, flags);
1477 1391
1478 for (;;) { 1392 for (;;) {
1479 stli_mkasysigs(&portp->asig, 1, 1); 1393 stli_mkasysigs(&portp->asig, 1, 1);
@@ -1499,12 +1413,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1499 interruptible_sleep_on(&portp->open_wait); 1413 interruptible_sleep_on(&portp->open_wait);
1500 } 1414 }
1501 1415
1416 spin_lock_irqsave(&stli_lock, flags);
1502 if (! tty_hung_up_p(filp)) 1417 if (! tty_hung_up_p(filp))
1503 portp->refcount++; 1418 portp->refcount++;
1504 portp->openwaitcnt--; 1419 portp->openwaitcnt--;
1505 restore_flags(flags); 1420 spin_unlock_irqrestore(&stli_lock, flags);
1506 1421
1507 return(rc); 1422 return rc;
1508} 1423}
1509 1424
1510/*****************************************************************************/ 1425/*****************************************************************************/
@@ -1517,46 +1432,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1517 1432
1518static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count) 1433static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count)
1519{ 1434{
1520 volatile cdkasy_t *ap; 1435 cdkasy_t __iomem *ap;
1521 volatile cdkhdr_t *hdrp; 1436 cdkhdr_t __iomem *hdrp;
1522 volatile unsigned char *bits; 1437 unsigned char __iomem *bits;
1523 unsigned char *shbuf, *chbuf; 1438 unsigned char __iomem *shbuf;
1524 stliport_t *portp; 1439 unsigned char *chbuf;
1525 stlibrd_t *brdp; 1440 stliport_t *portp;
1526 unsigned int len, stlen, head, tail, size; 1441 stlibrd_t *brdp;
1527 unsigned long flags; 1442 unsigned int len, stlen, head, tail, size;
1528 1443 unsigned long flags;
1529#ifdef DEBUG
1530 printk("stli_write(tty=%x,buf=%x,count=%d)\n",
1531 (int) tty, (int) buf, count);
1532#endif
1533 1444
1534 if ((tty == (struct tty_struct *) NULL) ||
1535 (stli_tmpwritebuf == (char *) NULL))
1536 return(0);
1537 if (tty == stli_txcooktty) 1445 if (tty == stli_txcooktty)
1538 stli_flushchars(tty); 1446 stli_flushchars(tty);
1539 portp = tty->driver_data; 1447 portp = tty->driver_data;
1540 if (portp == (stliport_t *) NULL) 1448 if (portp == NULL)
1541 return(0); 1449 return 0;
1542 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1450 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1543 return(0); 1451 return 0;
1544 brdp = stli_brds[portp->brdnr]; 1452 brdp = stli_brds[portp->brdnr];
1545 if (brdp == (stlibrd_t *) NULL) 1453 if (brdp == NULL)
1546 return(0); 1454 return 0;
1547 chbuf = (unsigned char *) buf; 1455 chbuf = (unsigned char *) buf;
1548 1456
1549/* 1457/*
1550 * All data is now local, shove as much as possible into shared memory. 1458 * All data is now local, shove as much as possible into shared memory.
1551 */ 1459 */
1552 save_flags(flags); 1460 spin_lock_irqsave(&brd_lock, flags);
1553 cli();
1554 EBRDENABLE(brdp); 1461 EBRDENABLE(brdp);
1555 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1462 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1556 head = (unsigned int) ap->txq.head; 1463 head = (unsigned int) readw(&ap->txq.head);
1557 tail = (unsigned int) ap->txq.tail; 1464 tail = (unsigned int) readw(&ap->txq.tail);
1558 if (tail != ((unsigned int) ap->txq.tail)) 1465 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1559 tail = (unsigned int) ap->txq.tail; 1466 tail = (unsigned int) readw(&ap->txq.tail);
1560 size = portp->txsize; 1467 size = portp->txsize;
1561 if (head >= tail) { 1468 if (head >= tail) {
1562 len = size - (head - tail) - 1; 1469 len = size - (head - tail) - 1;
@@ -1568,11 +1475,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1568 1475
1569 len = MIN(len, count); 1476 len = MIN(len, count);
1570 count = 0; 1477 count = 0;
1571 shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); 1478 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
1572 1479
1573 while (len > 0) { 1480 while (len > 0) {
1574 stlen = MIN(len, stlen); 1481 stlen = MIN(len, stlen);
1575 memcpy((shbuf + head), chbuf, stlen); 1482 memcpy_toio(shbuf + head, chbuf, stlen);
1576 chbuf += stlen; 1483 chbuf += stlen;
1577 len -= stlen; 1484 len -= stlen;
1578 count += stlen; 1485 count += stlen;
@@ -1583,20 +1490,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1583 } 1490 }
1584 } 1491 }
1585 1492
1586 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1493 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1587 ap->txq.head = head; 1494 writew(head, &ap->txq.head);
1588 if (test_bit(ST_TXBUSY, &portp->state)) { 1495 if (test_bit(ST_TXBUSY, &portp->state)) {
1589 if (ap->changed.data & DT_TXEMPTY) 1496 if (readl(&ap->changed.data) & DT_TXEMPTY)
1590 ap->changed.data &= ~DT_TXEMPTY; 1497 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1591 } 1498 }
1592 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1499 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1593 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1500 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1594 portp->portidx; 1501 portp->portidx;
1595 *bits |= portp->portbit; 1502 writeb(readb(bits) | portp->portbit, bits);
1596 set_bit(ST_TXBUSY, &portp->state); 1503 set_bit(ST_TXBUSY, &portp->state);
1597 EBRDDISABLE(brdp); 1504 EBRDDISABLE(brdp);
1598 1505 spin_unlock_irqrestore(&brd_lock, flags);
1599 restore_flags(flags);
1600 1506
1601 return(count); 1507 return(count);
1602} 1508}
@@ -1613,14 +1519,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1613 1519
1614static void stli_putchar(struct tty_struct *tty, unsigned char ch) 1520static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1615{ 1521{
1616#ifdef DEBUG
1617 printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch);
1618#endif
1619
1620 if (tty == (struct tty_struct *) NULL)
1621 return;
1622 if (tty != stli_txcooktty) { 1522 if (tty != stli_txcooktty) {
1623 if (stli_txcooktty != (struct tty_struct *) NULL) 1523 if (stli_txcooktty != NULL)
1624 stli_flushchars(stli_txcooktty); 1524 stli_flushchars(stli_txcooktty);
1625 stli_txcooktty = tty; 1525 stli_txcooktty = tty;
1626 } 1526 }
@@ -1640,29 +1540,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1640 1540
1641static void stli_flushchars(struct tty_struct *tty) 1541static void stli_flushchars(struct tty_struct *tty)
1642{ 1542{
1643 volatile cdkhdr_t *hdrp; 1543 cdkhdr_t __iomem *hdrp;
1644 volatile unsigned char *bits; 1544 unsigned char __iomem *bits;
1645 volatile cdkasy_t *ap; 1545 cdkasy_t __iomem *ap;
1646 struct tty_struct *cooktty; 1546 struct tty_struct *cooktty;
1647 stliport_t *portp; 1547 stliport_t *portp;
1648 stlibrd_t *brdp; 1548 stlibrd_t *brdp;
1649 unsigned int len, stlen, head, tail, size, count, cooksize; 1549 unsigned int len, stlen, head, tail, size, count, cooksize;
1650 unsigned char *buf, *shbuf; 1550 unsigned char *buf;
1651 unsigned long flags; 1551 unsigned char __iomem *shbuf;
1652 1552 unsigned long flags;
1653#ifdef DEBUG
1654 printk("stli_flushchars(tty=%x)\n", (int) tty);
1655#endif
1656 1553
1657 cooksize = stli_txcooksize; 1554 cooksize = stli_txcooksize;
1658 cooktty = stli_txcooktty; 1555 cooktty = stli_txcooktty;
1659 stli_txcooksize = 0; 1556 stli_txcooksize = 0;
1660 stli_txcookrealsize = 0; 1557 stli_txcookrealsize = 0;
1661 stli_txcooktty = (struct tty_struct *) NULL; 1558 stli_txcooktty = NULL;
1662 1559
1663 if (tty == (struct tty_struct *) NULL) 1560 if (tty == NULL)
1664 return; 1561 return;
1665 if (cooktty == (struct tty_struct *) NULL) 1562 if (cooktty == NULL)
1666 return; 1563 return;
1667 if (tty != cooktty) 1564 if (tty != cooktty)
1668 tty = cooktty; 1565 tty = cooktty;
@@ -1670,23 +1567,22 @@ static void stli_flushchars(struct tty_struct *tty)
1670 return; 1567 return;
1671 1568
1672 portp = tty->driver_data; 1569 portp = tty->driver_data;
1673 if (portp == (stliport_t *) NULL) 1570 if (portp == NULL)
1674 return; 1571 return;
1675 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1572 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1676 return; 1573 return;
1677 brdp = stli_brds[portp->brdnr]; 1574 brdp = stli_brds[portp->brdnr];
1678 if (brdp == (stlibrd_t *) NULL) 1575 if (brdp == NULL)
1679 return; 1576 return;
1680 1577
1681 save_flags(flags); 1578 spin_lock_irqsave(&brd_lock, flags);
1682 cli();
1683 EBRDENABLE(brdp); 1579 EBRDENABLE(brdp);
1684 1580
1685 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1581 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1686 head = (unsigned int) ap->txq.head; 1582 head = (unsigned int) readw(&ap->txq.head);
1687 tail = (unsigned int) ap->txq.tail; 1583 tail = (unsigned int) readw(&ap->txq.tail);
1688 if (tail != ((unsigned int) ap->txq.tail)) 1584 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1689 tail = (unsigned int) ap->txq.tail; 1585 tail = (unsigned int) readw(&ap->txq.tail);
1690 size = portp->txsize; 1586 size = portp->txsize;
1691 if (head >= tail) { 1587 if (head >= tail) {
1692 len = size - (head - tail) - 1; 1588 len = size - (head - tail) - 1;
@@ -1703,7 +1599,7 @@ static void stli_flushchars(struct tty_struct *tty)
1703 1599
1704 while (len > 0) { 1600 while (len > 0) {
1705 stlen = MIN(len, stlen); 1601 stlen = MIN(len, stlen);
1706 memcpy((shbuf + head), buf, stlen); 1602 memcpy_toio(shbuf + head, buf, stlen);
1707 buf += stlen; 1603 buf += stlen;
1708 len -= stlen; 1604 len -= stlen;
1709 count += stlen; 1605 count += stlen;
@@ -1714,73 +1610,66 @@ static void stli_flushchars(struct tty_struct *tty)
1714 } 1610 }
1715 } 1611 }
1716 1612
1717 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1613 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1718 ap->txq.head = head; 1614 writew(head, &ap->txq.head);
1719 1615
1720 if (test_bit(ST_TXBUSY, &portp->state)) { 1616 if (test_bit(ST_TXBUSY, &portp->state)) {
1721 if (ap->changed.data & DT_TXEMPTY) 1617 if (readl(&ap->changed.data) & DT_TXEMPTY)
1722 ap->changed.data &= ~DT_TXEMPTY; 1618 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1723 } 1619 }
1724 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1620 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1725 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1621 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1726 portp->portidx; 1622 portp->portidx;
1727 *bits |= portp->portbit; 1623 writeb(readb(bits) | portp->portbit, bits);
1728 set_bit(ST_TXBUSY, &portp->state); 1624 set_bit(ST_TXBUSY, &portp->state);
1729 1625
1730 EBRDDISABLE(brdp); 1626 EBRDDISABLE(brdp);
1731 restore_flags(flags); 1627 spin_unlock_irqrestore(&brd_lock, flags);
1732} 1628}
1733 1629
1734/*****************************************************************************/ 1630/*****************************************************************************/
1735 1631
1736static int stli_writeroom(struct tty_struct *tty) 1632static int stli_writeroom(struct tty_struct *tty)
1737{ 1633{
1738 volatile cdkasyrq_t *rp; 1634 cdkasyrq_t __iomem *rp;
1739 stliport_t *portp; 1635 stliport_t *portp;
1740 stlibrd_t *brdp; 1636 stlibrd_t *brdp;
1741 unsigned int head, tail, len; 1637 unsigned int head, tail, len;
1742 unsigned long flags; 1638 unsigned long flags;
1743
1744#ifdef DEBUG
1745 printk("stli_writeroom(tty=%x)\n", (int) tty);
1746#endif
1747 1639
1748 if (tty == (struct tty_struct *) NULL)
1749 return(0);
1750 if (tty == stli_txcooktty) { 1640 if (tty == stli_txcooktty) {
1751 if (stli_txcookrealsize != 0) { 1641 if (stli_txcookrealsize != 0) {
1752 len = stli_txcookrealsize - stli_txcooksize; 1642 len = stli_txcookrealsize - stli_txcooksize;
1753 return(len); 1643 return len;
1754 } 1644 }
1755 } 1645 }
1756 1646
1757 portp = tty->driver_data; 1647 portp = tty->driver_data;
1758 if (portp == (stliport_t *) NULL) 1648 if (portp == NULL)
1759 return(0); 1649 return 0;
1760 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1650 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1761 return(0); 1651 return 0;
1762 brdp = stli_brds[portp->brdnr]; 1652 brdp = stli_brds[portp->brdnr];
1763 if (brdp == (stlibrd_t *) NULL) 1653 if (brdp == NULL)
1764 return(0); 1654 return 0;
1765 1655
1766 save_flags(flags); 1656 spin_lock_irqsave(&brd_lock, flags);
1767 cli();
1768 EBRDENABLE(brdp); 1657 EBRDENABLE(brdp);
1769 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1658 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1770 head = (unsigned int) rp->head; 1659 head = (unsigned int) readw(&rp->head);
1771 tail = (unsigned int) rp->tail; 1660 tail = (unsigned int) readw(&rp->tail);
1772 if (tail != ((unsigned int) rp->tail)) 1661 if (tail != ((unsigned int) readw(&rp->tail)))
1773 tail = (unsigned int) rp->tail; 1662 tail = (unsigned int) readw(&rp->tail);
1774 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head); 1663 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head);
1775 len--; 1664 len--;
1776 EBRDDISABLE(brdp); 1665 EBRDDISABLE(brdp);
1777 restore_flags(flags); 1666 spin_unlock_irqrestore(&brd_lock, flags);
1778 1667
1779 if (tty == stli_txcooktty) { 1668 if (tty == stli_txcooktty) {
1780 stli_txcookrealsize = len; 1669 stli_txcookrealsize = len;
1781 len -= stli_txcooksize; 1670 len -= stli_txcooksize;
1782 } 1671 }
1783 return(len); 1672 return len;
1784} 1673}
1785 1674
1786/*****************************************************************************/ 1675/*****************************************************************************/
@@ -1795,44 +1684,37 @@ static int stli_writeroom(struct tty_struct *tty)
1795 1684
1796static int stli_charsinbuffer(struct tty_struct *tty) 1685static int stli_charsinbuffer(struct tty_struct *tty)
1797{ 1686{
1798 volatile cdkasyrq_t *rp; 1687 cdkasyrq_t __iomem *rp;
1799 stliport_t *portp; 1688 stliport_t *portp;
1800 stlibrd_t *brdp; 1689 stlibrd_t *brdp;
1801 unsigned int head, tail, len; 1690 unsigned int head, tail, len;
1802 unsigned long flags; 1691 unsigned long flags;
1803
1804#ifdef DEBUG
1805 printk("stli_charsinbuffer(tty=%x)\n", (int) tty);
1806#endif
1807 1692
1808 if (tty == (struct tty_struct *) NULL)
1809 return(0);
1810 if (tty == stli_txcooktty) 1693 if (tty == stli_txcooktty)
1811 stli_flushchars(tty); 1694 stli_flushchars(tty);
1812 portp = tty->driver_data; 1695 portp = tty->driver_data;
1813 if (portp == (stliport_t *) NULL) 1696 if (portp == NULL)
1814 return(0); 1697 return 0;
1815 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1698 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1816 return(0); 1699 return 0;
1817 brdp = stli_brds[portp->brdnr]; 1700 brdp = stli_brds[portp->brdnr];
1818 if (brdp == (stlibrd_t *) NULL) 1701 if (brdp == NULL)
1819 return(0); 1702 return 0;
1820 1703
1821 save_flags(flags); 1704 spin_lock_irqsave(&brd_lock, flags);
1822 cli();
1823 EBRDENABLE(brdp); 1705 EBRDENABLE(brdp);
1824 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1706 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1825 head = (unsigned int) rp->head; 1707 head = (unsigned int) readw(&rp->head);
1826 tail = (unsigned int) rp->tail; 1708 tail = (unsigned int) readw(&rp->tail);
1827 if (tail != ((unsigned int) rp->tail)) 1709 if (tail != ((unsigned int) readw(&rp->tail)))
1828 tail = (unsigned int) rp->tail; 1710 tail = (unsigned int) readw(&rp->tail);
1829 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head)); 1711 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head));
1830 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state)) 1712 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state))
1831 len = 1; 1713 len = 1;
1832 EBRDDISABLE(brdp); 1714 EBRDDISABLE(brdp);
1833 restore_flags(flags); 1715 spin_unlock_irqrestore(&brd_lock, flags);
1834 1716
1835 return(len); 1717 return len;
1836} 1718}
1837 1719
1838/*****************************************************************************/ 1720/*****************************************************************************/
@@ -1843,12 +1725,8 @@ static int stli_charsinbuffer(struct tty_struct *tty)
1843 1725
1844static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) 1726static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1845{ 1727{
1846 struct serial_struct sio; 1728 struct serial_struct sio;
1847 stlibrd_t *brdp; 1729 stlibrd_t *brdp;
1848
1849#ifdef DEBUG
1850 printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
1851#endif
1852 1730
1853 memset(&sio, 0, sizeof(struct serial_struct)); 1731 memset(&sio, 0, sizeof(struct serial_struct));
1854 sio.type = PORT_UNKNOWN; 1732 sio.type = PORT_UNKNOWN;
@@ -1863,7 +1741,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1863 sio.hub6 = 0; 1741 sio.hub6 = 0;
1864 1742
1865 brdp = stli_brds[portp->brdnr]; 1743 brdp = stli_brds[portp->brdnr];
1866 if (brdp != (stlibrd_t *) NULL) 1744 if (brdp != NULL)
1867 sio.port = brdp->iobase; 1745 sio.port = brdp->iobase;
1868 1746
1869 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? 1747 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ?
@@ -1880,12 +1758,8 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1880 1758
1881static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) 1759static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1882{ 1760{
1883 struct serial_struct sio; 1761 struct serial_struct sio;
1884 int rc; 1762 int rc;
1885
1886#ifdef DEBUG
1887 printk("stli_setserial(portp=%p,sp=%p)\n", portp, sp);
1888#endif
1889 1763
1890 if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) 1764 if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
1891 return -EFAULT; 1765 return -EFAULT;
@@ -1894,7 +1768,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1894 (sio.close_delay != portp->close_delay) || 1768 (sio.close_delay != portp->close_delay) ||
1895 ((sio.flags & ~ASYNC_USR_MASK) != 1769 ((sio.flags & ~ASYNC_USR_MASK) !=
1896 (portp->flags & ~ASYNC_USR_MASK))) 1770 (portp->flags & ~ASYNC_USR_MASK)))
1897 return(-EPERM); 1771 return -EPERM;
1898 } 1772 }
1899 1773
1900 portp->flags = (portp->flags & ~ASYNC_USR_MASK) | 1774 portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
@@ -1905,8 +1779,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1905 portp->custom_divisor = sio.custom_divisor; 1779 portp->custom_divisor = sio.custom_divisor;
1906 1780
1907 if ((rc = stli_setport(portp)) < 0) 1781 if ((rc = stli_setport(portp)) < 0)
1908 return(rc); 1782 return rc;
1909 return(0); 1783 return 0;
1910} 1784}
1911 1785
1912/*****************************************************************************/ 1786/*****************************************************************************/
@@ -1917,19 +1791,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file)
1917 stlibrd_t *brdp; 1791 stlibrd_t *brdp;
1918 int rc; 1792 int rc;
1919 1793
1920 if (portp == (stliport_t *) NULL) 1794 if (portp == NULL)
1921 return(-ENODEV); 1795 return -ENODEV;
1922 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1796 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1923 return(0); 1797 return 0;
1924 brdp = stli_brds[portp->brdnr]; 1798 brdp = stli_brds[portp->brdnr];
1925 if (brdp == (stlibrd_t *) NULL) 1799 if (brdp == NULL)
1926 return(0); 1800 return 0;
1927 if (tty->flags & (1 << TTY_IO_ERROR)) 1801 if (tty->flags & (1 << TTY_IO_ERROR))
1928 return(-EIO); 1802 return -EIO;
1929 1803
1930 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, 1804 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS,
1931 &portp->asig, sizeof(asysigs_t), 1)) < 0) 1805 &portp->asig, sizeof(asysigs_t), 1)) < 0)
1932 return(rc); 1806 return rc;
1933 1807
1934 return stli_mktiocm(portp->asig.sigvalue); 1808 return stli_mktiocm(portp->asig.sigvalue);
1935} 1809}
@@ -1941,15 +1815,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1941 stlibrd_t *brdp; 1815 stlibrd_t *brdp;
1942 int rts = -1, dtr = -1; 1816 int rts = -1, dtr = -1;
1943 1817
1944 if (portp == (stliport_t *) NULL) 1818 if (portp == NULL)
1945 return(-ENODEV); 1819 return -ENODEV;
1946 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1820 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1947 return(0); 1821 return 0;
1948 brdp = stli_brds[portp->brdnr]; 1822 brdp = stli_brds[portp->brdnr];
1949 if (brdp == (stlibrd_t *) NULL) 1823 if (brdp == NULL)
1950 return(0); 1824 return 0;
1951 if (tty->flags & (1 << TTY_IO_ERROR)) 1825 if (tty->flags & (1 << TTY_IO_ERROR))
1952 return(-EIO); 1826 return -EIO;
1953 1827
1954 if (set & TIOCM_RTS) 1828 if (set & TIOCM_RTS)
1955 rts = 1; 1829 rts = 1;
@@ -1968,32 +1842,25 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1968 1842
1969static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1843static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
1970{ 1844{
1971 stliport_t *portp; 1845 stliport_t *portp;
1972 stlibrd_t *brdp; 1846 stlibrd_t *brdp;
1973 unsigned int ival; 1847 unsigned int ival;
1974 int rc; 1848 int rc;
1975 void __user *argp = (void __user *)arg; 1849 void __user *argp = (void __user *)arg;
1976 1850
1977#ifdef DEBUG
1978 printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
1979 (int) tty, (int) file, cmd, (int) arg);
1980#endif
1981
1982 if (tty == (struct tty_struct *) NULL)
1983 return(-ENODEV);
1984 portp = tty->driver_data; 1851 portp = tty->driver_data;
1985 if (portp == (stliport_t *) NULL) 1852 if (portp == NULL)
1986 return(-ENODEV); 1853 return -ENODEV;
1987 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1854 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1988 return(0); 1855 return 0;
1989 brdp = stli_brds[portp->brdnr]; 1856 brdp = stli_brds[portp->brdnr];
1990 if (brdp == (stlibrd_t *) NULL) 1857 if (brdp == NULL)
1991 return(0); 1858 return 0;
1992 1859
1993 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1860 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
1994 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { 1861 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) {
1995 if (tty->flags & (1 << TTY_IO_ERROR)) 1862 if (tty->flags & (1 << TTY_IO_ERROR))
1996 return(-EIO); 1863 return -EIO;
1997 } 1864 }
1998 1865
1999 rc = 0; 1866 rc = 0;
@@ -2040,7 +1907,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2040 break; 1907 break;
2041 } 1908 }
2042 1909
2043 return(rc); 1910 return rc;
2044} 1911}
2045 1912
2046/*****************************************************************************/ 1913/*****************************************************************************/
@@ -2052,24 +1919,20 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2052 1919
2053static void stli_settermios(struct tty_struct *tty, struct termios *old) 1920static void stli_settermios(struct tty_struct *tty, struct termios *old)
2054{ 1921{
2055 stliport_t *portp; 1922 stliport_t *portp;
2056 stlibrd_t *brdp; 1923 stlibrd_t *brdp;
2057 struct termios *tiosp; 1924 struct termios *tiosp;
2058 asyport_t aport; 1925 asyport_t aport;
2059
2060#ifdef DEBUG
2061 printk("stli_settermios(tty=%x,old=%x)\n", (int) tty, (int) old);
2062#endif
2063 1926
2064 if (tty == (struct tty_struct *) NULL) 1927 if (tty == NULL)
2065 return; 1928 return;
2066 portp = tty->driver_data; 1929 portp = tty->driver_data;
2067 if (portp == (stliport_t *) NULL) 1930 if (portp == NULL)
2068 return; 1931 return;
2069 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1932 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2070 return; 1933 return;
2071 brdp = stli_brds[portp->brdnr]; 1934 brdp = stli_brds[portp->brdnr];
2072 if (brdp == (stlibrd_t *) NULL) 1935 if (brdp == NULL)
2073 return; 1936 return;
2074 1937
2075 tiosp = tty->termios; 1938 tiosp = tty->termios;
@@ -2102,18 +1965,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
2102 1965
2103static void stli_throttle(struct tty_struct *tty) 1966static void stli_throttle(struct tty_struct *tty)
2104{ 1967{
2105 stliport_t *portp; 1968 stliport_t *portp = tty->driver_data;
2106 1969 if (portp == NULL)
2107#ifdef DEBUG
2108 printk("stli_throttle(tty=%x)\n", (int) tty);
2109#endif
2110
2111 if (tty == (struct tty_struct *) NULL)
2112 return; 1970 return;
2113 portp = tty->driver_data;
2114 if (portp == (stliport_t *) NULL)
2115 return;
2116
2117 set_bit(ST_RXSTOP, &portp->state); 1971 set_bit(ST_RXSTOP, &portp->state);
2118} 1972}
2119 1973
@@ -2127,88 +1981,30 @@ static void stli_throttle(struct tty_struct *tty)
2127 1981
2128static void stli_unthrottle(struct tty_struct *tty) 1982static void stli_unthrottle(struct tty_struct *tty)
2129{ 1983{
2130 stliport_t *portp; 1984 stliport_t *portp = tty->driver_data;
2131 1985 if (portp == NULL)
2132#ifdef DEBUG
2133 printk("stli_unthrottle(tty=%x)\n", (int) tty);
2134#endif
2135
2136 if (tty == (struct tty_struct *) NULL)
2137 return;
2138 portp = tty->driver_data;
2139 if (portp == (stliport_t *) NULL)
2140 return; 1986 return;
2141
2142 clear_bit(ST_RXSTOP, &portp->state); 1987 clear_bit(ST_RXSTOP, &portp->state);
2143} 1988}
2144 1989
2145/*****************************************************************************/ 1990/*****************************************************************************/
2146 1991
2147/* 1992/*
2148 * Stop the transmitter. Basically to do this we will just turn TX 1993 * Stop the transmitter.
2149 * interrupts off.
2150 */ 1994 */
2151 1995
2152static void stli_stop(struct tty_struct *tty) 1996static void stli_stop(struct tty_struct *tty)
2153{ 1997{
2154 stlibrd_t *brdp;
2155 stliport_t *portp;
2156 asyctrl_t actrl;
2157
2158#ifdef DEBUG
2159 printk("stli_stop(tty=%x)\n", (int) tty);
2160#endif
2161
2162 if (tty == (struct tty_struct *) NULL)
2163 return;
2164 portp = tty->driver_data;
2165 if (portp == (stliport_t *) NULL)
2166 return;
2167 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2168 return;
2169 brdp = stli_brds[portp->brdnr];
2170 if (brdp == (stlibrd_t *) NULL)
2171 return;
2172
2173 memset(&actrl, 0, sizeof(asyctrl_t));
2174 actrl.txctrl = CT_STOPFLOW;
2175#if 0
2176 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2177#endif
2178} 1998}
2179 1999
2180/*****************************************************************************/ 2000/*****************************************************************************/
2181 2001
2182/* 2002/*
2183 * Start the transmitter again. Just turn TX interrupts back on. 2003 * Start the transmitter again.
2184 */ 2004 */
2185 2005
2186static void stli_start(struct tty_struct *tty) 2006static void stli_start(struct tty_struct *tty)
2187{ 2007{
2188 stliport_t *portp;
2189 stlibrd_t *brdp;
2190 asyctrl_t actrl;
2191
2192#ifdef DEBUG
2193 printk("stli_start(tty=%x)\n", (int) tty);
2194#endif
2195
2196 if (tty == (struct tty_struct *) NULL)
2197 return;
2198 portp = tty->driver_data;
2199 if (portp == (stliport_t *) NULL)
2200 return;
2201 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2202 return;
2203 brdp = stli_brds[portp->brdnr];
2204 if (brdp == (stlibrd_t *) NULL)
2205 return;
2206
2207 memset(&actrl, 0, sizeof(asyctrl_t));
2208 actrl.txctrl = CT_STARTFLOW;
2209#if 0
2210 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2211#endif
2212} 2008}
2213 2009
2214/*****************************************************************************/ 2010/*****************************************************************************/
@@ -2224,22 +2020,9 @@ static void stli_start(struct tty_struct *tty)
2224 2020
2225static void stli_dohangup(void *arg) 2021static void stli_dohangup(void *arg)
2226{ 2022{
2227 stliport_t *portp; 2023 stliport_t *portp = (stliport_t *) arg;
2228 2024 if (portp->tty != NULL) {
2229#ifdef DEBUG 2025 tty_hangup(portp->tty);
2230 printk(KERN_DEBUG "stli_dohangup(portp=%x)\n", (int) arg);
2231#endif
2232
2233 /*
2234 * FIXME: There's a module removal race here: tty_hangup
2235 * calls schedule_work which will call into this
2236 * driver later.
2237 */
2238 portp = (stliport_t *) arg;
2239 if (portp != (stliport_t *) NULL) {
2240 if (portp->tty != (struct tty_struct *) NULL) {
2241 tty_hangup(portp->tty);
2242 }
2243 } 2026 }
2244} 2027}
2245 2028
@@ -2254,31 +2037,25 @@ static void stli_dohangup(void *arg)
2254 2037
2255static void stli_hangup(struct tty_struct *tty) 2038static void stli_hangup(struct tty_struct *tty)
2256{ 2039{
2257 stliport_t *portp; 2040 stliport_t *portp;
2258 stlibrd_t *brdp; 2041 stlibrd_t *brdp;
2259 unsigned long flags; 2042 unsigned long flags;
2260
2261#ifdef DEBUG
2262 printk(KERN_DEBUG "stli_hangup(tty=%x)\n", (int) tty);
2263#endif
2264 2043
2265 if (tty == (struct tty_struct *) NULL)
2266 return;
2267 portp = tty->driver_data; 2044 portp = tty->driver_data;
2268 if (portp == (stliport_t *) NULL) 2045 if (portp == NULL)
2269 return; 2046 return;
2270 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2047 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2271 return; 2048 return;
2272 brdp = stli_brds[portp->brdnr]; 2049 brdp = stli_brds[portp->brdnr];
2273 if (brdp == (stlibrd_t *) NULL) 2050 if (brdp == NULL)
2274 return; 2051 return;
2275 2052
2276 portp->flags &= ~ASYNC_INITIALIZED; 2053 portp->flags &= ~ASYNC_INITIALIZED;
2277 2054
2278 save_flags(flags); 2055 if (!test_bit(ST_CLOSING, &portp->state))
2279 cli();
2280 if (! test_bit(ST_CLOSING, &portp->state))
2281 stli_rawclose(brdp, portp, 0, 0); 2056 stli_rawclose(brdp, portp, 0, 0);
2057
2058 spin_lock_irqsave(&stli_lock, flags);
2282 if (tty->termios->c_cflag & HUPCL) { 2059 if (tty->termios->c_cflag & HUPCL) {
2283 stli_mkasysigs(&portp->asig, 0, 0); 2060 stli_mkasysigs(&portp->asig, 0, 0);
2284 if (test_bit(ST_CMDING, &portp->state)) { 2061 if (test_bit(ST_CMDING, &portp->state)) {
@@ -2290,14 +2067,15 @@ static void stli_hangup(struct tty_struct *tty)
2290 &portp->asig, sizeof(asysigs_t), 0); 2067 &portp->asig, sizeof(asysigs_t), 0);
2291 } 2068 }
2292 } 2069 }
2293 restore_flags(flags);
2294 2070
2295 clear_bit(ST_TXBUSY, &portp->state); 2071 clear_bit(ST_TXBUSY, &portp->state);
2296 clear_bit(ST_RXSTOP, &portp->state); 2072 clear_bit(ST_RXSTOP, &portp->state);
2297 set_bit(TTY_IO_ERROR, &tty->flags); 2073 set_bit(TTY_IO_ERROR, &tty->flags);
2298 portp->tty = (struct tty_struct *) NULL; 2074 portp->tty = NULL;
2299 portp->flags &= ~ASYNC_NORMAL_ACTIVE; 2075 portp->flags &= ~ASYNC_NORMAL_ACTIVE;
2300 portp->refcount = 0; 2076 portp->refcount = 0;
2077 spin_unlock_irqrestore(&stli_lock, flags);
2078
2301 wake_up_interruptible(&portp->open_wait); 2079 wake_up_interruptible(&portp->open_wait);
2302} 2080}
2303 2081
@@ -2312,29 +2090,22 @@ static void stli_hangup(struct tty_struct *tty)
2312 2090
2313static void stli_flushbuffer(struct tty_struct *tty) 2091static void stli_flushbuffer(struct tty_struct *tty)
2314{ 2092{
2315 stliport_t *portp; 2093 stliport_t *portp;
2316 stlibrd_t *brdp; 2094 stlibrd_t *brdp;
2317 unsigned long ftype, flags; 2095 unsigned long ftype, flags;
2318
2319#ifdef DEBUG
2320 printk(KERN_DEBUG "stli_flushbuffer(tty=%x)\n", (int) tty);
2321#endif
2322 2096
2323 if (tty == (struct tty_struct *) NULL)
2324 return;
2325 portp = tty->driver_data; 2097 portp = tty->driver_data;
2326 if (portp == (stliport_t *) NULL) 2098 if (portp == NULL)
2327 return; 2099 return;
2328 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2100 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2329 return; 2101 return;
2330 brdp = stli_brds[portp->brdnr]; 2102 brdp = stli_brds[portp->brdnr];
2331 if (brdp == (stlibrd_t *) NULL) 2103 if (brdp == NULL)
2332 return; 2104 return;
2333 2105
2334 save_flags(flags); 2106 spin_lock_irqsave(&brd_lock, flags);
2335 cli();
2336 if (tty == stli_txcooktty) { 2107 if (tty == stli_txcooktty) {
2337 stli_txcooktty = (struct tty_struct *) NULL; 2108 stli_txcooktty = NULL;
2338 stli_txcooksize = 0; 2109 stli_txcooksize = 0;
2339 stli_txcookrealsize = 0; 2110 stli_txcookrealsize = 0;
2340 } 2111 }
@@ -2346,15 +2117,10 @@ static void stli_flushbuffer(struct tty_struct *tty)
2346 ftype |= FLUSHRX; 2117 ftype |= FLUSHRX;
2347 clear_bit(ST_DOFLUSHRX, &portp->state); 2118 clear_bit(ST_DOFLUSHRX, &portp->state);
2348 } 2119 }
2349 stli_sendcmd(brdp, portp, A_FLUSH, &ftype, 2120 __stli_sendcmd(brdp, portp, A_FLUSH, &ftype, sizeof(u32), 0);
2350 sizeof(unsigned long), 0);
2351 } 2121 }
2352 restore_flags(flags); 2122 spin_unlock_irqrestore(&brd_lock, flags);
2353 2123 tty_wakeup(tty);
2354 wake_up_interruptible(&tty->write_wait);
2355 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
2356 tty->ldisc.write_wakeup)
2357 (tty->ldisc.write_wakeup)(tty);
2358} 2124}
2359 2125
2360/*****************************************************************************/ 2126/*****************************************************************************/
@@ -2364,55 +2130,31 @@ static void stli_breakctl(struct tty_struct *tty, int state)
2364 stlibrd_t *brdp; 2130 stlibrd_t *brdp;
2365 stliport_t *portp; 2131 stliport_t *portp;
2366 long arg; 2132 long arg;
2367 /* long savestate, savetime; */
2368 2133
2369#ifdef DEBUG
2370 printk(KERN_DEBUG "stli_breakctl(tty=%x,state=%d)\n", (int) tty, state);
2371#endif
2372
2373 if (tty == (struct tty_struct *) NULL)
2374 return;
2375 portp = tty->driver_data; 2134 portp = tty->driver_data;
2376 if (portp == (stliport_t *) NULL) 2135 if (portp == NULL)
2377 return; 2136 return;
2378 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2137 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2379 return; 2138 return;
2380 brdp = stli_brds[portp->brdnr]; 2139 brdp = stli_brds[portp->brdnr];
2381 if (brdp == (stlibrd_t *) NULL) 2140 if (brdp == NULL)
2382 return; 2141 return;
2383 2142
2384/*
2385 * Due to a bug in the tty send_break() code we need to preserve
2386 * the current process state and timeout...
2387 savetime = current->timeout;
2388 savestate = current->state;
2389 */
2390
2391 arg = (state == -1) ? BREAKON : BREAKOFF; 2143 arg = (state == -1) ? BREAKON : BREAKOFF;
2392 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); 2144 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0);
2393
2394/*
2395 *
2396 current->timeout = savetime;
2397 current->state = savestate;
2398 */
2399} 2145}
2400 2146
2401/*****************************************************************************/ 2147/*****************************************************************************/
2402 2148
2403static void stli_waituntilsent(struct tty_struct *tty, int timeout) 2149static void stli_waituntilsent(struct tty_struct *tty, int timeout)
2404{ 2150{
2405 stliport_t *portp; 2151 stliport_t *portp;
2406 unsigned long tend; 2152 unsigned long tend;
2407 2153
2408#ifdef DEBUG 2154 if (tty == NULL)
2409 printk(KERN_DEBUG "stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty, timeout);
2410#endif
2411
2412 if (tty == (struct tty_struct *) NULL)
2413 return; 2155 return;
2414 portp = tty->driver_data; 2156 portp = tty->driver_data;
2415 if (portp == (stliport_t *) NULL) 2157 if (portp == NULL)
2416 return; 2158 return;
2417 2159
2418 if (timeout == 0) 2160 if (timeout == 0)
@@ -2436,19 +2178,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2436 stliport_t *portp; 2178 stliport_t *portp;
2437 asyctrl_t actrl; 2179 asyctrl_t actrl;
2438 2180
2439#ifdef DEBUG
2440 printk(KERN_DEBUG "stli_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch);
2441#endif
2442
2443 if (tty == (struct tty_struct *) NULL)
2444 return;
2445 portp = tty->driver_data; 2181 portp = tty->driver_data;
2446 if (portp == (stliport_t *) NULL) 2182 if (portp == NULL)
2447 return; 2183 return;
2448 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2184 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2449 return; 2185 return;
2450 brdp = stli_brds[portp->brdnr]; 2186 brdp = stli_brds[portp->brdnr];
2451 if (brdp == (stlibrd_t *) NULL) 2187 if (brdp == NULL)
2452 return; 2188 return;
2453 2189
2454 memset(&actrl, 0, sizeof(asyctrl_t)); 2190 memset(&actrl, 0, sizeof(asyctrl_t));
@@ -2460,7 +2196,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2460 actrl.txctrl = CT_SENDCHR; 2196 actrl.txctrl = CT_SENDCHR;
2461 actrl.tximdch = ch; 2197 actrl.tximdch = ch;
2462 } 2198 }
2463
2464 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); 2199 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2465} 2200}
2466 2201
@@ -2476,17 +2211,17 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2476 2211
2477static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos) 2212static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos)
2478{ 2213{
2479 char *sp, *uart; 2214 char *sp, *uart;
2480 int rc, cnt; 2215 int rc, cnt;
2481 2216
2482 rc = stli_portcmdstats(portp); 2217 rc = stli_portcmdstats(portp);
2483 2218
2484 uart = "UNKNOWN"; 2219 uart = "UNKNOWN";
2485 if (brdp->state & BST_STARTED) { 2220 if (brdp->state & BST_STARTED) {
2486 switch (stli_comstats.hwid) { 2221 switch (stli_comstats.hwid) {
2487 case 0: uart = "2681"; break; 2222 case 0: uart = "2681"; break;
2488 case 1: uart = "SC26198"; break; 2223 case 1: uart = "SC26198"; break;
2489 default: uart = "CD1400"; break; 2224 default:uart = "CD1400"; break;
2490 } 2225 }
2491 } 2226 }
2492 2227
@@ -2537,17 +2272,11 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p
2537 2272
2538static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 2273static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
2539{ 2274{
2540 stlibrd_t *brdp; 2275 stlibrd_t *brdp;
2541 stliport_t *portp; 2276 stliport_t *portp;
2542 int brdnr, portnr, totalport; 2277 int brdnr, portnr, totalport;
2543 int curoff, maxoff; 2278 int curoff, maxoff;
2544 char *pos; 2279 char *pos;
2545
2546#ifdef DEBUG
2547 printk(KERN_DEBUG "stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
2548 "data=%x\n", (int) page, (int) start, (int) off, count,
2549 (int) eof, (int) data);
2550#endif
2551 2280
2552 pos = page; 2281 pos = page;
2553 totalport = 0; 2282 totalport = 0;
@@ -2568,7 +2297,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2568 */ 2297 */
2569 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2298 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
2570 brdp = stli_brds[brdnr]; 2299 brdp = stli_brds[brdnr];
2571 if (brdp == (stlibrd_t *) NULL) 2300 if (brdp == NULL)
2572 continue; 2301 continue;
2573 if (brdp->state == 0) 2302 if (brdp->state == 0)
2574 continue; 2303 continue;
@@ -2583,7 +2312,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2583 for (portnr = 0; (portnr < brdp->nrports); portnr++, 2312 for (portnr = 0; (portnr < brdp->nrports); portnr++,
2584 totalport++) { 2313 totalport++) {
2585 portp = brdp->ports[portnr]; 2314 portp = brdp->ports[portnr];
2586 if (portp == (stliport_t *) NULL) 2315 if (portp == NULL)
2587 continue; 2316 continue;
2588 if (off >= (curoff += MAXLINE)) 2317 if (off >= (curoff += MAXLINE))
2589 continue; 2318 continue;
@@ -2610,49 +2339,54 @@ stli_readdone:
2610 * a poll routine that does not have user context. Therefore you cannot 2339 * a poll routine that does not have user context. Therefore you cannot
2611 * copy back directly into user space, or to the kernel stack of a 2340 * copy back directly into user space, or to the kernel stack of a
2612 * process. This routine does not sleep, so can be called from anywhere. 2341 * process. This routine does not sleep, so can be called from anywhere.
2342 *
2343 * The caller must hold the brd_lock (see also stli_sendcmd the usual
2344 * entry point)
2613 */ 2345 */
2614 2346
2615static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 2347static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2616{ 2348{
2617 volatile cdkhdr_t *hdrp; 2349 cdkhdr_t __iomem *hdrp;
2618 volatile cdkctrl_t *cp; 2350 cdkctrl_t __iomem *cp;
2619 volatile unsigned char *bits; 2351 unsigned char __iomem *bits;
2620 unsigned long flags; 2352 unsigned long flags;
2621 2353
2622#ifdef DEBUG 2354 spin_lock_irqsave(&brd_lock, flags);
2623 printk(KERN_DEBUG "stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
2624 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
2625 (int) arg, size, copyback);
2626#endif
2627
2628 save_flags(flags);
2629 cli();
2630 2355
2631 if (test_bit(ST_CMDING, &portp->state)) { 2356 if (test_bit(ST_CMDING, &portp->state)) {
2632 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", 2357 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
2633 (int) cmd); 2358 (int) cmd);
2634 restore_flags(flags); 2359 spin_unlock_irqrestore(&brd_lock, flags);
2635 return; 2360 return;
2636 } 2361 }
2637 2362
2638 EBRDENABLE(brdp); 2363 EBRDENABLE(brdp);
2639 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 2364 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
2640 if (size > 0) { 2365 if (size > 0) {
2641 memcpy((void *) &(cp->args[0]), arg, size); 2366 memcpy_toio((void __iomem *) &(cp->args[0]), arg, size);
2642 if (copyback) { 2367 if (copyback) {
2643 portp->argp = arg; 2368 portp->argp = arg;
2644 portp->argsize = size; 2369 portp->argsize = size;
2645 } 2370 }
2646 } 2371 }
2647 cp->status = 0; 2372 writel(0, &cp->status);
2648 cp->cmd = cmd; 2373 writel(cmd, &cp->cmd);
2649 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2374 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2650 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 2375 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
2651 portp->portidx; 2376 portp->portidx;
2652 *bits |= portp->portbit; 2377 writeb(readb(bits) | portp->portbit, bits);
2653 set_bit(ST_CMDING, &portp->state); 2378 set_bit(ST_CMDING, &portp->state);
2654 EBRDDISABLE(brdp); 2379 EBRDDISABLE(brdp);
2655 restore_flags(flags); 2380 spin_unlock_irqrestore(&brd_lock, flags);
2381}
2382
2383static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2384{
2385 unsigned long flags;
2386
2387 spin_lock_irqsave(&brd_lock, flags);
2388 __stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
2389 spin_unlock_irqrestore(&brd_lock, flags);
2656} 2390}
2657 2391
2658/*****************************************************************************/ 2392/*****************************************************************************/
@@ -2667,28 +2401,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd,
2667 2401
2668static void stli_read(stlibrd_t *brdp, stliport_t *portp) 2402static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2669{ 2403{
2670 volatile cdkasyrq_t *rp; 2404 cdkasyrq_t __iomem *rp;
2671 volatile char *shbuf; 2405 char __iomem *shbuf;
2672 struct tty_struct *tty; 2406 struct tty_struct *tty;
2673 unsigned int head, tail, size; 2407 unsigned int head, tail, size;
2674 unsigned int len, stlen; 2408 unsigned int len, stlen;
2675
2676#ifdef DEBUG
2677 printk(KERN_DEBUG "stli_read(brdp=%x,portp=%d)\n",
2678 (int) brdp, (int) portp);
2679#endif
2680 2409
2681 if (test_bit(ST_RXSTOP, &portp->state)) 2410 if (test_bit(ST_RXSTOP, &portp->state))
2682 return; 2411 return;
2683 tty = portp->tty; 2412 tty = portp->tty;
2684 if (tty == (struct tty_struct *) NULL) 2413 if (tty == NULL)
2685 return; 2414 return;
2686 2415
2687 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2416 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2688 head = (unsigned int) rp->head; 2417 head = (unsigned int) readw(&rp->head);
2689 if (head != ((unsigned int) rp->head)) 2418 if (head != ((unsigned int) readw(&rp->head)))
2690 head = (unsigned int) rp->head; 2419 head = (unsigned int) readw(&rp->head);
2691 tail = (unsigned int) rp->tail; 2420 tail = (unsigned int) readw(&rp->tail);
2692 size = portp->rxsize; 2421 size = portp->rxsize;
2693 if (head >= tail) { 2422 if (head >= tail) {
2694 len = head - tail; 2423 len = head - tail;
@@ -2699,12 +2428,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2699 } 2428 }
2700 2429
2701 len = tty_buffer_request_room(tty, len); 2430 len = tty_buffer_request_room(tty, len);
2702 /* FIXME : iomap ? */ 2431
2703 shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); 2432 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->rxoffset);
2704 2433
2705 while (len > 0) { 2434 while (len > 0) {
2435 unsigned char *cptr;
2436
2706 stlen = MIN(len, stlen); 2437 stlen = MIN(len, stlen);
2707 tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); 2438 tty_prepare_flip_string(tty, &cptr, stlen);
2439 memcpy_fromio(cptr, shbuf + tail, stlen);
2708 len -= stlen; 2440 len -= stlen;
2709 tail += stlen; 2441 tail += stlen;
2710 if (tail >= size) { 2442 if (tail >= size) {
@@ -2712,8 +2444,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2712 stlen = head; 2444 stlen = head;
2713 } 2445 }
2714 } 2446 }
2715 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2447 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2716 rp->tail = tail; 2448 writew(tail, &rp->tail);
2717 2449
2718 if (head != tail) 2450 if (head != tail)
2719 set_bit(ST_RXING, &portp->state); 2451 set_bit(ST_RXING, &portp->state);
@@ -2729,9 +2461,9 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2729 * difficult to deal with them here. 2461 * difficult to deal with them here.
2730 */ 2462 */
2731 2463
2732static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) 2464static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
2733{ 2465{
2734 int cmd; 2466 int cmd;
2735 2467
2736 if (test_bit(ST_DOSIGS, &portp->state)) { 2468 if (test_bit(ST_DOSIGS, &portp->state)) {
2737 if (test_bit(ST_DOFLUSHTX, &portp->state) && 2469 if (test_bit(ST_DOFLUSHTX, &portp->state) &&
@@ -2746,10 +2478,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2746 clear_bit(ST_DOFLUSHTX, &portp->state); 2478 clear_bit(ST_DOFLUSHTX, &portp->state);
2747 clear_bit(ST_DOFLUSHRX, &portp->state); 2479 clear_bit(ST_DOFLUSHRX, &portp->state);
2748 clear_bit(ST_DOSIGS, &portp->state); 2480 clear_bit(ST_DOSIGS, &portp->state);
2749 memcpy((void *) &(cp->args[0]), (void *) &portp->asig, 2481 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &portp->asig,
2750 sizeof(asysigs_t)); 2482 sizeof(asysigs_t));
2751 cp->status = 0; 2483 writel(0, &cp->status);
2752 cp->cmd = cmd; 2484 writel(cmd, &cp->cmd);
2753 set_bit(ST_CMDING, &portp->state); 2485 set_bit(ST_CMDING, &portp->state);
2754 } else if (test_bit(ST_DOFLUSHTX, &portp->state) || 2486 } else if (test_bit(ST_DOFLUSHTX, &portp->state) ||
2755 test_bit(ST_DOFLUSHRX, &portp->state)) { 2487 test_bit(ST_DOFLUSHRX, &portp->state)) {
@@ -2757,9 +2489,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2757 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0); 2489 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0);
2758 clear_bit(ST_DOFLUSHTX, &portp->state); 2490 clear_bit(ST_DOFLUSHTX, &portp->state);
2759 clear_bit(ST_DOFLUSHRX, &portp->state); 2491 clear_bit(ST_DOFLUSHRX, &portp->state);
2760 memcpy((void *) &(cp->args[0]), (void *) &cmd, sizeof(int)); 2492 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &cmd, sizeof(int));
2761 cp->status = 0; 2493 writel(0, &cp->status);
2762 cp->cmd = A_FLUSH; 2494 writel(A_FLUSH, &cp->cmd);
2763 set_bit(ST_CMDING, &portp->state); 2495 set_bit(ST_CMDING, &portp->state);
2764 } 2496 }
2765} 2497}
@@ -2779,30 +2511,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2779 2511
2780static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) 2512static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2781{ 2513{
2782 volatile cdkasy_t *ap; 2514 cdkasy_t __iomem *ap;
2783 volatile cdkctrl_t *cp; 2515 cdkctrl_t __iomem *cp;
2784 struct tty_struct *tty; 2516 struct tty_struct *tty;
2785 asynotify_t nt; 2517 asynotify_t nt;
2786 unsigned long oldsigs; 2518 unsigned long oldsigs;
2787 int rc, donerx; 2519 int rc, donerx;
2788 2520
2789#ifdef DEBUG 2521 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
2790 printk(KERN_DEBUG "stli_hostcmd(brdp=%x,channr=%d)\n",
2791 (int) brdp, channr);
2792#endif
2793
2794 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
2795 cp = &ap->ctrl; 2522 cp = &ap->ctrl;
2796 2523
2797/* 2524/*
2798 * Check if we are waiting for an open completion message. 2525 * Check if we are waiting for an open completion message.
2799 */ 2526 */
2800 if (test_bit(ST_OPENING, &portp->state)) { 2527 if (test_bit(ST_OPENING, &portp->state)) {
2801 rc = (int) cp->openarg; 2528 rc = readl(&cp->openarg);
2802 if ((cp->open == 0) && (rc != 0)) { 2529 if (readb(&cp->open) == 0 && rc != 0) {
2803 if (rc > 0) 2530 if (rc > 0)
2804 rc--; 2531 rc--;
2805 cp->openarg = 0; 2532 writel(0, &cp->openarg);
2806 portp->rc = rc; 2533 portp->rc = rc;
2807 clear_bit(ST_OPENING, &portp->state); 2534 clear_bit(ST_OPENING, &portp->state);
2808 wake_up_interruptible(&portp->raw_wait); 2535 wake_up_interruptible(&portp->raw_wait);
@@ -2813,11 +2540,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2813 * Check if we are waiting for a close completion message. 2540 * Check if we are waiting for a close completion message.
2814 */ 2541 */
2815 if (test_bit(ST_CLOSING, &portp->state)) { 2542 if (test_bit(ST_CLOSING, &portp->state)) {
2816 rc = (int) cp->closearg; 2543 rc = (int) readl(&cp->closearg);
2817 if ((cp->close == 0) && (rc != 0)) { 2544 if (readb(&cp->close) == 0 && rc != 0) {
2818 if (rc > 0) 2545 if (rc > 0)
2819 rc--; 2546 rc--;
2820 cp->closearg = 0; 2547 writel(0, &cp->closearg);
2821 portp->rc = rc; 2548 portp->rc = rc;
2822 clear_bit(ST_CLOSING, &portp->state); 2549 clear_bit(ST_CLOSING, &portp->state);
2823 wake_up_interruptible(&portp->raw_wait); 2550 wake_up_interruptible(&portp->raw_wait);
@@ -2829,16 +2556,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2829 * need to copy out the command results associated with this command. 2556 * need to copy out the command results associated with this command.
2830 */ 2557 */
2831 if (test_bit(ST_CMDING, &portp->state)) { 2558 if (test_bit(ST_CMDING, &portp->state)) {
2832 rc = cp->status; 2559 rc = readl(&cp->status);
2833 if ((cp->cmd == 0) && (rc != 0)) { 2560 if (readl(&cp->cmd) == 0 && rc != 0) {
2834 if (rc > 0) 2561 if (rc > 0)
2835 rc--; 2562 rc--;
2836 if (portp->argp != (void *) NULL) { 2563 if (portp->argp != NULL) {
2837 memcpy(portp->argp, (void *) &(cp->args[0]), 2564 memcpy_fromio(portp->argp, (void __iomem *) &(cp->args[0]),
2838 portp->argsize); 2565 portp->argsize);
2839 portp->argp = (void *) NULL; 2566 portp->argp = NULL;
2840 } 2567 }
2841 cp->status = 0; 2568 writel(0, &cp->status);
2842 portp->rc = rc; 2569 portp->rc = rc;
2843 clear_bit(ST_CMDING, &portp->state); 2570 clear_bit(ST_CMDING, &portp->state);
2844 stli_dodelaycmd(portp, cp); 2571 stli_dodelaycmd(portp, cp);
@@ -2877,18 +2604,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2877 if (nt.data & DT_TXEMPTY) 2604 if (nt.data & DT_TXEMPTY)
2878 clear_bit(ST_TXBUSY, &portp->state); 2605 clear_bit(ST_TXBUSY, &portp->state);
2879 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) { 2606 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) {
2880 if (tty != (struct tty_struct *) NULL) { 2607 if (tty != NULL) {
2881 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 2608 tty_wakeup(tty);
2882 tty->ldisc.write_wakeup) { 2609 EBRDENABLE(brdp);
2883 (tty->ldisc.write_wakeup)(tty);
2884 EBRDENABLE(brdp);
2885 }
2886 wake_up_interruptible(&tty->write_wait); 2610 wake_up_interruptible(&tty->write_wait);
2887 } 2611 }
2888 } 2612 }
2889 2613
2890 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { 2614 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) {
2891 if (tty != (struct tty_struct *) NULL) { 2615 if (tty != NULL) {
2892 tty_insert_flip_char(tty, 0, TTY_BREAK); 2616 tty_insert_flip_char(tty, 0, TTY_BREAK);
2893 if (portp->flags & ASYNC_SAK) { 2617 if (portp->flags & ASYNC_SAK) {
2894 do_SAK(tty); 2618 do_SAK(tty);
@@ -2932,14 +2656,14 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2932 * at the cdk header structure. 2656 * at the cdk header structure.
2933 */ 2657 */
2934 2658
2935static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) 2659static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
2936{ 2660{
2937 stliport_t *portp; 2661 stliport_t *portp;
2938 unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; 2662 unsigned char hostbits[(STL_MAXCHANS / 8) + 1];
2939 unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; 2663 unsigned char slavebits[(STL_MAXCHANS / 8) + 1];
2940 unsigned char *slavep; 2664 unsigned char __iomem *slavep;
2941 int bitpos, bitat, bitsize; 2665 int bitpos, bitat, bitsize;
2942 int channr, nrdevs, slavebitchange; 2666 int channr, nrdevs, slavebitchange;
2943 2667
2944 bitsize = brdp->bitsize; 2668 bitsize = brdp->bitsize;
2945 nrdevs = brdp->nrdevs; 2669 nrdevs = brdp->nrdevs;
@@ -2951,7 +2675,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2951 * 8 service bits at a time in the inner loop, so we can bypass 2675 * 8 service bits at a time in the inner loop, so we can bypass
2952 * the lot if none of them want service. 2676 * the lot if none of them want service.
2953 */ 2677 */
2954 memcpy(&hostbits[0], (((unsigned char *) hdrp) + brdp->hostoffset), 2678 memcpy_fromio(&hostbits[0], (((unsigned char __iomem *) hdrp) + brdp->hostoffset),
2955 bitsize); 2679 bitsize);
2956 2680
2957 memset(&slavebits[0], 0, bitsize); 2681 memset(&slavebits[0], 0, bitsize);
@@ -2978,11 +2702,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2978 * service may initiate more slave requests. 2702 * service may initiate more slave requests.
2979 */ 2703 */
2980 if (slavebitchange) { 2704 if (slavebitchange) {
2981 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2705 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2982 slavep = ((unsigned char *) hdrp) + brdp->slaveoffset; 2706 slavep = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset;
2983 for (bitpos = 0; (bitpos < bitsize); bitpos++) { 2707 for (bitpos = 0; (bitpos < bitsize); bitpos++) {
2984 if (slavebits[bitpos]) 2708 if (readb(slavebits + bitpos))
2985 slavep[bitpos] &= ~slavebits[bitpos]; 2709 writeb(readb(slavep + bitpos) & ~slavebits[bitpos], slavebits + bitpos);
2986 } 2710 }
2987 } 2711 }
2988} 2712}
@@ -3000,9 +2724,9 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
3000 2724
3001static void stli_poll(unsigned long arg) 2725static void stli_poll(unsigned long arg)
3002{ 2726{
3003 volatile cdkhdr_t *hdrp; 2727 cdkhdr_t __iomem *hdrp;
3004 stlibrd_t *brdp; 2728 stlibrd_t *brdp;
3005 int brdnr; 2729 int brdnr;
3006 2730
3007 stli_timerlist.expires = STLI_TIMEOUT; 2731 stli_timerlist.expires = STLI_TIMEOUT;
3008 add_timer(&stli_timerlist); 2732 add_timer(&stli_timerlist);
@@ -3012,16 +2736,18 @@ static void stli_poll(unsigned long arg)
3012 */ 2736 */
3013 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2737 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
3014 brdp = stli_brds[brdnr]; 2738 brdp = stli_brds[brdnr];
3015 if (brdp == (stlibrd_t *) NULL) 2739 if (brdp == NULL)
3016 continue; 2740 continue;
3017 if ((brdp->state & BST_STARTED) == 0) 2741 if ((brdp->state & BST_STARTED) == 0)
3018 continue; 2742 continue;
3019 2743
2744 spin_lock(&brd_lock);
3020 EBRDENABLE(brdp); 2745 EBRDENABLE(brdp);
3021 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2746 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
3022 if (hdrp->hostreq) 2747 if (readb(&hdrp->hostreq))
3023 stli_brdpoll(brdp, hdrp); 2748 stli_brdpoll(brdp, hdrp);
3024 EBRDDISABLE(brdp); 2749 EBRDDISABLE(brdp);
2750 spin_unlock(&brd_lock);
3025 } 2751 }
3026} 2752}
3027 2753
@@ -3034,11 +2760,6 @@ static void stli_poll(unsigned long arg)
3034 2760
3035static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) 2761static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
3036{ 2762{
3037#ifdef DEBUG
3038 printk(KERN_DEBUG "stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n",
3039 (int) portp, (int) pp, (int) tiosp);
3040#endif
3041
3042 memset(pp, 0, sizeof(asyport_t)); 2763 memset(pp, 0, sizeof(asyport_t));
3043 2764
3044/* 2765/*
@@ -3157,11 +2878,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio
3157 2878
3158static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) 2879static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3159{ 2880{
3160#ifdef DEBUG
3161 printk(KERN_DEBUG "stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n",
3162 (int) sp, dtr, rts);
3163#endif
3164
3165 memset(sp, 0, sizeof(asysigs_t)); 2881 memset(sp, 0, sizeof(asysigs_t));
3166 if (dtr >= 0) { 2882 if (dtr >= 0) {
3167 sp->signal |= SG_DTR; 2883 sp->signal |= SG_DTR;
@@ -3182,13 +2898,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3182 2898
3183static long stli_mktiocm(unsigned long sigvalue) 2899static long stli_mktiocm(unsigned long sigvalue)
3184{ 2900{
3185 long tiocm; 2901 long tiocm = 0;
3186
3187#ifdef DEBUG
3188 printk(KERN_DEBUG "stli_mktiocm(sigvalue=%x)\n", (int) sigvalue);
3189#endif
3190
3191 tiocm = 0;
3192 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0); 2902 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0);
3193 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0); 2903 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0);
3194 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0); 2904 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0);
@@ -3210,10 +2920,6 @@ static int stli_initports(stlibrd_t *brdp)
3210 stliport_t *portp; 2920 stliport_t *portp;
3211 int i, panelnr, panelport; 2921 int i, panelnr, panelport;
3212 2922
3213#ifdef DEBUG
3214 printk(KERN_DEBUG "stli_initports(brdp=%x)\n", (int) brdp);
3215#endif
3216
3217 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { 2923 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) {
3218 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); 2924 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL);
3219 if (!portp) { 2925 if (!portp) {
@@ -3240,7 +2946,7 @@ static int stli_initports(stlibrd_t *brdp)
3240 brdp->ports[i] = portp; 2946 brdp->ports[i] = portp;
3241 } 2947 }
3242 2948
3243 return(0); 2949 return 0;
3244} 2950}
3245 2951
3246/*****************************************************************************/ 2952/*****************************************************************************/
@@ -3253,10 +2959,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3253{ 2959{
3254 unsigned long memconf; 2960 unsigned long memconf;
3255 2961
3256#ifdef DEBUG
3257 printk(KERN_DEBUG "stli_ecpinit(brdp=%d)\n", (int) brdp);
3258#endif
3259
3260 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 2962 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3261 udelay(10); 2963 udelay(10);
3262 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2964 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3270,9 +2972,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3270 2972
3271static void stli_ecpenable(stlibrd_t *brdp) 2973static void stli_ecpenable(stlibrd_t *brdp)
3272{ 2974{
3273#ifdef DEBUG
3274 printk(KERN_DEBUG "stli_ecpenable(brdp=%x)\n", (int) brdp);
3275#endif
3276 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); 2975 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR));
3277} 2976}
3278 2977
@@ -3280,9 +2979,6 @@ static void stli_ecpenable(stlibrd_t *brdp)
3280 2979
3281static void stli_ecpdisable(stlibrd_t *brdp) 2980static void stli_ecpdisable(stlibrd_t *brdp)
3282{ 2981{
3283#ifdef DEBUG
3284 printk(KERN_DEBUG "stli_ecpdisable(brdp=%x)\n", (int) brdp);
3285#endif
3286 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2982 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
3287} 2983}
3288 2984
@@ -3290,13 +2986,8 @@ static void stli_ecpdisable(stlibrd_t *brdp)
3290 2986
3291static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 2987static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3292{ 2988{
3293 void *ptr; 2989 void *ptr;
3294 unsigned char val; 2990 unsigned char val;
3295
3296#ifdef DEBUG
3297 printk(KERN_DEBUG "stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3298 (int) offset);
3299#endif
3300 2991
3301 if (offset > brdp->memsize) { 2992 if (offset > brdp->memsize) {
3302 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 2993 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3316,10 +3007,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3316 3007
3317static void stli_ecpreset(stlibrd_t *brdp) 3008static void stli_ecpreset(stlibrd_t *brdp)
3318{ 3009{
3319#ifdef DEBUG
3320 printk(KERN_DEBUG "stli_ecpreset(brdp=%x)\n", (int) brdp);
3321#endif
3322
3323 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 3010 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3324 udelay(10); 3011 udelay(10);
3325 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 3012 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3330,9 +3017,6 @@ static void stli_ecpreset(stlibrd_t *brdp)
3330 3017
3331static void stli_ecpintr(stlibrd_t *brdp) 3018static void stli_ecpintr(stlibrd_t *brdp)
3332{ 3019{
3333#ifdef DEBUG
3334 printk(KERN_DEBUG "stli_ecpintr(brdp=%x)\n", (int) brdp);
3335#endif
3336 outb(0x1, brdp->iobase); 3020 outb(0x1, brdp->iobase);
3337} 3021}
3338 3022
@@ -3346,10 +3030,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp)
3346{ 3030{
3347 unsigned long memconf; 3031 unsigned long memconf;
3348 3032
3349#ifdef DEBUG
3350 printk(KERN_DEBUG "stli_ecpeiinit(brdp=%x)\n", (int) brdp);
3351#endif
3352
3353 outb(0x1, (brdp->iobase + ECP_EIBRDENAB)); 3033 outb(0x1, (brdp->iobase + ECP_EIBRDENAB));
3354 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); 3034 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR));
3355 udelay(10); 3035 udelay(10);
@@ -3383,11 +3063,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line
3383 void *ptr; 3063 void *ptr;
3384 unsigned char val; 3064 unsigned char val;
3385 3065
3386#ifdef DEBUG
3387 printk(KERN_DEBUG "stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3388 (int) brdp, (int) offset, line);
3389#endif
3390
3391 if (offset > brdp->memsize) { 3066 if (offset > brdp->memsize) {
3392 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3067 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3393 "range at line=%d(%d), brd=%d\n", 3068 "range at line=%d(%d), brd=%d\n",
@@ -3437,8 +3112,8 @@ static void stli_ecpmcdisable(stlibrd_t *brdp)
3437 3112
3438static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3113static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3439{ 3114{
3440 void *ptr; 3115 void *ptr;
3441 unsigned char val; 3116 unsigned char val;
3442 3117
3443 if (offset > brdp->memsize) { 3118 if (offset > brdp->memsize) {
3444 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3119 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3472,10 +3147,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp)
3472 3147
3473static void stli_ecppciinit(stlibrd_t *brdp) 3148static void stli_ecppciinit(stlibrd_t *brdp)
3474{ 3149{
3475#ifdef DEBUG
3476 printk(KERN_DEBUG "stli_ecppciinit(brdp=%x)\n", (int) brdp);
3477#endif
3478
3479 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); 3150 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
3480 udelay(10); 3151 udelay(10);
3481 outb(0, (brdp->iobase + ECP_PCICONFR)); 3152 outb(0, (brdp->iobase + ECP_PCICONFR));
@@ -3489,11 +3160,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin
3489 void *ptr; 3160 void *ptr;
3490 unsigned char val; 3161 unsigned char val;
3491 3162
3492#ifdef DEBUG
3493 printk(KERN_DEBUG "stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3494 (int) brdp, (int) offset, line);
3495#endif
3496
3497 if (offset > brdp->memsize) { 3163 if (offset > brdp->memsize) {
3498 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3164 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3499 "range at line=%d(%d), board=%d\n", 3165 "range at line=%d(%d), board=%d\n",
@@ -3528,10 +3194,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3528{ 3194{
3529 unsigned long memconf; 3195 unsigned long memconf;
3530 3196
3531#ifdef DEBUG
3532 printk(KERN_DEBUG "stli_onbinit(brdp=%d)\n", (int) brdp);
3533#endif
3534
3535 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3197 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3536 udelay(10); 3198 udelay(10);
3537 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3199 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3547,9 +3209,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3547 3209
3548static void stli_onbenable(stlibrd_t *brdp) 3210static void stli_onbenable(stlibrd_t *brdp)
3549{ 3211{
3550#ifdef DEBUG
3551 printk(KERN_DEBUG "stli_onbenable(brdp=%x)\n", (int) brdp);
3552#endif
3553 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); 3212 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR));
3554} 3213}
3555 3214
@@ -3557,9 +3216,6 @@ static void stli_onbenable(stlibrd_t *brdp)
3557 3216
3558static void stli_onbdisable(stlibrd_t *brdp) 3217static void stli_onbdisable(stlibrd_t *brdp)
3559{ 3218{
3560#ifdef DEBUG
3561 printk(KERN_DEBUG "stli_onbdisable(brdp=%x)\n", (int) brdp);
3562#endif
3563 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); 3219 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR));
3564} 3220}
3565 3221
@@ -3569,11 +3225,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3569{ 3225{
3570 void *ptr; 3226 void *ptr;
3571 3227
3572#ifdef DEBUG
3573 printk(KERN_DEBUG "stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3574 (int) offset);
3575#endif
3576
3577 if (offset > brdp->memsize) { 3228 if (offset > brdp->memsize) {
3578 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3229 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3579 "range at line=%d(%d), brd=%d\n", 3230 "range at line=%d(%d), brd=%d\n",
@@ -3589,11 +3240,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3589 3240
3590static void stli_onbreset(stlibrd_t *brdp) 3241static void stli_onbreset(stlibrd_t *brdp)
3591{ 3242{
3592
3593#ifdef DEBUG
3594 printk(KERN_DEBUG "stli_onbreset(brdp=%x)\n", (int) brdp);
3595#endif
3596
3597 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3243 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3598 udelay(10); 3244 udelay(10);
3599 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3245 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3610,10 +3256,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3610{ 3256{
3611 unsigned long memconf; 3257 unsigned long memconf;
3612 3258
3613#ifdef DEBUG
3614 printk(KERN_DEBUG "stli_onbeinit(brdp=%d)\n", (int) brdp);
3615#endif
3616
3617 outb(0x1, (brdp->iobase + ONB_EIBRDENAB)); 3259 outb(0x1, (brdp->iobase + ONB_EIBRDENAB));
3618 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3260 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3619 udelay(10); 3261 udelay(10);
@@ -3632,9 +3274,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3632 3274
3633static void stli_onbeenable(stlibrd_t *brdp) 3275static void stli_onbeenable(stlibrd_t *brdp)
3634{ 3276{
3635#ifdef DEBUG
3636 printk(KERN_DEBUG "stli_onbeenable(brdp=%x)\n", (int) brdp);
3637#endif
3638 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); 3277 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR));
3639} 3278}
3640 3279
@@ -3642,9 +3281,6 @@ static void stli_onbeenable(stlibrd_t *brdp)
3642 3281
3643static void stli_onbedisable(stlibrd_t *brdp) 3282static void stli_onbedisable(stlibrd_t *brdp)
3644{ 3283{
3645#ifdef DEBUG
3646 printk(KERN_DEBUG "stli_onbedisable(brdp=%x)\n", (int) brdp);
3647#endif
3648 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3284 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
3649} 3285}
3650 3286
@@ -3652,13 +3288,8 @@ static void stli_onbedisable(stlibrd_t *brdp)
3652 3288
3653static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3289static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3654{ 3290{
3655 void *ptr; 3291 void *ptr;
3656 unsigned char val; 3292 unsigned char val;
3657
3658#ifdef DEBUG
3659 printk(KERN_DEBUG "stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n",
3660 (int) brdp, (int) offset, line);
3661#endif
3662 3293
3663 if (offset > brdp->memsize) { 3294 if (offset > brdp->memsize) {
3664 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3295 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3681,11 +3312,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3681 3312
3682static void stli_onbereset(stlibrd_t *brdp) 3313static void stli_onbereset(stlibrd_t *brdp)
3683{ 3314{
3684
3685#ifdef DEBUG
3686 printk(KERN_ERR "stli_onbereset(brdp=%x)\n", (int) brdp);
3687#endif
3688
3689 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3315 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3690 udelay(10); 3316 udelay(10);
3691 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3317 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
@@ -3700,11 +3326,6 @@ static void stli_onbereset(stlibrd_t *brdp)
3700 3326
3701static void stli_bbyinit(stlibrd_t *brdp) 3327static void stli_bbyinit(stlibrd_t *brdp)
3702{ 3328{
3703
3704#ifdef DEBUG
3705 printk(KERN_ERR "stli_bbyinit(brdp=%d)\n", (int) brdp);
3706#endif
3707
3708 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3329 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3709 udelay(10); 3330 udelay(10);
3710 outb(0, (brdp->iobase + BBY_ATCONFR)); 3331 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3717,24 +3338,13 @@ static void stli_bbyinit(stlibrd_t *brdp)
3717 3338
3718static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3339static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3719{ 3340{
3720 void *ptr; 3341 void *ptr;
3721 unsigned char val; 3342 unsigned char val;
3722 3343
3723#ifdef DEBUG 3344 BUG_ON(offset > brdp->memsize);
3724 printk(KERN_ERR "stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3725 (int) offset);
3726#endif
3727 3345
3728 if (offset > brdp->memsize) { 3346 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3729 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3347 val = (unsigned char) (offset / BBY_PAGESIZE);
3730 "range at line=%d(%d), brd=%d\n",
3731 (int) offset, line, __LINE__, brdp->brdnr);
3732 ptr = NULL;
3733 val = 0;
3734 } else {
3735 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3736 val = (unsigned char) (offset / BBY_PAGESIZE);
3737 }
3738 outb(val, (brdp->iobase + BBY_ATCONFR)); 3348 outb(val, (brdp->iobase + BBY_ATCONFR));
3739 return(ptr); 3349 return(ptr);
3740} 3350}
@@ -3743,11 +3353,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3743 3353
3744static void stli_bbyreset(stlibrd_t *brdp) 3354static void stli_bbyreset(stlibrd_t *brdp)
3745{ 3355{
3746
3747#ifdef DEBUG
3748 printk(KERN_DEBUG "stli_bbyreset(brdp=%x)\n", (int) brdp);
3749#endif
3750
3751 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3356 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3752 udelay(10); 3357 udelay(10);
3753 outb(0, (brdp->iobase + BBY_ATCONFR)); 3358 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3762,11 +3367,6 @@ static void stli_bbyreset(stlibrd_t *brdp)
3762 3367
3763static void stli_stalinit(stlibrd_t *brdp) 3368static void stli_stalinit(stlibrd_t *brdp)
3764{ 3369{
3765
3766#ifdef DEBUG
3767 printk(KERN_DEBUG "stli_stalinit(brdp=%d)\n", (int) brdp);
3768#endif
3769
3770 outb(0x1, brdp->iobase); 3370 outb(0x1, brdp->iobase);
3771 mdelay(1000); 3371 mdelay(1000);
3772} 3372}
@@ -3775,36 +3375,18 @@ static void stli_stalinit(stlibrd_t *brdp)
3775 3375
3776static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3376static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3777{ 3377{
3778 void *ptr; 3378 BUG_ON(offset > brdp->memsize);
3779 3379 return brdp->membase + (offset % STAL_PAGESIZE);
3780#ifdef DEBUG
3781 printk(KERN_DEBUG "stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3782 (int) offset);
3783#endif
3784
3785 if (offset > brdp->memsize) {
3786 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3787 "range at line=%d(%d), brd=%d\n",
3788 (int) offset, line, __LINE__, brdp->brdnr);
3789 ptr = NULL;
3790 } else {
3791 ptr = brdp->membase + (offset % STAL_PAGESIZE);
3792 }
3793 return(ptr);
3794} 3380}
3795 3381
3796/*****************************************************************************/ 3382/*****************************************************************************/
3797 3383
3798static void stli_stalreset(stlibrd_t *brdp) 3384static void stli_stalreset(stlibrd_t *brdp)
3799{ 3385{
3800 volatile unsigned long *vecp; 3386 u32 __iomem *vecp;
3801
3802#ifdef DEBUG
3803 printk(KERN_DEBUG "stli_stalreset(brdp=%x)\n", (int) brdp);
3804#endif
3805 3387
3806 vecp = (volatile unsigned long *) (brdp->membase + 0x30); 3388 vecp = (u32 __iomem *) (brdp->membase + 0x30);
3807 *vecp = 0xffff0000; 3389 writel(0xffff0000, vecp);
3808 outb(0, brdp->iobase); 3390 outb(0, brdp->iobase);
3809 mdelay(1000); 3391 mdelay(1000);
3810} 3392}
@@ -3818,15 +3400,11 @@ static void stli_stalreset(stlibrd_t *brdp)
3818 3400
3819static int stli_initecp(stlibrd_t *brdp) 3401static int stli_initecp(stlibrd_t *brdp)
3820{ 3402{
3821 cdkecpsig_t sig; 3403 cdkecpsig_t sig;
3822 cdkecpsig_t *sigsp; 3404 cdkecpsig_t __iomem *sigsp;
3823 unsigned int status, nxtid; 3405 unsigned int status, nxtid;
3824 char *name; 3406 char *name;
3825 int panelnr, nrports; 3407 int panelnr, nrports;
3826
3827#ifdef DEBUG
3828 printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp);
3829#endif
3830 3408
3831 if (!request_region(brdp->iobase, brdp->iosize, "istallion")) 3409 if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
3832 return -EIO; 3410 return -EIO;
@@ -3834,7 +3412,7 @@ static int stli_initecp(stlibrd_t *brdp)
3834 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3412 if ((brdp->iobase == 0) || (brdp->memaddr == 0))
3835 { 3413 {
3836 release_region(brdp->iobase, brdp->iosize); 3414 release_region(brdp->iobase, brdp->iosize);
3837 return(-ENODEV); 3415 return -ENODEV;
3838 } 3416 }
3839 3417
3840 brdp->iosize = ECP_IOSIZE; 3418 brdp->iosize = ECP_IOSIZE;
@@ -3903,7 +3481,7 @@ static int stli_initecp(stlibrd_t *brdp)
3903 3481
3904 default: 3482 default:
3905 release_region(brdp->iobase, brdp->iosize); 3483 release_region(brdp->iobase, brdp->iosize);
3906 return(-EINVAL); 3484 return -EINVAL;
3907 } 3485 }
3908 3486
3909/* 3487/*
@@ -3915,10 +3493,10 @@ static int stli_initecp(stlibrd_t *brdp)
3915 EBRDINIT(brdp); 3493 EBRDINIT(brdp);
3916 3494
3917 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3495 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
3918 if (brdp->membase == (void *) NULL) 3496 if (brdp->membase == NULL)
3919 { 3497 {
3920 release_region(brdp->iobase, brdp->iosize); 3498 release_region(brdp->iobase, brdp->iosize);
3921 return(-ENOMEM); 3499 return -ENOMEM;
3922 } 3500 }
3923 3501
3924/* 3502/*
@@ -3927,23 +3505,14 @@ static int stli_initecp(stlibrd_t *brdp)
3927 * this is, and what it is connected to it. 3505 * this is, and what it is connected to it.
3928 */ 3506 */
3929 EBRDENABLE(brdp); 3507 EBRDENABLE(brdp);
3930 sigsp = (cdkecpsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3508 sigsp = (cdkecpsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
3931 memcpy(&sig, sigsp, sizeof(cdkecpsig_t)); 3509 memcpy(&sig, sigsp, sizeof(cdkecpsig_t));
3932 EBRDDISABLE(brdp); 3510 EBRDDISABLE(brdp);
3933 3511
3934#if 0 3512 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3935 printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n",
3936 __FILE__, __LINE__, (int) sig.magic, sig.romver, sig.panelid[0],
3937 (int) sig.panelid[1], (int) sig.panelid[2],
3938 (int) sig.panelid[3], (int) sig.panelid[4],
3939 (int) sig.panelid[5], (int) sig.panelid[6],
3940 (int) sig.panelid[7]);
3941#endif
3942
3943 if (sig.magic != ECP_MAGIC)
3944 { 3513 {
3945 release_region(brdp->iobase, brdp->iosize); 3514 release_region(brdp->iobase, brdp->iosize);
3946 return(-ENODEV); 3515 return -ENODEV;
3947 } 3516 }
3948 3517
3949/* 3518/*
@@ -3967,7 +3536,7 @@ static int stli_initecp(stlibrd_t *brdp)
3967 3536
3968 3537
3969 brdp->state |= BST_FOUND; 3538 brdp->state |= BST_FOUND;
3970 return(0); 3539 return 0;
3971} 3540}
3972 3541
3973/*****************************************************************************/ 3542/*****************************************************************************/
@@ -3979,20 +3548,16 @@ static int stli_initecp(stlibrd_t *brdp)
3979 3548
3980static int stli_initonb(stlibrd_t *brdp) 3549static int stli_initonb(stlibrd_t *brdp)
3981{ 3550{
3982 cdkonbsig_t sig; 3551 cdkonbsig_t sig;
3983 cdkonbsig_t *sigsp; 3552 cdkonbsig_t __iomem *sigsp;
3984 char *name; 3553 char *name;
3985 int i; 3554 int i;
3986
3987#ifdef DEBUG
3988 printk(KERN_DEBUG "stli_initonb(brdp=%x)\n", (int) brdp);
3989#endif
3990 3555
3991/* 3556/*
3992 * Do a basic sanity check on the IO and memory addresses. 3557 * Do a basic sanity check on the IO and memory addresses.
3993 */ 3558 */
3994 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3559 if (brdp->iobase == 0 || brdp->memaddr == 0)
3995 return(-ENODEV); 3560 return -ENODEV;
3996 3561
3997 brdp->iosize = ONB_IOSIZE; 3562 brdp->iosize = ONB_IOSIZE;
3998 3563
@@ -4010,7 +3575,6 @@ static int stli_initonb(stlibrd_t *brdp)
4010 case BRD_ONBOARD2: 3575 case BRD_ONBOARD2:
4011 case BRD_ONBOARD2_32: 3576 case BRD_ONBOARD2_32:
4012 case BRD_ONBOARDRS: 3577 case BRD_ONBOARDRS:
4013 brdp->membase = (void *) brdp->memaddr;
4014 brdp->memsize = ONB_MEMSIZE; 3578 brdp->memsize = ONB_MEMSIZE;
4015 brdp->pagesize = ONB_ATPAGESIZE; 3579 brdp->pagesize = ONB_ATPAGESIZE;
4016 brdp->init = stli_onbinit; 3580 brdp->init = stli_onbinit;
@@ -4028,7 +3592,6 @@ static int stli_initonb(stlibrd_t *brdp)
4028 break; 3592 break;
4029 3593
4030 case BRD_ONBOARDE: 3594 case BRD_ONBOARDE:
4031 brdp->membase = (void *) brdp->memaddr;
4032 brdp->memsize = ONB_EIMEMSIZE; 3595 brdp->memsize = ONB_EIMEMSIZE;
4033 brdp->pagesize = ONB_EIPAGESIZE; 3596 brdp->pagesize = ONB_EIPAGESIZE;
4034 brdp->init = stli_onbeinit; 3597 brdp->init = stli_onbeinit;
@@ -4044,7 +3607,6 @@ static int stli_initonb(stlibrd_t *brdp)
4044 case BRD_BRUMBY4: 3607 case BRD_BRUMBY4:
4045 case BRD_BRUMBY8: 3608 case BRD_BRUMBY8:
4046 case BRD_BRUMBY16: 3609 case BRD_BRUMBY16:
4047 brdp->membase = (void *) brdp->memaddr;
4048 brdp->memsize = BBY_MEMSIZE; 3610 brdp->memsize = BBY_MEMSIZE;
4049 brdp->pagesize = BBY_PAGESIZE; 3611 brdp->pagesize = BBY_PAGESIZE;
4050 brdp->init = stli_bbyinit; 3612 brdp->init = stli_bbyinit;
@@ -4058,7 +3620,6 @@ static int stli_initonb(stlibrd_t *brdp)
4058 break; 3620 break;
4059 3621
4060 case BRD_STALLION: 3622 case BRD_STALLION:
4061 brdp->membase = (void *) brdp->memaddr;
4062 brdp->memsize = STAL_MEMSIZE; 3623 brdp->memsize = STAL_MEMSIZE;
4063 brdp->pagesize = STAL_PAGESIZE; 3624 brdp->pagesize = STAL_PAGESIZE;
4064 brdp->init = stli_stalinit; 3625 brdp->init = stli_stalinit;
@@ -4073,7 +3634,7 @@ static int stli_initonb(stlibrd_t *brdp)
4073 3634
4074 default: 3635 default:
4075 release_region(brdp->iobase, brdp->iosize); 3636 release_region(brdp->iobase, brdp->iosize);
4076 return(-EINVAL); 3637 return -EINVAL;
4077 } 3638 }
4078 3639
4079/* 3640/*
@@ -4085,10 +3646,10 @@ static int stli_initonb(stlibrd_t *brdp)
4085 EBRDINIT(brdp); 3646 EBRDINIT(brdp);
4086 3647
4087 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3648 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4088 if (brdp->membase == (void *) NULL) 3649 if (brdp->membase == NULL)
4089 { 3650 {
4090 release_region(brdp->iobase, brdp->iosize); 3651 release_region(brdp->iobase, brdp->iosize);
4091 return(-ENOMEM); 3652 return -ENOMEM;
4092 } 3653 }
4093 3654
4094/* 3655/*
@@ -4097,21 +3658,17 @@ static int stli_initonb(stlibrd_t *brdp)
4097 * this is, and how many ports. 3658 * this is, and how many ports.
4098 */ 3659 */
4099 EBRDENABLE(brdp); 3660 EBRDENABLE(brdp);
4100 sigsp = (cdkonbsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3661 sigsp = (cdkonbsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
4101 memcpy(&sig, sigsp, sizeof(cdkonbsig_t)); 3662 memcpy_fromio(&sig, sigsp, sizeof(cdkonbsig_t));
4102 EBRDDISABLE(brdp); 3663 EBRDDISABLE(brdp);
4103 3664
4104#if 0 3665 if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) ||
4105 printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n", 3666 sig.magic1 != cpu_to_le16(ONB_MAGIC1) ||
4106 __FILE__, __LINE__, sig.magic0, sig.magic1, sig.magic2, 3667 sig.magic2 != cpu_to_le16(ONB_MAGIC2) ||
4107 sig.magic3, sig.romver, sig.amask0, sig.amask1, sig.amask2); 3668 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
4108#endif
4109
4110 if ((sig.magic0 != ONB_MAGIC0) || (sig.magic1 != ONB_MAGIC1) ||
4111 (sig.magic2 != ONB_MAGIC2) || (sig.magic3 != ONB_MAGIC3))
4112 { 3669 {
4113 release_region(brdp->iobase, brdp->iosize); 3670 release_region(brdp->iobase, brdp->iosize);
4114 return(-ENODEV); 3671 return -ENODEV;
4115 } 3672 }
4116 3673
4117/* 3674/*
@@ -4132,7 +3689,7 @@ static int stli_initonb(stlibrd_t *brdp)
4132 3689
4133 3690
4134 brdp->state |= BST_FOUND; 3691 brdp->state |= BST_FOUND;
4135 return(0); 3692 return 0;
4136} 3693}
4137 3694
4138/*****************************************************************************/ 3695/*****************************************************************************/
@@ -4145,31 +3702,25 @@ static int stli_initonb(stlibrd_t *brdp)
4145 3702
4146static int stli_startbrd(stlibrd_t *brdp) 3703static int stli_startbrd(stlibrd_t *brdp)
4147{ 3704{
4148 volatile cdkhdr_t *hdrp; 3705 cdkhdr_t __iomem *hdrp;
4149 volatile cdkmem_t *memp; 3706 cdkmem_t __iomem *memp;
4150 volatile cdkasy_t *ap; 3707 cdkasy_t __iomem *ap;
4151 unsigned long flags; 3708 unsigned long flags;
4152 stliport_t *portp; 3709 stliport_t *portp;
4153 int portnr, nrdevs, i, rc; 3710 int portnr, nrdevs, i, rc = 0;
4154 3711 u32 memoff;
4155#ifdef DEBUG 3712
4156 printk(KERN_DEBUG "stli_startbrd(brdp=%x)\n", (int) brdp); 3713 spin_lock_irqsave(&brd_lock, flags);
4157#endif
4158
4159 rc = 0;
4160
4161 save_flags(flags);
4162 cli();
4163 EBRDENABLE(brdp); 3714 EBRDENABLE(brdp);
4164 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 3715 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
4165 nrdevs = hdrp->nrdevs; 3716 nrdevs = hdrp->nrdevs;
4166 3717
4167#if 0 3718#if 0
4168 printk("%s(%d): CDK version %d.%d.%d --> " 3719 printk("%s(%d): CDK version %d.%d.%d --> "
4169 "nrdevs=%d memp=%x hostp=%x slavep=%x\n", 3720 "nrdevs=%d memp=%x hostp=%x slavep=%x\n",
4170 __FILE__, __LINE__, hdrp->ver_release, hdrp->ver_modification, 3721 __FILE__, __LINE__, readb(&hdrp->ver_release), readb(&hdrp->ver_modification),
4171 hdrp->ver_fix, nrdevs, (int) hdrp->memp, (int) hdrp->hostp, 3722 readb(&hdrp->ver_fix), nrdevs, (int) readl(&hdrp->memp), readl(&hdrp->hostp),
4172 (int) hdrp->slavep); 3723 readl(&hdrp->slavep));
4173#endif 3724#endif
4174 3725
4175 if (nrdevs < (brdp->nrports + 1)) { 3726 if (nrdevs < (brdp->nrports + 1)) {
@@ -4181,14 +3732,14 @@ static int stli_startbrd(stlibrd_t *brdp)
4181 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR; 3732 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR;
4182 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR; 3733 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR;
4183 brdp->bitsize = (nrdevs + 7) / 8; 3734 brdp->bitsize = (nrdevs + 7) / 8;
4184 memp = (volatile cdkmem_t *) hdrp->memp; 3735 memoff = readl(&hdrp->memp);
4185 if (((unsigned long) memp) > brdp->memsize) { 3736 if (memoff > brdp->memsize) {
4186 printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); 3737 printk(KERN_ERR "STALLION: corrupted shared memory region?\n");
4187 rc = -EIO; 3738 rc = -EIO;
4188 goto stli_donestartup; 3739 goto stli_donestartup;
4189 } 3740 }
4190 memp = (volatile cdkmem_t *) EBRDGETMEMPTR(brdp, (unsigned long) memp); 3741 memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff);
4191 if (memp->dtype != TYP_ASYNCTRL) { 3742 if (readw(&memp->dtype) != TYP_ASYNCTRL) {
4192 printk(KERN_ERR "STALLION: no slave control device found\n"); 3743 printk(KERN_ERR "STALLION: no slave control device found\n");
4193 goto stli_donestartup; 3744 goto stli_donestartup;
4194 } 3745 }
@@ -4200,19 +3751,19 @@ static int stli_startbrd(stlibrd_t *brdp)
4200 * change pages while reading memory map. 3751 * change pages while reading memory map.
4201 */ 3752 */
4202 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) { 3753 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) {
4203 if (memp->dtype != TYP_ASYNC) 3754 if (readw(&memp->dtype) != TYP_ASYNC)
4204 break; 3755 break;
4205 portp = brdp->ports[portnr]; 3756 portp = brdp->ports[portnr];
4206 if (portp == (stliport_t *) NULL) 3757 if (portp == NULL)
4207 break; 3758 break;
4208 portp->devnr = i; 3759 portp->devnr = i;
4209 portp->addr = memp->offset; 3760 portp->addr = readl(&memp->offset);
4210 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs)); 3761 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs));
4211 portp->portidx = (unsigned char) (i / 8); 3762 portp->portidx = (unsigned char) (i / 8);
4212 portp->portbit = (unsigned char) (0x1 << (i % 8)); 3763 portp->portbit = (unsigned char) (0x1 << (i % 8));
4213 } 3764 }
4214 3765
4215 hdrp->slavereq = 0xff; 3766 writeb(0xff, &hdrp->slavereq);
4216 3767
4217/* 3768/*
4218 * For each port setup a local copy of the RX and TX buffer offsets 3769 * For each port setup a local copy of the RX and TX buffer offsets
@@ -4221,22 +3772,22 @@ static int stli_startbrd(stlibrd_t *brdp)
4221 */ 3772 */
4222 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) { 3773 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) {
4223 portp = brdp->ports[portnr]; 3774 portp = brdp->ports[portnr];
4224 if (portp == (stliport_t *) NULL) 3775 if (portp == NULL)
4225 break; 3776 break;
4226 if (portp->addr == 0) 3777 if (portp->addr == 0)
4227 break; 3778 break;
4228 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 3779 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
4229 if (ap != (volatile cdkasy_t *) NULL) { 3780 if (ap != NULL) {
4230 portp->rxsize = ap->rxq.size; 3781 portp->rxsize = readw(&ap->rxq.size);
4231 portp->txsize = ap->txq.size; 3782 portp->txsize = readw(&ap->txq.size);
4232 portp->rxoffset = ap->rxq.offset; 3783 portp->rxoffset = readl(&ap->rxq.offset);
4233 portp->txoffset = ap->txq.offset; 3784 portp->txoffset = readl(&ap->txq.offset);
4234 } 3785 }
4235 } 3786 }
4236 3787
4237stli_donestartup: 3788stli_donestartup:
4238 EBRDDISABLE(brdp); 3789 EBRDDISABLE(brdp);
4239 restore_flags(flags); 3790 spin_unlock_irqrestore(&brd_lock, flags);
4240 3791
4241 if (rc == 0) 3792 if (rc == 0)
4242 brdp->state |= BST_STARTED; 3793 brdp->state |= BST_STARTED;
@@ -4247,7 +3798,7 @@ stli_donestartup:
4247 add_timer(&stli_timerlist); 3798 add_timer(&stli_timerlist);
4248 } 3799 }
4249 3800
4250 return(rc); 3801 return rc;
4251} 3802}
4252 3803
4253/*****************************************************************************/ 3804/*****************************************************************************/
@@ -4258,10 +3809,6 @@ stli_donestartup:
4258 3809
4259static int __init stli_brdinit(stlibrd_t *brdp) 3810static int __init stli_brdinit(stlibrd_t *brdp)
4260{ 3811{
4261#ifdef DEBUG
4262 printk(KERN_DEBUG "stli_brdinit(brdp=%x)\n", (int) brdp);
4263#endif
4264
4265 stli_brds[brdp->brdnr] = brdp; 3812 stli_brds[brdp->brdnr] = brdp;
4266 3813
4267 switch (brdp->brdtype) { 3814 switch (brdp->brdtype) {
@@ -4289,11 +3836,11 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4289 case BRD_ECHPCI: 3836 case BRD_ECHPCI:
4290 printk(KERN_ERR "STALLION: %s board type not supported in " 3837 printk(KERN_ERR "STALLION: %s board type not supported in "
4291 "this driver\n", stli_brdnames[brdp->brdtype]); 3838 "this driver\n", stli_brdnames[brdp->brdtype]);
4292 return(ENODEV); 3839 return -ENODEV;
4293 default: 3840 default:
4294 printk(KERN_ERR "STALLION: board=%d is unknown board " 3841 printk(KERN_ERR "STALLION: board=%d is unknown board "
4295 "type=%d\n", brdp->brdnr, brdp->brdtype); 3842 "type=%d\n", brdp->brdnr, brdp->brdtype);
4296 return(ENODEV); 3843 return -ENODEV;
4297 } 3844 }
4298 3845
4299 if ((brdp->state & BST_FOUND) == 0) { 3846 if ((brdp->state & BST_FOUND) == 0) {
@@ -4301,7 +3848,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4301 "io=%x mem=%x\n", 3848 "io=%x mem=%x\n",
4302 stli_brdnames[brdp->brdtype], brdp->brdnr, 3849 stli_brdnames[brdp->brdtype], brdp->brdnr,
4303 brdp->iobase, (int) brdp->memaddr); 3850 brdp->iobase, (int) brdp->memaddr);
4304 return(ENODEV); 3851 return -ENODEV;
4305 } 3852 }
4306 3853
4307 stli_initports(brdp); 3854 stli_initports(brdp);
@@ -4309,7 +3856,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4309 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], 3856 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype],
4310 brdp->brdnr, brdp->iobase, (int) brdp->memaddr, 3857 brdp->brdnr, brdp->iobase, (int) brdp->memaddr,
4311 brdp->nrpanels, brdp->nrports); 3858 brdp->nrpanels, brdp->nrports);
4312 return(0); 3859 return 0;
4313} 3860}
4314 3861
4315/*****************************************************************************/ 3862/*****************************************************************************/
@@ -4321,14 +3868,10 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4321 3868
4322static int stli_eisamemprobe(stlibrd_t *brdp) 3869static int stli_eisamemprobe(stlibrd_t *brdp)
4323{ 3870{
4324 cdkecpsig_t ecpsig, *ecpsigp; 3871 cdkecpsig_t ecpsig, __iomem *ecpsigp;
4325 cdkonbsig_t onbsig, *onbsigp; 3872 cdkonbsig_t onbsig, __iomem *onbsigp;
4326 int i, foundit; 3873 int i, foundit;
4327 3874
4328#ifdef DEBUG
4329 printk(KERN_DEBUG "stli_eisamemprobe(brdp=%x)\n", (int) brdp);
4330#endif
4331
4332/* 3875/*
4333 * First up we reset the board, to get it into a known state. There 3876 * First up we reset the board, to get it into a known state. There
4334 * is only 2 board types here we need to worry about. Don;t use the 3877 * is only 2 board types here we need to worry about. Don;t use the
@@ -4352,7 +3895,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4352 mdelay(1); 3895 mdelay(1);
4353 stli_onbeenable(brdp); 3896 stli_onbeenable(brdp);
4354 } else { 3897 } else {
4355 return(-ENODEV); 3898 return -ENODEV;
4356 } 3899 }
4357 3900
4358 foundit = 0; 3901 foundit = 0;
@@ -4364,25 +3907,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4364 */ 3907 */
4365 for (i = 0; (i < stli_eisamempsize); i++) { 3908 for (i = 0; (i < stli_eisamempsize); i++) {
4366 brdp->memaddr = stli_eisamemprobeaddrs[i]; 3909 brdp->memaddr = stli_eisamemprobeaddrs[i];
4367 brdp->membase = (void *) brdp->memaddr;
4368 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3910 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4369 if (brdp->membase == (void *) NULL) 3911 if (brdp->membase == NULL)
4370 continue; 3912 continue;
4371 3913
4372 if (brdp->brdtype == BRD_ECPE) { 3914 if (brdp->brdtype == BRD_ECPE) {
4373 ecpsigp = (cdkecpsig_t *) stli_ecpeigetmemptr(brdp, 3915 ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp,
4374 CDK_SIGADDR, __LINE__); 3916 CDK_SIGADDR, __LINE__);
4375 memcpy(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); 3917 memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t));
4376 if (ecpsig.magic == ECP_MAGIC) 3918 if (ecpsig.magic == cpu_to_le32(ECP_MAGIC))
4377 foundit = 1; 3919 foundit = 1;
4378 } else { 3920 } else {
4379 onbsigp = (cdkonbsig_t *) stli_onbegetmemptr(brdp, 3921 onbsigp = (cdkonbsig_t __iomem *) stli_onbegetmemptr(brdp,
4380 CDK_SIGADDR, __LINE__); 3922 CDK_SIGADDR, __LINE__);
4381 memcpy(&onbsig, onbsigp, sizeof(cdkonbsig_t)); 3923 memcpy_fromio(&onbsig, onbsigp, sizeof(cdkonbsig_t));
4382 if ((onbsig.magic0 == ONB_MAGIC0) && 3924 if ((onbsig.magic0 == cpu_to_le16(ONB_MAGIC0)) &&
4383 (onbsig.magic1 == ONB_MAGIC1) && 3925 (onbsig.magic1 == cpu_to_le16(ONB_MAGIC1)) &&
4384 (onbsig.magic2 == ONB_MAGIC2) && 3926 (onbsig.magic2 == cpu_to_le16(ONB_MAGIC2)) &&
4385 (onbsig.magic3 == ONB_MAGIC3)) 3927 (onbsig.magic3 == cpu_to_le16(ONB_MAGIC3)))
4386 foundit = 1; 3928 foundit = 1;
4387 } 3929 }
4388 3930
@@ -4406,9 +3948,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4406 printk(KERN_ERR "STALLION: failed to probe shared memory " 3948 printk(KERN_ERR "STALLION: failed to probe shared memory "
4407 "region for %s in EISA slot=%d\n", 3949 "region for %s in EISA slot=%d\n",
4408 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); 3950 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12));
4409 return(-ENODEV); 3951 return -ENODEV;
4410 } 3952 }
4411 return(0); 3953 return 0;
4412} 3954}
4413 3955
4414static int stli_getbrdnr(void) 3956static int stli_getbrdnr(void)
@@ -4439,22 +3981,16 @@ static int stli_getbrdnr(void)
4439 3981
4440static int stli_findeisabrds(void) 3982static int stli_findeisabrds(void)
4441{ 3983{
4442 stlibrd_t *brdp; 3984 stlibrd_t *brdp;
4443 unsigned int iobase, eid; 3985 unsigned int iobase, eid;
4444 int i; 3986 int i;
4445
4446#ifdef DEBUG
4447 printk(KERN_DEBUG "stli_findeisabrds()\n");
4448#endif
4449 3987
4450/* 3988/*
4451 * Firstly check if this is an EISA system. Do this by probing for 3989 * Firstly check if this is an EISA system. If this is not an EISA system then
4452 * the system board EISA ID. If this is not an EISA system then
4453 * don't bother going any further! 3990 * don't bother going any further!
4454 */ 3991 */
4455 outb(0xff, 0xc80); 3992 if (EISA_bus)
4456 if (inb(0xc80) == 0xff) 3993 return 0;
4457 return(0);
4458 3994
4459/* 3995/*
4460 * Looks like an EISA system, so go searching for EISA boards. 3996 * Looks like an EISA system, so go searching for EISA boards.
@@ -4472,7 +4008,7 @@ static int stli_findeisabrds(void)
4472 */ 4008 */
4473 for (i = 0; (i < STL_MAXBRDS); i++) { 4009 for (i = 0; (i < STL_MAXBRDS); i++) {
4474 brdp = stli_brds[i]; 4010 brdp = stli_brds[i];
4475 if (brdp == (stlibrd_t *) NULL) 4011 if (brdp == NULL)
4476 continue; 4012 continue;
4477 if (brdp->iobase == iobase) 4013 if (brdp->iobase == iobase)
4478 break; 4014 break;
@@ -4484,10 +4020,10 @@ static int stli_findeisabrds(void)
4484 * We have found a Stallion board and it is not configured already. 4020 * We have found a Stallion board and it is not configured already.
4485 * Allocate a board structure and initialize it. 4021 * Allocate a board structure and initialize it.
4486 */ 4022 */
4487 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4023 if ((brdp = stli_allocbrd()) == NULL)
4488 return(-ENOMEM); 4024 return -ENOMEM;
4489 if ((brdp->brdnr = stli_getbrdnr()) < 0) 4025 if ((brdp->brdnr = stli_getbrdnr()) < 0)
4490 return(-ENOMEM); 4026 return -ENOMEM;
4491 eid = inb(iobase + 0xc82); 4027 eid = inb(iobase + 0xc82);
4492 if (eid == ECP_EISAID) 4028 if (eid == ECP_EISAID)
4493 brdp->brdtype = BRD_ECPE; 4029 brdp->brdtype = BRD_ECPE;
@@ -4502,7 +4038,7 @@ static int stli_findeisabrds(void)
4502 stli_brdinit(brdp); 4038 stli_brdinit(brdp);
4503 } 4039 }
4504 4040
4505 return(0); 4041 return 0;
4506} 4042}
4507 4043
4508/*****************************************************************************/ 4044/*****************************************************************************/
@@ -4523,32 +4059,18 @@ static int stli_findeisabrds(void)
4523 4059
4524static int stli_initpcibrd(int brdtype, struct pci_dev *devp) 4060static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4525{ 4061{
4526 stlibrd_t *brdp; 4062 stlibrd_t *brdp;
4527
4528#ifdef DEBUG
4529 printk(KERN_DEBUG "stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n",
4530 brdtype, dev->bus->number, dev->devfn);
4531#endif
4532 4063
4533 if (pci_enable_device(devp)) 4064 if (pci_enable_device(devp))
4534 return(-EIO); 4065 return -EIO;
4535 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4066 if ((brdp = stli_allocbrd()) == NULL)
4536 return(-ENOMEM); 4067 return -ENOMEM;
4537 if ((brdp->brdnr = stli_getbrdnr()) < 0) { 4068 if ((brdp->brdnr = stli_getbrdnr()) < 0) {
4538 printk(KERN_INFO "STALLION: too many boards found, " 4069 printk(KERN_INFO "STALLION: too many boards found, "
4539 "maximum supported %d\n", STL_MAXBRDS); 4070 "maximum supported %d\n", STL_MAXBRDS);
4540 return(0); 4071 return 0;
4541 } 4072 }
4542 brdp->brdtype = brdtype; 4073 brdp->brdtype = brdtype;
4543
4544#ifdef DEBUG
4545 printk(KERN_DEBUG "%s(%d): BAR[]=%lx,%lx,%lx,%lx\n", __FILE__, __LINE__,
4546 pci_resource_start(devp, 0),
4547 pci_resource_start(devp, 1),
4548 pci_resource_start(devp, 2),
4549 pci_resource_start(devp, 3));
4550#endif
4551
4552/* 4074/*
4553 * We have all resources from the board, so lets setup the actual 4075 * We have all resources from the board, so lets setup the actual
4554 * board structure now. 4076 * board structure now.
@@ -4557,7 +4079,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4557 brdp->memaddr = pci_resource_start(devp, 2); 4079 brdp->memaddr = pci_resource_start(devp, 2);
4558 stli_brdinit(brdp); 4080 stli_brdinit(brdp);
4559 4081
4560 return(0); 4082 return 0;
4561} 4083}
4562 4084
4563/*****************************************************************************/ 4085/*****************************************************************************/
@@ -4569,20 +4091,12 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4569 4091
4570static int stli_findpcibrds(void) 4092static int stli_findpcibrds(void)
4571{ 4093{
4572 struct pci_dev *dev = NULL; 4094 struct pci_dev *dev = NULL;
4573 int rc;
4574
4575#ifdef DEBUG
4576 printk("stli_findpcibrds()\n");
4577#endif
4578 4095
4579 while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION, 4096 while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) {
4580 PCI_DEVICE_ID_ECRA, dev))) { 4097 stli_initpcibrd(BRD_ECPPCI, dev);
4581 if ((rc = stli_initpcibrd(BRD_ECPPCI, dev)))
4582 return(rc);
4583 } 4098 }
4584 4099 return 0;
4585 return(0);
4586} 4100}
4587 4101
4588#endif 4102#endif
@@ -4595,17 +4109,16 @@ static int stli_findpcibrds(void)
4595 4109
4596static stlibrd_t *stli_allocbrd(void) 4110static stlibrd_t *stli_allocbrd(void)
4597{ 4111{
4598 stlibrd_t *brdp; 4112 stlibrd_t *brdp;
4599 4113
4600 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); 4114 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL);
4601 if (!brdp) { 4115 if (!brdp) {
4602 printk(KERN_ERR "STALLION: failed to allocate memory " 4116 printk(KERN_ERR "STALLION: failed to allocate memory "
4603 "(size=%d)\n", sizeof(stlibrd_t)); 4117 "(size=%Zd)\n", sizeof(stlibrd_t));
4604 return NULL; 4118 return NULL;
4605 } 4119 }
4606
4607 brdp->magic = STLI_BOARDMAGIC; 4120 brdp->magic = STLI_BOARDMAGIC;
4608 return(brdp); 4121 return brdp;
4609} 4122}
4610 4123
4611/*****************************************************************************/ 4124/*****************************************************************************/
@@ -4617,13 +4130,9 @@ static stlibrd_t *stli_allocbrd(void)
4617 4130
4618static int stli_initbrds(void) 4131static int stli_initbrds(void)
4619{ 4132{
4620 stlibrd_t *brdp, *nxtbrdp; 4133 stlibrd_t *brdp, *nxtbrdp;
4621 stlconf_t *confp; 4134 stlconf_t *confp;
4622 int i, j; 4135 int i, j;
4623
4624#ifdef DEBUG
4625 printk(KERN_DEBUG "stli_initbrds()\n");
4626#endif
4627 4136
4628 if (stli_nrbrds > STL_MAXBRDS) { 4137 if (stli_nrbrds > STL_MAXBRDS) {
4629 printk(KERN_INFO "STALLION: too many boards in configuration " 4138 printk(KERN_INFO "STALLION: too many boards in configuration "
@@ -4638,11 +4147,9 @@ static int stli_initbrds(void)
4638 */ 4147 */
4639 for (i = 0; (i < stli_nrbrds); i++) { 4148 for (i = 0; (i < stli_nrbrds); i++) {
4640 confp = &stli_brdconf[i]; 4149 confp = &stli_brdconf[i];
4641#ifdef MODULE
4642 stli_parsebrd(confp, stli_brdsp[i]); 4150 stli_parsebrd(confp, stli_brdsp[i]);
4643#endif 4151 if ((brdp = stli_allocbrd()) == NULL)
4644 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4152 return -ENOMEM;
4645 return(-ENOMEM);
4646 brdp->brdnr = i; 4153 brdp->brdnr = i;
4647 brdp->brdtype = confp->brdtype; 4154 brdp->brdtype = confp->brdtype;
4648 brdp->iobase = confp->ioaddr1; 4155 brdp->iobase = confp->ioaddr1;
@@ -4654,9 +4161,7 @@ static int stli_initbrds(void)
4654 * Static configuration table done, so now use dynamic methods to 4161 * Static configuration table done, so now use dynamic methods to
4655 * see if any more boards should be configured. 4162 * see if any more boards should be configured.
4656 */ 4163 */
4657#ifdef MODULE
4658 stli_argbrds(); 4164 stli_argbrds();
4659#endif
4660 if (STLI_EISAPROBE) 4165 if (STLI_EISAPROBE)
4661 stli_findeisabrds(); 4166 stli_findeisabrds();
4662#ifdef CONFIG_PCI 4167#ifdef CONFIG_PCI
@@ -4672,11 +4177,11 @@ static int stli_initbrds(void)
4672 if (stli_nrbrds > 1) { 4177 if (stli_nrbrds > 1) {
4673 for (i = 0; (i < stli_nrbrds); i++) { 4178 for (i = 0; (i < stli_nrbrds); i++) {
4674 brdp = stli_brds[i]; 4179 brdp = stli_brds[i];
4675 if (brdp == (stlibrd_t *) NULL) 4180 if (brdp == NULL)
4676 continue; 4181 continue;
4677 for (j = i + 1; (j < stli_nrbrds); j++) { 4182 for (j = i + 1; (j < stli_nrbrds); j++) {
4678 nxtbrdp = stli_brds[j]; 4183 nxtbrdp = stli_brds[j];
4679 if (nxtbrdp == (stlibrd_t *) NULL) 4184 if (nxtbrdp == NULL)
4680 continue; 4185 continue;
4681 if ((brdp->membase >= nxtbrdp->membase) && 4186 if ((brdp->membase >= nxtbrdp->membase) &&
4682 (brdp->membase <= (nxtbrdp->membase + 4187 (brdp->membase <= (nxtbrdp->membase +
@@ -4691,7 +4196,7 @@ static int stli_initbrds(void)
4691 if (stli_shared == 0) { 4196 if (stli_shared == 0) {
4692 for (i = 0; (i < stli_nrbrds); i++) { 4197 for (i = 0; (i < stli_nrbrds); i++) {
4693 brdp = stli_brds[i]; 4198 brdp = stli_brds[i];
4694 if (brdp == (stlibrd_t *) NULL) 4199 if (brdp == NULL)
4695 continue; 4200 continue;
4696 if (brdp->state & BST_FOUND) { 4201 if (brdp->state & BST_FOUND) {
4697 EBRDENABLE(brdp); 4202 EBRDENABLE(brdp);
@@ -4701,7 +4206,7 @@ static int stli_initbrds(void)
4701 } 4206 }
4702 } 4207 }
4703 4208
4704 return(0); 4209 return 0;
4705} 4210}
4706 4211
4707/*****************************************************************************/ 4212/*****************************************************************************/
@@ -4714,48 +4219,55 @@ static int stli_initbrds(void)
4714 4219
4715static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) 4220static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp)
4716{ 4221{
4717 unsigned long flags; 4222 unsigned long flags;
4718 void *memptr; 4223 void *memptr;
4719 stlibrd_t *brdp; 4224 stlibrd_t *brdp;
4720 int brdnr, size, n; 4225 int brdnr, size, n;
4721 4226 void *p;
4722#ifdef DEBUG 4227 loff_t off = *offp;
4723 printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n",
4724 (int) fp, (int) buf, count, (int) offp);
4725#endif
4726 4228
4727 brdnr = iminor(fp->f_dentry->d_inode); 4229 brdnr = iminor(fp->f_dentry->d_inode);
4728 if (brdnr >= stli_nrbrds) 4230 if (brdnr >= stli_nrbrds)
4729 return(-ENODEV); 4231 return -ENODEV;
4730 brdp = stli_brds[brdnr]; 4232 brdp = stli_brds[brdnr];
4731 if (brdp == (stlibrd_t *) NULL) 4233 if (brdp == NULL)
4732 return(-ENODEV); 4234 return -ENODEV;
4733 if (brdp->state == 0) 4235 if (brdp->state == 0)
4734 return(-ENODEV); 4236 return -ENODEV;
4735 if (fp->f_pos >= brdp->memsize) 4237 if (off >= brdp->memsize || off + count < off)
4736 return(0); 4238 return 0;
4737 4239
4738 size = MIN(count, (brdp->memsize - fp->f_pos)); 4240 size = MIN(count, (brdp->memsize - off));
4241
4242 /*
4243 * Copy the data a page at a time
4244 */
4245
4246 p = (void *)__get_free_page(GFP_KERNEL);
4247 if(p == NULL)
4248 return -ENOMEM;
4739 4249
4740 save_flags(flags);
4741 cli();
4742 EBRDENABLE(brdp);
4743 while (size > 0) { 4250 while (size > 0) {
4744 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4251 spin_lock_irqsave(&brd_lock, flags);
4745 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4252 EBRDENABLE(brdp);
4746 if (copy_to_user(buf, memptr, n)) { 4253 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4254 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4255 n = MIN(n, PAGE_SIZE);
4256 memcpy_fromio(p, memptr, n);
4257 EBRDDISABLE(brdp);
4258 spin_unlock_irqrestore(&brd_lock, flags);
4259 if (copy_to_user(buf, p, n)) {
4747 count = -EFAULT; 4260 count = -EFAULT;
4748 goto out; 4261 goto out;
4749 } 4262 }
4750 fp->f_pos += n; 4263 off += n;
4751 buf += n; 4264 buf += n;
4752 size -= n; 4265 size -= n;
4753 } 4266 }
4754out: 4267out:
4755 EBRDDISABLE(brdp); 4268 *offp = off;
4756 restore_flags(flags); 4269 free_page((unsigned long)p);
4757 4270 return count;
4758 return(count);
4759} 4271}
4760 4272
4761/*****************************************************************************/ 4273/*****************************************************************************/
@@ -4764,54 +4276,65 @@ out:
4764 * Code to handle an "staliomem" write operation. This device is the 4276 * Code to handle an "staliomem" write operation. This device is the
4765 * contents of the board shared memory. It is used for down loading 4277 * contents of the board shared memory. It is used for down loading
4766 * the slave image (and debugging :-) 4278 * the slave image (and debugging :-)
4279 *
4280 * FIXME: copy under lock
4767 */ 4281 */
4768 4282
4769static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) 4283static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp)
4770{ 4284{
4771 unsigned long flags; 4285 unsigned long flags;
4772 void *memptr; 4286 void *memptr;
4773 stlibrd_t *brdp; 4287 stlibrd_t *brdp;
4774 char __user *chbuf; 4288 char __user *chbuf;
4775 int brdnr, size, n; 4289 int brdnr, size, n;
4776 4290 void *p;
4777#ifdef DEBUG 4291 loff_t off = *offp;
4778 printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n",
4779 (int) fp, (int) buf, count, (int) offp);
4780#endif
4781 4292
4782 brdnr = iminor(fp->f_dentry->d_inode); 4293 brdnr = iminor(fp->f_dentry->d_inode);
4294
4783 if (brdnr >= stli_nrbrds) 4295 if (brdnr >= stli_nrbrds)
4784 return(-ENODEV); 4296 return -ENODEV;
4785 brdp = stli_brds[brdnr]; 4297 brdp = stli_brds[brdnr];
4786 if (brdp == (stlibrd_t *) NULL) 4298 if (brdp == NULL)
4787 return(-ENODEV); 4299 return -ENODEV;
4788 if (brdp->state == 0) 4300 if (brdp->state == 0)
4789 return(-ENODEV); 4301 return -ENODEV;
4790 if (fp->f_pos >= brdp->memsize) 4302 if (off >= brdp->memsize || off + count < off)
4791 return(0); 4303 return 0;
4792 4304
4793 chbuf = (char __user *) buf; 4305 chbuf = (char __user *) buf;
4794 size = MIN(count, (brdp->memsize - fp->f_pos)); 4306 size = MIN(count, (brdp->memsize - off));
4307
4308 /*
4309 * Copy the data a page at a time
4310 */
4311
4312 p = (void *)__get_free_page(GFP_KERNEL);
4313 if(p == NULL)
4314 return -ENOMEM;
4795 4315
4796 save_flags(flags);
4797 cli();
4798 EBRDENABLE(brdp);
4799 while (size > 0) { 4316 while (size > 0) {
4800 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4317 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4801 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4318 n = MIN(n, PAGE_SIZE);
4802 if (copy_from_user(memptr, chbuf, n)) { 4319 if (copy_from_user(p, chbuf, n)) {
4803 count = -EFAULT; 4320 if (count == 0)
4321 count = -EFAULT;
4804 goto out; 4322 goto out;
4805 } 4323 }
4806 fp->f_pos += n; 4324 spin_lock_irqsave(&brd_lock, flags);
4325 EBRDENABLE(brdp);
4326 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4327 memcpy_toio(memptr, p, n);
4328 EBRDDISABLE(brdp);
4329 spin_unlock_irqrestore(&brd_lock, flags);
4330 off += n;
4807 chbuf += n; 4331 chbuf += n;
4808 size -= n; 4332 size -= n;
4809 } 4333 }
4810out: 4334out:
4811 EBRDDISABLE(brdp); 4335 free_page((unsigned long) p);
4812 restore_flags(flags); 4336 *offp = off;
4813 4337 return count;
4814 return(count);
4815} 4338}
4816 4339
4817/*****************************************************************************/ 4340/*****************************************************************************/
@@ -4822,16 +4345,16 @@ out:
4822 4345
4823static int stli_getbrdstats(combrd_t __user *bp) 4346static int stli_getbrdstats(combrd_t __user *bp)
4824{ 4347{
4825 stlibrd_t *brdp; 4348 stlibrd_t *brdp;
4826 int i; 4349 int i;
4827 4350
4828 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) 4351 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
4829 return -EFAULT; 4352 return -EFAULT;
4830 if (stli_brdstats.brd >= STL_MAXBRDS) 4353 if (stli_brdstats.brd >= STL_MAXBRDS)
4831 return(-ENODEV); 4354 return -ENODEV;
4832 brdp = stli_brds[stli_brdstats.brd]; 4355 brdp = stli_brds[stli_brdstats.brd];
4833 if (brdp == (stlibrd_t *) NULL) 4356 if (brdp == NULL)
4834 return(-ENODEV); 4357 return -ENODEV;
4835 4358
4836 memset(&stli_brdstats, 0, sizeof(combrd_t)); 4359 memset(&stli_brdstats, 0, sizeof(combrd_t));
4837 stli_brdstats.brd = brdp->brdnr; 4360 stli_brdstats.brd = brdp->brdnr;
@@ -4850,7 +4373,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
4850 4373
4851 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t))) 4374 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t)))
4852 return -EFAULT; 4375 return -EFAULT;
4853 return(0); 4376 return 0;
4854} 4377}
4855 4378
4856/*****************************************************************************/ 4379/*****************************************************************************/
@@ -4861,19 +4384,19 @@ static int stli_getbrdstats(combrd_t __user *bp)
4861 4384
4862static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) 4385static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
4863{ 4386{
4864 stlibrd_t *brdp; 4387 stlibrd_t *brdp;
4865 int i; 4388 int i;
4866 4389
4867 if ((brdnr < 0) || (brdnr >= STL_MAXBRDS)) 4390 if (brdnr < 0 || brdnr >= STL_MAXBRDS)
4868 return((stliport_t *) NULL); 4391 return NULL;
4869 brdp = stli_brds[brdnr]; 4392 brdp = stli_brds[brdnr];
4870 if (brdp == (stlibrd_t *) NULL) 4393 if (brdp == NULL)
4871 return((stliport_t *) NULL); 4394 return NULL;
4872 for (i = 0; (i < panelnr); i++) 4395 for (i = 0; (i < panelnr); i++)
4873 portnr += brdp->panels[i]; 4396 portnr += brdp->panels[i];
4874 if ((portnr < 0) || (portnr >= brdp->nrports)) 4397 if ((portnr < 0) || (portnr >= brdp->nrports))
4875 return((stliport_t *) NULL); 4398 return NULL;
4876 return(brdp->ports[portnr]); 4399 return brdp->ports[portnr];
4877} 4400}
4878 4401
4879/*****************************************************************************/ 4402/*****************************************************************************/
@@ -4892,16 +4415,16 @@ static int stli_portcmdstats(stliport_t *portp)
4892 4415
4893 memset(&stli_comstats, 0, sizeof(comstats_t)); 4416 memset(&stli_comstats, 0, sizeof(comstats_t));
4894 4417
4895 if (portp == (stliport_t *) NULL) 4418 if (portp == NULL)
4896 return(-ENODEV); 4419 return -ENODEV;
4897 brdp = stli_brds[portp->brdnr]; 4420 brdp = stli_brds[portp->brdnr];
4898 if (brdp == (stlibrd_t *) NULL) 4421 if (brdp == NULL)
4899 return(-ENODEV); 4422 return -ENODEV;
4900 4423
4901 if (brdp->state & BST_STARTED) { 4424 if (brdp->state & BST_STARTED) {
4902 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, 4425 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS,
4903 &stli_cdkstats, sizeof(asystats_t), 1)) < 0) 4426 &stli_cdkstats, sizeof(asystats_t), 1)) < 0)
4904 return(rc); 4427 return rc;
4905 } else { 4428 } else {
4906 memset(&stli_cdkstats, 0, sizeof(asystats_t)); 4429 memset(&stli_cdkstats, 0, sizeof(asystats_t));
4907 } 4430 }
@@ -4912,13 +4435,12 @@ static int stli_portcmdstats(stliport_t *portp)
4912 stli_comstats.state = portp->state; 4435 stli_comstats.state = portp->state;
4913 stli_comstats.flags = portp->flags; 4436 stli_comstats.flags = portp->flags;
4914 4437
4915 save_flags(flags); 4438 spin_lock_irqsave(&brd_lock, flags);
4916 cli(); 4439 if (portp->tty != NULL) {
4917 if (portp->tty != (struct tty_struct *) NULL) {
4918 if (portp->tty->driver_data == portp) { 4440 if (portp->tty->driver_data == portp) {
4919 stli_comstats.ttystate = portp->tty->flags; 4441 stli_comstats.ttystate = portp->tty->flags;
4920 stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; 4442 stli_comstats.rxbuffered = -1;
4921 if (portp->tty->termios != (struct termios *) NULL) { 4443 if (portp->tty->termios != NULL) {
4922 stli_comstats.cflags = portp->tty->termios->c_cflag; 4444 stli_comstats.cflags = portp->tty->termios->c_cflag;
4923 stli_comstats.iflags = portp->tty->termios->c_iflag; 4445 stli_comstats.iflags = portp->tty->termios->c_iflag;
4924 stli_comstats.oflags = portp->tty->termios->c_oflag; 4446 stli_comstats.oflags = portp->tty->termios->c_oflag;
@@ -4926,7 +4448,7 @@ static int stli_portcmdstats(stliport_t *portp)
4926 } 4448 }
4927 } 4449 }
4928 } 4450 }
4929 restore_flags(flags); 4451 spin_unlock_irqrestore(&brd_lock, flags);
4930 4452
4931 stli_comstats.txtotal = stli_cdkstats.txchars; 4453 stli_comstats.txtotal = stli_cdkstats.txchars;
4932 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover; 4454 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover;
@@ -4948,7 +4470,7 @@ static int stli_portcmdstats(stliport_t *portp)
4948 stli_comstats.hwid = stli_cdkstats.hwid; 4470 stli_comstats.hwid = stli_cdkstats.hwid;
4949 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); 4471 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals);
4950 4472
4951 return(0); 4473 return 0;
4952} 4474}
4953 4475
4954/*****************************************************************************/ 4476/*****************************************************************************/
@@ -4961,8 +4483,8 @@ static int stli_portcmdstats(stliport_t *portp)
4961 4483
4962static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) 4484static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4963{ 4485{
4964 stlibrd_t *brdp; 4486 stlibrd_t *brdp;
4965 int rc; 4487 int rc;
4966 4488
4967 if (!portp) { 4489 if (!portp) {
4968 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4490 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -4992,8 +4514,8 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4992 4514
4993static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) 4515static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
4994{ 4516{
4995 stlibrd_t *brdp; 4517 stlibrd_t *brdp;
4996 int rc; 4518 int rc;
4997 4519
4998 if (!portp) { 4520 if (!portp) {
4999 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4521 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -5031,7 +4553,7 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
5031 4553
5032static int stli_getportstruct(stliport_t __user *arg) 4554static int stli_getportstruct(stliport_t __user *arg)
5033{ 4555{
5034 stliport_t *portp; 4556 stliport_t *portp;
5035 4557
5036 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t))) 4558 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t)))
5037 return -EFAULT; 4559 return -EFAULT;
@@ -5052,7 +4574,7 @@ static int stli_getportstruct(stliport_t __user *arg)
5052 4574
5053static int stli_getbrdstruct(stlibrd_t __user *arg) 4575static int stli_getbrdstruct(stlibrd_t __user *arg)
5054{ 4576{
5055 stlibrd_t *brdp; 4577 stlibrd_t *brdp;
5056 4578
5057 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t))) 4579 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t)))
5058 return -EFAULT; 4580 return -EFAULT;
@@ -5076,15 +4598,10 @@ static int stli_getbrdstruct(stlibrd_t __user *arg)
5076 4598
5077static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) 4599static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
5078{ 4600{
5079 stlibrd_t *brdp; 4601 stlibrd_t *brdp;
5080 int brdnr, rc, done; 4602 int brdnr, rc, done;
5081 void __user *argp = (void __user *)arg; 4603 void __user *argp = (void __user *)arg;
5082 4604
5083#ifdef DEBUG
5084 printk(KERN_DEBUG "stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n",
5085 (int) ip, (int) fp, cmd, (int) arg);
5086#endif
5087
5088/* 4605/*
5089 * First up handle the board independent ioctls. 4606 * First up handle the board independent ioctls.
5090 */ 4607 */
@@ -5115,7 +4632,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5115 } 4632 }
5116 4633
5117 if (done) 4634 if (done)
5118 return(rc); 4635 return rc;
5119 4636
5120/* 4637/*
5121 * Now handle the board specific ioctls. These all depend on the 4638 * Now handle the board specific ioctls. These all depend on the
@@ -5123,12 +4640,12 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5123 */ 4640 */
5124 brdnr = iminor(ip); 4641 brdnr = iminor(ip);
5125 if (brdnr >= STL_MAXBRDS) 4642 if (brdnr >= STL_MAXBRDS)
5126 return(-ENODEV); 4643 return -ENODEV;
5127 brdp = stli_brds[brdnr]; 4644 brdp = stli_brds[brdnr];
5128 if (!brdp) 4645 if (!brdp)
5129 return(-ENODEV); 4646 return -ENODEV;
5130 if (brdp->state == 0) 4647 if (brdp->state == 0)
5131 return(-ENODEV); 4648 return -ENODEV;
5132 4649
5133 switch (cmd) { 4650 switch (cmd) {
5134 case STL_BINTR: 4651 case STL_BINTR:
@@ -5152,8 +4669,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5152 rc = -ENOIOCTLCMD; 4669 rc = -ENOIOCTLCMD;
5153 break; 4670 break;
5154 } 4671 }
5155 4672 return rc;
5156 return(rc);
5157} 4673}
5158 4674
5159static struct tty_operations stli_ops = { 4675static struct tty_operations stli_ops = {
@@ -5187,6 +4703,9 @@ int __init stli_init(void)
5187 int i; 4703 int i;
5188 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); 4704 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
5189 4705
4706 spin_lock_init(&stli_lock);
4707 spin_lock_init(&brd_lock);
4708
5190 stli_initbrds(); 4709 stli_initbrds();
5191 4710
5192 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 4711 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
@@ -5196,10 +4715,6 @@ int __init stli_init(void)
5196/* 4715/*
5197 * Allocate a temporary write buffer. 4716 * Allocate a temporary write buffer.
5198 */ 4717 */
5199 stli_tmpwritebuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5200 if (!stli_tmpwritebuf)
5201 printk(KERN_ERR "STALLION: failed to allocate memory "
5202 "(size=%d)\n", STLI_TXBUFSIZE);
5203 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); 4718 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5204 if (!stli_txcookbuf) 4719 if (!stli_txcookbuf)
5205 printk(KERN_ERR "STALLION: failed to allocate memory " 4720 printk(KERN_ERR "STALLION: failed to allocate memory "
@@ -5243,7 +4758,7 @@ int __init stli_init(void)
5243 printk(KERN_ERR "STALLION: failed to register serial driver\n"); 4758 printk(KERN_ERR "STALLION: failed to register serial driver\n");
5244 return -EBUSY; 4759 return -EBUSY;
5245 } 4760 }
5246 return(0); 4761 return 0;
5247} 4762}
5248 4763
5249/*****************************************************************************/ 4764/*****************************************************************************/
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 645d9d713aec..72cfd09091e0 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -996,7 +996,6 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
996 996
997 info->session = current->signal->session; 997 info->session = current->signal->session;
998 info->pgrp = process_group(current); 998 info->pgrp = process_group(current);
999 clear_bit(TTY_DONT_FLIP, &tty->flags);
1000 999
1001 /* 1000 /*
1002 status = mxser_get_msr(info->base, 0, info->port); 1001 status = mxser_get_msr(info->base, 0, info->port);
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index b9371d5bf790..603b9ade5eb0 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
1132 * buffer, and once to drain the space from the (physical) beginning of 1132 * buffer, and once to drain the space from the (physical) beginning of
1133 * the buffer to head pointer. 1133 * the buffer to head pointer.
1134 * 1134 *
1135 * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set 1135 * Called under the tty->atomic_read_lock sem
1136 * 1136 *
1137 */ 1137 */
1138 1138
@@ -1271,7 +1271,6 @@ do_it_again:
1271 } 1271 }
1272 1272
1273 add_wait_queue(&tty->read_wait, &wait); 1273 add_wait_queue(&tty->read_wait, &wait);
1274 set_bit(TTY_DONT_FLIP, &tty->flags);
1275 while (nr) { 1274 while (nr) {
1276 /* First test for status change. */ 1275 /* First test for status change. */
1277 if (tty->packet && tty->link->ctrl_status) { 1276 if (tty->packet && tty->link->ctrl_status) {
@@ -1315,9 +1314,7 @@ do_it_again:
1315 break; 1314 break;
1316 } 1315 }
1317 n_tty_set_room(tty); 1316 n_tty_set_room(tty);
1318 clear_bit(TTY_DONT_FLIP, &tty->flags);
1319 timeout = schedule_timeout(timeout); 1317 timeout = schedule_timeout(timeout);
1320 set_bit(TTY_DONT_FLIP, &tty->flags);
1321 continue; 1318 continue;
1322 } 1319 }
1323 __set_current_state(TASK_RUNNING); 1320 __set_current_state(TASK_RUNNING);
@@ -1394,7 +1391,6 @@ do_it_again:
1394 if (time) 1391 if (time)
1395 timeout = time; 1392 timeout = time;
1396 } 1393 }
1397 clear_bit(TTY_DONT_FLIP, &tty->flags);
1398 mutex_unlock(&tty->atomic_read_lock); 1394 mutex_unlock(&tty->atomic_read_lock);
1399 remove_wait_queue(&tty->read_wait, &wait); 1395 remove_wait_queue(&tty->read_wait, &wait);
1400 1396
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 9b5a2c0e7008..0c17f61549b4 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -101,7 +101,7 @@ static void pty_unthrottle(struct tty_struct * tty)
101 * 101 *
102 * FIXME: Our pty_write method is called with our ldisc lock held but 102 * FIXME: Our pty_write method is called with our ldisc lock held but
103 * not our partners. We can't just take the other one blindly without 103 * not our partners. We can't just take the other one blindly without
104 * risking deadlocks. There is also the small matter of TTY_DONT_FLIP 104 * risking deadlocks.
105 */ 105 */
106static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count) 106static int pty_write(struct tty_struct * tty, const unsigned char *buf, int count)
107{ 107{
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index bf361a5ba70d..00b4a2187164 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -3029,6 +3029,9 @@ static int __init stl_init(void)
3029 int i; 3029 int i;
3030 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); 3030 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
3031 3031
3032 spin_lock_init(&stallion_lock);
3033 spin_lock_init(&brd_lock);
3034
3032 stl_initbrds(); 3035 stl_initbrds();
3033 3036
3034 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 3037 stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index bd74e82d8a72..8d19f7281f0b 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -267,7 +267,6 @@ static struct tty_buffer *tty_buffer_alloc(size_t size)
267 p->used = 0; 267 p->used = 0;
268 p->size = size; 268 p->size = size;
269 p->next = NULL; 269 p->next = NULL;
270 p->active = 0;
271 p->commit = 0; 270 p->commit = 0;
272 p->read = 0; 271 p->read = 0;
273 p->char_buf_ptr = (char *)(p->data); 272 p->char_buf_ptr = (char *)(p->data);
@@ -327,10 +326,9 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
327 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to 326 /* OPTIMISATION: We could keep a per tty "zero" sized buffer to
328 remove this conditional if its worth it. This would be invisible 327 remove this conditional if its worth it. This would be invisible
329 to the callers */ 328 to the callers */
330 if ((b = tty->buf.tail) != NULL) { 329 if ((b = tty->buf.tail) != NULL)
331 left = b->size - b->used; 330 left = b->size - b->used;
332 b->active = 1; 331 else
333 } else
334 left = 0; 332 left = 0;
335 333
336 if (left < size) { 334 if (left < size) {
@@ -338,12 +336,10 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
338 if ((n = tty_buffer_find(tty, size)) != NULL) { 336 if ((n = tty_buffer_find(tty, size)) != NULL) {
339 if (b != NULL) { 337 if (b != NULL) {
340 b->next = n; 338 b->next = n;
341 b->active = 0;
342 b->commit = b->used; 339 b->commit = b->used;
343 } else 340 } else
344 tty->buf.head = n; 341 tty->buf.head = n;
345 tty->buf.tail = n; 342 tty->buf.tail = n;
346 n->active = 1;
347 } else 343 } else
348 size = left; 344 size = left;
349 } 345 }
@@ -404,10 +400,8 @@ void tty_schedule_flip(struct tty_struct *tty)
404{ 400{
405 unsigned long flags; 401 unsigned long flags;
406 spin_lock_irqsave(&tty->buf.lock, flags); 402 spin_lock_irqsave(&tty->buf.lock, flags);
407 if (tty->buf.tail != NULL) { 403 if (tty->buf.tail != NULL)
408 tty->buf.tail->active = 0;
409 tty->buf.tail->commit = tty->buf.tail->used; 404 tty->buf.tail->commit = tty->buf.tail->used;
410 }
411 spin_unlock_irqrestore(&tty->buf.lock, flags); 405 spin_unlock_irqrestore(&tty->buf.lock, flags);
412 schedule_delayed_work(&tty->buf.work, 1); 406 schedule_delayed_work(&tty->buf.work, 1);
413} 407}
@@ -784,11 +778,8 @@ restart:
784 } 778 }
785 779
786 clear_bit(TTY_LDISC, &tty->flags); 780 clear_bit(TTY_LDISC, &tty->flags);
787 clear_bit(TTY_DONT_FLIP, &tty->flags); 781 if (o_tty)
788 if (o_tty) {
789 clear_bit(TTY_LDISC, &o_tty->flags); 782 clear_bit(TTY_LDISC, &o_tty->flags);
790 clear_bit(TTY_DONT_FLIP, &o_tty->flags);
791 }
792 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 783 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
793 784
794 /* 785 /*
@@ -1955,7 +1946,6 @@ static void release_dev(struct file * filp)
1955 * race with the set_ldisc code path. 1946 * race with the set_ldisc code path.
1956 */ 1947 */
1957 clear_bit(TTY_LDISC, &tty->flags); 1948 clear_bit(TTY_LDISC, &tty->flags);
1958 clear_bit(TTY_DONT_FLIP, &tty->flags);
1959 cancel_delayed_work(&tty->buf.work); 1949 cancel_delayed_work(&tty->buf.work);
1960 1950
1961 /* 1951 /*
@@ -2775,8 +2765,7 @@ static void flush_to_ldisc(void *private_)
2775 struct tty_struct *tty = (struct tty_struct *) private_; 2765 struct tty_struct *tty = (struct tty_struct *) private_;
2776 unsigned long flags; 2766 unsigned long flags;
2777 struct tty_ldisc *disc; 2767 struct tty_ldisc *disc;
2778 struct tty_buffer *tbuf; 2768 struct tty_buffer *tbuf, *head;
2779 int count;
2780 char *char_buf; 2769 char *char_buf;
2781 unsigned char *flag_buf; 2770 unsigned char *flag_buf;
2782 2771
@@ -2784,32 +2773,37 @@ static void flush_to_ldisc(void *private_)
2784 if (disc == NULL) /* !TTY_LDISC */ 2773 if (disc == NULL) /* !TTY_LDISC */
2785 return; 2774 return;
2786 2775
2787 if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
2788 /*
2789 * Do it after the next timer tick:
2790 */
2791 schedule_delayed_work(&tty->buf.work, 1);
2792 goto out;
2793 }
2794 spin_lock_irqsave(&tty->buf.lock, flags); 2776 spin_lock_irqsave(&tty->buf.lock, flags);
2795 while((tbuf = tty->buf.head) != NULL) { 2777 head = tty->buf.head;
2796 while ((count = tbuf->commit - tbuf->read) != 0) { 2778 if (head != NULL) {
2797 char_buf = tbuf->char_buf_ptr + tbuf->read; 2779 tty->buf.head = NULL;
2798 flag_buf = tbuf->flag_buf_ptr + tbuf->read; 2780 for (;;) {
2799 tbuf->read += count; 2781 int count = head->commit - head->read;
2782 if (!count) {
2783 if (head->next == NULL)
2784 break;
2785 tbuf = head;
2786 head = head->next;
2787 tty_buffer_free(tty, tbuf);
2788 continue;
2789 }
2790 if (!tty->receive_room) {
2791 schedule_delayed_work(&tty->buf.work, 1);
2792 break;
2793 }
2794 if (count > tty->receive_room)
2795 count = tty->receive_room;
2796 char_buf = head->char_buf_ptr + head->read;
2797 flag_buf = head->flag_buf_ptr + head->read;
2798 head->read += count;
2800 spin_unlock_irqrestore(&tty->buf.lock, flags); 2799 spin_unlock_irqrestore(&tty->buf.lock, flags);
2801 disc->receive_buf(tty, char_buf, flag_buf, count); 2800 disc->receive_buf(tty, char_buf, flag_buf, count);
2802 spin_lock_irqsave(&tty->buf.lock, flags); 2801 spin_lock_irqsave(&tty->buf.lock, flags);
2803 } 2802 }
2804 if (tbuf->active) 2803 tty->buf.head = head;
2805 break;
2806 tty->buf.head = tbuf->next;
2807 if (tty->buf.head == NULL)
2808 tty->buf.tail = NULL;
2809 tty_buffer_free(tty, tbuf);
2810 } 2804 }
2811 spin_unlock_irqrestore(&tty->buf.lock, flags); 2805 spin_unlock_irqrestore(&tty->buf.lock, flags);
2812out: 2806
2813 tty_ldisc_deref(disc); 2807 tty_ldisc_deref(disc);
2814} 2808}
2815 2809
@@ -2902,10 +2896,8 @@ void tty_flip_buffer_push(struct tty_struct *tty)
2902{ 2896{
2903 unsigned long flags; 2897 unsigned long flags;
2904 spin_lock_irqsave(&tty->buf.lock, flags); 2898 spin_lock_irqsave(&tty->buf.lock, flags);
2905 if (tty->buf.tail != NULL) { 2899 if (tty->buf.tail != NULL)
2906 tty->buf.tail->active = 0;
2907 tty->buf.tail->commit = tty->buf.tail->used; 2900 tty->buf.tail->commit = tty->buf.tail->used;
2908 }
2909 spin_unlock_irqrestore(&tty->buf.lock, flags); 2901 spin_unlock_irqrestore(&tty->buf.lock, flags);
2910 2902
2911 if (tty->low_latency) 2903 if (tty->low_latency)
diff --git a/drivers/char/watchdog/at91_wdt.c b/drivers/char/watchdog/at91_wdt.c
index ac83bc4b019a..00080655533d 100644
--- a/drivers/char/watchdog/at91_wdt.c
+++ b/drivers/char/watchdog/at91_wdt.c
@@ -17,14 +17,15 @@
17#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20#include <linux/platform_device.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/watchdog.h> 22#include <linux/watchdog.h>
22#include <asm/bitops.h> 23#include <asm/bitops.h>
23#include <asm/uaccess.h> 24#include <asm/uaccess.h>
24 25
25 26
26#define WDT_DEFAULT_TIME 5 /* 5 seconds */ 27#define WDT_DEFAULT_TIME 5 /* seconds */
27#define WDT_MAX_TIME 256 /* 256 seconds */ 28#define WDT_MAX_TIME 256 /* seconds */
28 29
29static int wdt_time = WDT_DEFAULT_TIME; 30static int wdt_time = WDT_DEFAULT_TIME;
30static int nowayout = WATCHDOG_NOWAYOUT; 31static int nowayout = WATCHDOG_NOWAYOUT;
@@ -32,8 +33,10 @@ static int nowayout = WATCHDOG_NOWAYOUT;
32module_param(wdt_time, int, 0); 33module_param(wdt_time, int, 0);
33MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")"); 34MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="__MODULE_STRING(WDT_DEFAULT_TIME) ")");
34 35
36#ifdef CONFIG_WATCHDOG_NOWAYOUT
35module_param(nowayout, int, 0); 37module_param(nowayout, int, 0);
36MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 38MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
39#endif
37 40
38 41
39static unsigned long at91wdt_busy; 42static unsigned long at91wdt_busy;
@@ -138,7 +141,7 @@ static int at91_wdt_ioctl(struct inode *inode, struct file *file,
138 case WDIOC_SETTIMEOUT: 141 case WDIOC_SETTIMEOUT:
139 if (get_user(new_value, p)) 142 if (get_user(new_value, p))
140 return -EFAULT; 143 return -EFAULT;
141 144
142 if (at91_wdt_settimeout(new_value)) 145 if (at91_wdt_settimeout(new_value))
143 return -EINVAL; 146 return -EINVAL;
144 147
@@ -196,27 +199,84 @@ static struct miscdevice at91wdt_miscdev = {
196 .fops = &at91wdt_fops, 199 .fops = &at91wdt_fops,
197}; 200};
198 201
199static int __init at91_wdt_init(void) 202static int __init at91wdt_probe(struct platform_device *pdev)
200{ 203{
201 int res; 204 int res;
202 205
203 /* Check that the heartbeat value is within range; if not reset to the default */ 206 if (at91wdt_miscdev.dev)
204 if (at91_wdt_settimeout(wdt_time)) { 207 return -EBUSY;
205 at91_wdt_settimeout(WDT_DEFAULT_TIME); 208 at91wdt_miscdev.dev = &pdev->dev;
206 printk(KERN_INFO "at91_wdt: wdt_time value must be 1 <= wdt_time <= 256, using %d\n", wdt_time);
207 }
208 209
209 res = misc_register(&at91wdt_miscdev); 210 res = misc_register(&at91wdt_miscdev);
210 if (res) 211 if (res)
211 return res; 212 return res;
212 213
213 printk("AT91 Watchdog Timer enabled (%d seconds, nowayout=%d)\n", wdt_time, nowayout); 214 printk("AT91 Watchdog Timer enabled (%d seconds%s)\n", wdt_time, nowayout ? ", nowayout" : "");
214 return 0; 215 return 0;
215} 216}
216 217
218static int __exit at91wdt_remove(struct platform_device *pdev)
219{
220 int res;
221
222 res = misc_deregister(&at91wdt_miscdev);
223 if (!res)
224 at91wdt_miscdev.dev = NULL;
225
226 return res;
227}
228
229static void at91wdt_shutdown(struct platform_device *pdev)
230{
231 at91_wdt_stop();
232}
233
234#ifdef CONFIG_PM
235
236static int at91wdt_suspend(struct platform_device *pdev, pm_message_t message)
237{
238 at91_wdt_stop();
239 return 0;
240}
241
242static int at91wdt_resume(struct platform_device *pdev)
243{
244 if (at91wdt_busy)
245 at91_wdt_start();
246 return 0;
247}
248
249#else
250#define at91wdt_suspend NULL
251#define at91wdt_resume NULL
252#endif
253
254static struct platform_driver at91wdt_driver = {
255 .probe = at91wdt_probe,
256 .remove = __exit_p(at91wdt_remove),
257 .shutdown = at91wdt_shutdown,
258 .suspend = at91wdt_suspend,
259 .resume = at91wdt_resume,
260 .driver = {
261 .name = "at91_wdt",
262 .owner = THIS_MODULE,
263 },
264};
265
266static int __init at91_wdt_init(void)
267{
268 /* Check that the heartbeat value is within range; if not reset to the default */
269 if (at91_wdt_settimeout(wdt_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);
272 }
273
274 return platform_driver_register(&at91wdt_driver);
275}
276
217static void __exit at91_wdt_exit(void) 277static void __exit at91_wdt_exit(void)
218{ 278{
219 misc_deregister(&at91wdt_miscdev); 279 platform_driver_unregister(&at91wdt_driver);
220} 280}
221 281
222module_init(at91_wdt_init); 282module_init(at91_wdt_init);
diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c
index fa2ba9ebe42a..bfbdbbf3c2f2 100644
--- a/drivers/char/watchdog/i8xx_tco.c
+++ b/drivers/char/watchdog/i8xx_tco.c
@@ -205,6 +205,23 @@ static int tco_timer_set_heartbeat (int t)
205 return 0; 205 return 0;
206} 206}
207 207
208static int tco_timer_get_timeleft (int *time_left)
209{
210 unsigned char val;
211
212 spin_lock(&tco_lock);
213
214 /* read the TCO Timer */
215 val = inb (TCO1_RLD);
216 val &= 0x3f;
217
218 spin_unlock(&tco_lock);
219
220 *time_left = (int)((val * 6) / 10);
221
222 return 0;
223}
224
208/* 225/*
209 * /dev/watchdog handling 226 * /dev/watchdog handling
210 */ 227 */
@@ -272,6 +289,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
272{ 289{
273 int new_options, retval = -EINVAL; 290 int new_options, retval = -EINVAL;
274 int new_heartbeat; 291 int new_heartbeat;
292 int time_left;
275 void __user *argp = (void __user *)arg; 293 void __user *argp = (void __user *)arg;
276 int __user *p = argp; 294 int __user *p = argp;
277 static struct watchdog_info ident = { 295 static struct watchdog_info ident = {
@@ -320,7 +338,7 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
320 return -EFAULT; 338 return -EFAULT;
321 339
322 if (tco_timer_set_heartbeat(new_heartbeat)) 340 if (tco_timer_set_heartbeat(new_heartbeat))
323 return -EINVAL; 341 return -EINVAL;
324 342
325 tco_timer_keepalive (); 343 tco_timer_keepalive ();
326 /* Fall */ 344 /* Fall */
@@ -329,6 +347,14 @@ static int i8xx_tco_ioctl (struct inode *inode, struct file *file,
329 case WDIOC_GETTIMEOUT: 347 case WDIOC_GETTIMEOUT:
330 return put_user(heartbeat, p); 348 return put_user(heartbeat, p);
331 349
350 case WDIOC_GETTIMELEFT:
351 {
352 if (tco_timer_get_timeleft(&time_left))
353 return -EINVAL;
354
355 return put_user(time_left, p);
356 }
357
332 default: 358 default:
333 return -ENOIOCTLCMD; 359 return -ENOIOCTLCMD;
334 } 360 }
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index 2451edbefece..1f40ecefbf72 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -21,7 +21,7 @@
21 */ 21 */
22 22
23/* 23/*
24 * A bells and whistles driver is available from: 24 * A bells and whistles driver is available from:
25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/ 25 * http://www.kernel.org/pub/linux/kernel/people/wim/pcwd/pcwd_pci/
26 * 26 *
27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/ 27 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/
@@ -390,6 +390,24 @@ static int pcipcwd_get_temperature(int *temperature)
390 return 0; 390 return 0;
391} 391}
392 392
393static int pcipcwd_get_timeleft(int *time_left)
394{
395 int msb;
396 int lsb;
397
398 /* Read the time that's left before rebooting */
399 /* Note: if the board is not yet armed then we will read 0xFFFF */
400 send_command(CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb);
401
402 *time_left = (msb << 8) + lsb;
403
404 if (debug >= VERBOSE)
405 printk(KERN_DEBUG PFX "Time left before next reboot: %d\n",
406 *time_left);
407
408 return 0;
409}
410
393/* 411/*
394 * /dev/watchdog handling 412 * /dev/watchdog handling
395 */ 413 */
@@ -512,6 +530,16 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file,
512 case WDIOC_GETTIMEOUT: 530 case WDIOC_GETTIMEOUT:
513 return put_user(heartbeat, p); 531 return put_user(heartbeat, p);
514 532
533 case WDIOC_GETTIMELEFT:
534 {
535 int time_left;
536
537 if (pcipcwd_get_timeleft(&time_left))
538 return -EFAULT;
539
540 return put_user(time_left, p);
541 }
542
515 default: 543 default:
516 return -ENOIOCTLCMD; 544 return -ENOIOCTLCMD;
517 } 545 }
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 3fdfda9324fa..0d072bed501d 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -317,6 +317,19 @@ static int usb_pcwd_get_temperature(struct usb_pcwd_private *usb_pcwd, int *temp
317 return 0; 317 return 0;
318} 318}
319 319
320static int usb_pcwd_get_timeleft(struct usb_pcwd_private *usb_pcwd, int *time_left)
321{
322 unsigned char msb, lsb;
323
324 /* Read the time that's left before rebooting */
325 /* Note: if the board is not yet armed then we will read 0xFFFF */
326 usb_pcwd_send_command(usb_pcwd, CMD_READ_WATCHDOG_TIMEOUT, &msb, &lsb);
327
328 *time_left = (msb << 8) + lsb;
329
330 return 0;
331}
332
320/* 333/*
321 * /dev/watchdog handling 334 * /dev/watchdog handling
322 */ 335 */
@@ -422,6 +435,16 @@ static int usb_pcwd_ioctl(struct inode *inode, struct file *file,
422 case WDIOC_GETTIMEOUT: 435 case WDIOC_GETTIMEOUT:
423 return put_user(heartbeat, p); 436 return put_user(heartbeat, p);
424 437
438 case WDIOC_GETTIMELEFT:
439 {
440 int time_left;
441
442 if (usb_pcwd_get_timeleft(usb_pcwd_device, &time_left))
443 return -EFAULT;
444
445 return put_user(time_left, p);
446 }
447
425 default: 448 default:
426 return -ENOIOCTLCMD; 449 return -ENOIOCTLCMD;
427 } 450 }
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 935cb2583770..26ceab1e90bb 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -505,7 +505,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
505 } 505 }
506 } 506 }
507 507
508 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ) 508 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && hwif->err_stops_fifo == 0)
509 try_to_flush_leftover_data(drive); 509 try_to_flush_leftover_data(drive);
510 510
511 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT)) 511 if (hwif->INB(IDE_STATUS_REG) & (BUSY_STAT|DRQ_STAT))
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 97a49e77a8f1..32117f0ec5c0 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -597,6 +597,10 @@ u8 eighty_ninty_three (ide_drive_t *drive)
597{ 597{
598 if(HWIF(drive)->udma_four == 0) 598 if(HWIF(drive)->udma_four == 0)
599 return 0; 599 return 0;
600
601 /* Check for SATA but only if we are ATA5 or higher */
602 if (drive->id->hw_config == 0 && (drive->id->major_rev_num & 0x7FE0))
603 return 1;
600 if (!(drive->id->hw_config & 0x6000)) 604 if (!(drive->id->hw_config & 0x6000))
601 return 0; 605 return 0;
602#ifndef CONFIG_IDEDMA_IVB 606#ifndef CONFIG_IDEDMA_IVB
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index c743e68c33aa..ff0cdc142f17 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -22,7 +22,7 @@ struct chipset_bus_clock_list_entry {
22 u8 ultra_settings; 22 u8 ultra_settings;
23}; 23};
24 24
25static struct chipset_bus_clock_list_entry aec6xxx_33_base [] = { 25static const struct chipset_bus_clock_list_entry aec6xxx_33_base [] = {
26 { XFER_UDMA_6, 0x31, 0x07 }, 26 { XFER_UDMA_6, 0x31, 0x07 },
27 { XFER_UDMA_5, 0x31, 0x06 }, 27 { XFER_UDMA_5, 0x31, 0x06 },
28 { XFER_UDMA_4, 0x31, 0x05 }, 28 { XFER_UDMA_4, 0x31, 0x05 },
@@ -42,7 +42,7 @@ static struct chipset_bus_clock_list_entry aec6xxx_33_base [] = {
42 { 0, 0x00, 0x00 } 42 { 0, 0x00, 0x00 }
43}; 43};
44 44
45static struct chipset_bus_clock_list_entry aec6xxx_34_base [] = { 45static const struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
46 { XFER_UDMA_6, 0x41, 0x06 }, 46 { XFER_UDMA_6, 0x41, 0x06 },
47 { XFER_UDMA_5, 0x41, 0x05 }, 47 { XFER_UDMA_5, 0x41, 0x05 },
48 { XFER_UDMA_4, 0x41, 0x04 }, 48 { XFER_UDMA_4, 0x41, 0x04 },
@@ -425,12 +425,12 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi
425 return d->init_setup(dev, d); 425 return d->init_setup(dev, d);
426} 426}
427 427
428static struct pci_device_id aec62xx_pci_tbl[] = { 428static const struct pci_device_id aec62xx_pci_tbl[] = {
429 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 429 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 },
430 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 430 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 },
431 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860R, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 431 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860R), 2 },
432 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, 432 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865), 3 },
433 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865R, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 433 { PCI_DEVICE(PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865R), 4 },
434 { 0, }, 434 { 0, },
435}; 435};
436MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl); 436MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl);
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 3d9c7afc8695..92b7b1549b16 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -190,14 +190,6 @@ static int cmd64x_get_info (char *buffer, char **addr, off_t offset, int count)
190#endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */ 190#endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */
191 191
192/* 192/*
193 * Registers and masks for easy access by drive index:
194 */
195#if 0
196static u8 prefetch_regs[4] = {CNTRL, CNTRL, ARTTIM23, ARTTIM23};
197static u8 prefetch_masks[4] = {CNTRL_DIS_RA0, CNTRL_DIS_RA1, ARTTIM23_DIS_RA2, ARTTIM23_DIS_RA3};
198#endif
199
200/*
201 * This routine writes the prepared setup/active/recovery counts 193 * This routine writes the prepared setup/active/recovery counts
202 * for a drive into the cmd646 chipset registers to active them. 194 * for a drive into the cmd646 chipset registers to active them.
203 */ 195 */
@@ -606,13 +598,6 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
606 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 598 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
607 class_rev &= 0xff; 599 class_rev &= 0xff;
608 600
609#ifdef __i386__
610 if (dev->resource[PCI_ROM_RESOURCE].start) {
611 pci_write_config_dword(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
612 printk(KERN_INFO "%s: ROM enabled at 0x%08lx\n", name, dev->resource[PCI_ROM_RESOURCE].start);
613 }
614#endif
615
616 switch(dev->device) { 601 switch(dev->device) {
617 case PCI_DEVICE_ID_CMD_643: 602 case PCI_DEVICE_ID_CMD_643:
618 break; 603 break;
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index acd63173199b..2c9e938dd1cd 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -338,6 +338,8 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
338 hwif->ultra_mask = 0x7f; 338 hwif->ultra_mask = 0x7f;
339 hwif->mwdma_mask = 0x07; 339 hwif->mwdma_mask = 0x07;
340 340
341 hwif->err_stops_fifo = 1;
342
341 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate; 343 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate;
342 hwif->ide_dma_lostirq = &pdcnew_ide_dma_lostirq; 344 hwif->ide_dma_lostirq = &pdcnew_ide_dma_lostirq;
343 hwif->ide_dma_timeout = &pdcnew_ide_dma_timeout; 345 hwif->ide_dma_timeout = &pdcnew_ide_dma_timeout;
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 22d17548ecdb..26bc688a1821 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -101,31 +101,6 @@ static const char *pdc_quirk_drives[] = {
101#define MC1 0x02 /* DMA"C" timing */ 101#define MC1 0x02 /* DMA"C" timing */
102#define MC0 0x01 /* DMA"C" timing */ 102#define MC0 0x01 /* DMA"C" timing */
103 103
104#if 0
105 unsigned long bibma = pci_resource_start(dev, 4);
106 u8 hi = 0, lo = 0;
107
108 u8 sc1c = inb_p((u16)bibma + 0x1c);
109 u8 sc1e = inb_p((u16)bibma + 0x1e);
110 u8 sc1f = inb_p((u16)bibma + 0x1f);
111
112 p += sprintf(p, "Host Mode : %s\n",
113 (sc1f & 0x08) ? "Tri-Stated" : "Normal");
114 p += sprintf(p, "Bus Clocking : %s\n",
115 ((sc1f & 0xC0) == 0xC0) ? "100 External" :
116 ((sc1f & 0x80) == 0x80) ? "66 External" :
117 ((sc1f & 0x40) == 0x40) ? "33 External" : "33 PCI Internal");
118 p += sprintf(p, "IO pad select : %s mA\n",
119 ((sc1c & 0x03) == 0x03) ? "10" :
120 ((sc1c & 0x02) == 0x02) ? "8" :
121 ((sc1c & 0x01) == 0x01) ? "6" :
122 ((sc1c & 0x00) == 0x00) ? "4" : "??");
123 hi = sc1e >> 4;
124 lo = sc1e & 0xf;
125 p += sprintf(p, "Status Polling Period : %d\n", hi);
126 p += sprintf(p, "Interrupt Check Status Polling Delay : %d\n", lo);
127#endif
128
129static u8 pdc202xx_ratemask (ide_drive_t *drive) 104static u8 pdc202xx_ratemask (ide_drive_t *drive)
130{ 105{
131 u8 mode; 106 u8 mode;
@@ -505,42 +480,13 @@ static void pdc202xx_reset (ide_drive_t *drive)
505 480
506 pdc202xx_reset_host(hwif); 481 pdc202xx_reset_host(hwif);
507 pdc202xx_reset_host(mate); 482 pdc202xx_reset_host(mate);
508#if 0
509 /*
510 * FIXME: Have to kick all the drives again :-/
511 * What a pain in the ACE!
512 */
513 if (hwif->present) {
514 u16 hunit = 0;
515 for (hunit = 0; hunit < MAX_DRIVES; ++hunit) {
516 ide_drive_t *hdrive = &hwif->drives[hunit];
517 if (hdrive->present) {
518 if (hwif->ide_dma_check)
519 hwif->ide_dma_check(hdrive);
520 else
521 hwif->tuneproc(hdrive, 5);
522 }
523 }
524 }
525 if (mate->present) {
526 u16 munit = 0;
527 for (munit = 0; munit < MAX_DRIVES; ++munit) {
528 ide_drive_t *mdrive = &mate->drives[munit];
529 if (mdrive->present) {
530 if (mate->ide_dma_check)
531 mate->ide_dma_check(mdrive);
532 else
533 mate->tuneproc(mdrive, 5);
534 }
535 }
536 }
537#else
538 hwif->tuneproc(drive, 5); 483 hwif->tuneproc(drive, 5);
539#endif
540} 484}
541 485
542static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, const char *name) 486static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev,
487 const char *name)
543{ 488{
489 /* This doesn't appear needed */
544 if (dev->resource[PCI_ROM_RESOURCE].start) { 490 if (dev->resource[PCI_ROM_RESOURCE].start) {
545 pci_write_config_dword(dev, PCI_ROM_ADDRESS, 491 pci_write_config_dword(dev, PCI_ROM_ADDRESS,
546 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); 492 dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE);
@@ -548,30 +494,6 @@ static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, const c
548 name, dev->resource[PCI_ROM_RESOURCE].start); 494 name, dev->resource[PCI_ROM_RESOURCE].start);
549 } 495 }
550 496
551 /*
552 * software reset - this is required because the bios
553 * will set UDMA timing on if the hdd supports it. The
554 * user may want to turn udma off. A bug in the pdc20262
555 * is that it cannot handle a downgrade in timing from
556 * UDMA to DMA. Disk accesses after issuing a set
557 * feature command will result in errors. A software
558 * reset leaves the timing registers intact,
559 * but resets the drives.
560 */
561#if 0
562 if ((dev->device == PCI_DEVICE_ID_PROMISE_20267) ||
563 (dev->device == PCI_DEVICE_ID_PROMISE_20265) ||
564 (dev->device == PCI_DEVICE_ID_PROMISE_20263) ||
565 (dev->device == PCI_DEVICE_ID_PROMISE_20262)) {
566 unsigned long high_16 = pci_resource_start(dev, 4);
567 byte udma_speed_flag = inb(high_16 + 0x001f);
568 outb(udma_speed_flag | 0x10, high_16 + 0x001f);
569 mdelay(100);
570 outb(udma_speed_flag & ~0x10, high_16 + 0x001f);
571 mdelay(2000); /* 2 seconds ?! */
572 }
573
574#endif
575 return dev->irq; 497 return dev->irq;
576} 498}
577 499
@@ -599,6 +521,8 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
599 hwif->mwdma_mask = 0x07; 521 hwif->mwdma_mask = 0x07;
600 hwif->swdma_mask = 0x07; 522 hwif->swdma_mask = 0x07;
601 523
524 hwif->err_stops_fifo = 1;
525
602 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate; 526 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate;
603 hwif->ide_dma_lostirq = &pdc202xx_ide_dma_lostirq; 527 hwif->ide_dma_lostirq = &pdc202xx_ide_dma_lostirq;
604 hwif->ide_dma_timeout = &pdc202xx_ide_dma_timeout; 528 hwif->ide_dma_timeout = &pdc202xx_ide_dma_timeout;
@@ -687,19 +611,6 @@ static int __devinit init_setup_pdc202ata4(struct pci_dev *dev,
687 "mirror fixed.\n", d->name); 611 "mirror fixed.\n", d->name);
688 } 612 }
689 } 613 }
690
691#if 0
692 if (dev->device == PCI_DEVICE_ID_PROMISE_20262)
693 if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) ||
694 (tmp & e->mask) != e->val))
695
696 if (d->enablebits[0].reg != d->enablebits[1].reg) {
697 d->enablebits[0].reg = d->enablebits[1].reg;
698 d->enablebits[0].mask = d->enablebits[1].mask;
699 d->enablebits[0].val = d->enablebits[1].val;
700 }
701#endif
702
703 return ide_setup_pci_device(dev, d); 614 return ide_setup_pci_device(dev, d);
704} 615}
705 616
@@ -714,22 +625,6 @@ static int __devinit init_setup_pdc20265(struct pci_dev *dev,
714 "attached to I2O RAID controller.\n"); 625 "attached to I2O RAID controller.\n");
715 return -ENODEV; 626 return -ENODEV;
716 } 627 }
717
718#if 0
719 {
720 u8 pri = 0, sec = 0;
721
722 if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) ||
723 (tmp & e->mask) != e->val))
724
725 if (d->enablebits[0].reg != d->enablebits[1].reg) {
726 d->enablebits[0].reg = d->enablebits[1].reg;
727 d->enablebits[0].mask = d->enablebits[1].mask;
728 d->enablebits[0].val = d->enablebits[1].val;
729 }
730 }
731#endif
732
733 return ide_setup_pci_device(dev, d); 628 return ide_setup_pci_device(dev, d);
734} 629}
735 630
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 24e21b2838c1..778b82ae964d 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -395,7 +395,6 @@ static int sc1200_resume (struct pci_dev *dev)
395{ 395{
396 ide_hwif_t *hwif = NULL; 396 ide_hwif_t *hwif = NULL;
397 397
398printk("SC1200: resume\n");
399 pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state 398 pci_set_power_state(dev, PCI_D0); // bring chip back from sleep state
400 dev->current_state = PM_EVENT_ON; 399 dev->current_state = PM_EVENT_ON;
401 pci_enable_device(dev); 400 pci_enable_device(dev);
@@ -405,7 +404,6 @@ printk("SC1200: resume\n");
405 while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) { 404 while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) {
406 unsigned int basereg, r, d, format; 405 unsigned int basereg, r, d, format;
407 sc1200_saved_state_t *ss = (sc1200_saved_state_t *)hwif->config_data; 406 sc1200_saved_state_t *ss = (sc1200_saved_state_t *)hwif->config_data;
408printk("%s: SC1200: resume\n", hwif->name);
409 407
410 // 408 //
411 // Restore timing registers: this may be unnecessary if BIOS also does it 409 // Restore timing registers: this may be unnecessary if BIOS also does it
@@ -493,7 +491,7 @@ static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_devic
493} 491}
494 492
495static struct pci_device_id sc1200_pci_tbl[] = { 493static struct pci_device_id sc1200_pci_tbl[] = {
496 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 494 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE), 0},
497 { 0, }, 495 { 0, },
498}; 496};
499MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl); 497MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl);
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 0d3073f4eab4..5100b827a935 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -123,11 +123,11 @@ static u8 svwks_csb_check (struct pci_dev *dev)
123} 123}
124static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed) 124static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
125{ 125{
126 u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; 126 static const u8 udma_modes[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
127 u8 dma_modes[] = { 0x77, 0x21, 0x20 }; 127 static const u8 dma_modes[] = { 0x77, 0x21, 0x20 };
128 u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 }; 128 static const u8 pio_modes[] = { 0x5d, 0x47, 0x34, 0x22, 0x20 };
129 u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 }; 129 static const u8 drive_pci[] = { 0x41, 0x40, 0x43, 0x42 };
130 u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 }; 130 static const u8 drive_pci2[] = { 0x45, 0x44, 0x47, 0x46 };
131 131
132 ide_hwif_t *hwif = HWIF(drive); 132 ide_hwif_t *hwif = HWIF(drive);
133 struct pci_dev *dev = hwif->pci_dev; 133 struct pci_dev *dev = hwif->pci_dev;
@@ -392,16 +392,6 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha
392 } 392 }
393 outb_p(0x06, 0x0c00); 393 outb_p(0x06, 0x0c00);
394 dev->irq = inb_p(0x0c01); 394 dev->irq = inb_p(0x0c01);
395#if 0
396 printk("%s: device class (0x%04x)\n",
397 name, dev->class);
398 if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE) {
399 dev->class &= ~0x000F0F00;
400 // dev->class |= ~0x00000400;
401 dev->class |= ~0x00010100;
402 /**/
403 }
404#endif
405 } else { 395 } else {
406 struct pci_dev * findev = NULL; 396 struct pci_dev * findev = NULL;
407 u8 reg41 = 0; 397 u8 reg41 = 0;
@@ -452,7 +442,7 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha
452 pci_write_config_byte(dev, 0x5A, btr); 442 pci_write_config_byte(dev, 0x5A, btr);
453 } 443 }
454 444
455 return (dev->irq) ? dev->irq : 0; 445 return dev->irq;
456} 446}
457 447
458static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif) 448static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif)
@@ -500,11 +490,6 @@ static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif)
500{ 490{
501 struct pci_dev *dev = hwif->pci_dev; 491 struct pci_dev *dev = hwif->pci_dev;
502 492
503 /* Per Specified Design by OEM, and ASIC Architect */
504 if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
505 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
506 return 1;
507
508 /* Server Works */ 493 /* Server Works */
509 if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS) 494 if (dev->subsystem_vendor == PCI_VENDOR_ID_SERVERWORKS)
510 return ata66_svwks_svwks (hwif); 495 return ata66_svwks_svwks (hwif);
@@ -517,10 +502,14 @@ static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif)
517 if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN) 502 if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN)
518 return ata66_svwks_cobalt (hwif); 503 return ata66_svwks_cobalt (hwif);
519 504
505 /* Per Specified Design by OEM, and ASIC Architect */
506 if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
507 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
508 return 1;
509
520 return 0; 510 return 0;
521} 511}
522 512
523#undef CAN_SW_DMA
524static void __devinit init_hwif_svwks (ide_hwif_t *hwif) 513static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
525{ 514{
526 u8 dma_stat = 0; 515 u8 dma_stat = 0;
@@ -537,9 +526,6 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
537 hwif->ultra_mask = 0x3f; 526 hwif->ultra_mask = 0x3f;
538 527
539 hwif->mwdma_mask = 0x07; 528 hwif->mwdma_mask = 0x07;
540#ifdef CAN_SW_DMA
541 hwif->swdma_mask = 0x07;
542#endif /* CAN_SW_DMA */
543 529
544 hwif->autodma = 0; 530 hwif->autodma = 0;
545 531
@@ -562,8 +548,6 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
562 hwif->drives[1].autodma = (dma_stat & 0x40); 548 hwif->drives[1].autodma = (dma_stat & 0x40);
563 hwif->drives[0].autotune = (!(dma_stat & 0x20)); 549 hwif->drives[0].autotune = (!(dma_stat & 0x20));
564 hwif->drives[1].autotune = (!(dma_stat & 0x40)); 550 hwif->drives[1].autotune = (!(dma_stat & 0x40));
565// hwif->drives[0].autodma = hwif->autodma;
566// hwif->drives[1].autodma = hwif->autodma;
567} 551}
568 552
569/* 553/*
@@ -593,11 +577,6 @@ static int __devinit init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d)
593 if (dev->resource[0].start == 0x01f1) 577 if (dev->resource[0].start == 0x01f1)
594 d->bootable = ON_BOARD; 578 d->bootable = ON_BOARD;
595 } 579 }
596#if 0
597 if ((IDE_PCI_DEVID_EQ(d->devid, DEVID_CSB6) &&
598 (!(PCI_FUNC(dev->devfn) & 1)))
599 d->autodma = AUTODMA;
600#endif
601 580
602 d->channels = ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE || 581 d->channels = ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE ||
603 dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) && 582 dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) &&
@@ -671,11 +650,11 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device
671} 650}
672 651
673static struct pci_device_id svwks_pci_tbl[] = { 652static struct pci_device_id svwks_pci_tbl[] = {
674 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 653 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0},
675 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 654 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE), 1},
676 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 655 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE), 2},
677 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 656 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2), 3},
678 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 657 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE), 4},
679 { 0, }, 658 { 0, },
680}; 659};
681MODULE_DEVICE_TABLE(pci, svwks_pci_tbl); 660MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index f1ca154dd52c..72dade14c725 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -38,9 +38,6 @@
38 38
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#undef SIIMAGE_VIRTUAL_DMAPIO
42#undef SIIMAGE_LARGE_DMA
43
44/** 41/**
45 * pdev_is_sata - check if device is SATA 42 * pdev_is_sata - check if device is SATA
46 * @pdev: PCI device to check 43 * @pdev: PCI device to check
@@ -461,36 +458,6 @@ static int siimage_io_ide_dma_test_irq (ide_drive_t *drive)
461 return 0; 458 return 0;
462} 459}
463 460
464#if 0
465/**
466 * siimage_mmio_ide_dma_count - DMA bytes done
467 * @drive
468 *
469 * If we are doing VDMA the CMD680 requires a little bit
470 * of more careful handling and we have to read the counts
471 * off ourselves. For non VDMA life is normal.
472 */
473
474static int siimage_mmio_ide_dma_count (ide_drive_t *drive)
475{
476#ifdef SIIMAGE_VIRTUAL_DMAPIO
477 struct request *rq = HWGROUP(drive)->rq;
478 ide_hwif_t *hwif = HWIF(drive);
479 u32 count = (rq->nr_sectors * SECTOR_SIZE);
480 u32 rcount = 0;
481 unsigned long addr = siimage_selreg(hwif, 0x1C);
482
483 hwif->OUTL(count, addr);
484 rcount = hwif->INL(addr);
485
486 printk("\n%s: count = %d, rcount = %d, nr_sectors = %lu\n",
487 drive->name, count, rcount, rq->nr_sectors);
488
489#endif /* SIIMAGE_VIRTUAL_DMAPIO */
490 return __ide_dma_count(drive);
491}
492#endif
493
494/** 461/**
495 * siimage_mmio_ide_dma_test_irq - check we caused an IRQ 462 * siimage_mmio_ide_dma_test_irq - check we caused an IRQ
496 * @drive: drive we are testing 463 * @drive: drive we are testing
@@ -512,12 +479,10 @@ static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
512 u32 sata_error = hwif->INL(SATA_ERROR_REG); 479 u32 sata_error = hwif->INL(SATA_ERROR_REG);
513 hwif->OUTL(sata_error, SATA_ERROR_REG); 480 hwif->OUTL(sata_error, SATA_ERROR_REG);
514 watchdog = (sata_error & 0x00680000) ? 1 : 0; 481 watchdog = (sata_error & 0x00680000) ? 1 : 0;
515#if 1
516 printk(KERN_WARNING "%s: sata_error = 0x%08x, " 482 printk(KERN_WARNING "%s: sata_error = 0x%08x, "
517 "watchdog = %d, %s\n", 483 "watchdog = %d, %s\n",
518 drive->name, sata_error, watchdog, 484 drive->name, sata_error, watchdog,
519 __FUNCTION__); 485 __FUNCTION__);
520#endif
521 486
522 } else { 487 } else {
523 watchdog = (ext_stat & 0x8000) ? 1 : 0; 488 watchdog = (ext_stat & 0x8000) ? 1 : 0;
@@ -863,7 +828,7 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, const ch
863 * time. 828 * time.
864 * 829 *
865 * The hardware supports buffered taskfiles and also some rather nice 830 * The hardware supports buffered taskfiles and also some rather nice
866 * extended PRD tables. Unfortunately right now we don't. 831 * extended PRD tables. For better SI3112 support use the libata driver
867 */ 832 */
868 833
869static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) 834static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
@@ -900,9 +865,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
900 * so we can't currently use it sanely since we want to 865 * so we can't currently use it sanely since we want to
901 * use LBA48 mode. 866 * use LBA48 mode.
902 */ 867 */
903// base += 0x10;
904// hwif->no_lba48 = 1;
905
906 hw.io_ports[IDE_DATA_OFFSET] = base; 868 hw.io_ports[IDE_DATA_OFFSET] = base;
907 hw.io_ports[IDE_ERROR_OFFSET] = base + 1; 869 hw.io_ports[IDE_ERROR_OFFSET] = base + 1;
908 hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2; 870 hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2;
@@ -936,15 +898,8 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
936 898
937 base = (unsigned long) addr; 899 base = (unsigned long) addr;
938 900
939#ifdef SIIMAGE_LARGE_DMA
940/* Watch the brackets - even Ken and Dennis get some language design wrong */
941 hwif->dma_base = base + (ch ? 0x18 : 0x10);
942 hwif->dma_base2 = base + (ch ? 0x08 : 0x00);
943 hwif->dma_prdtable = hwif->dma_base2 + 4;
944#else /* ! SIIMAGE_LARGE_DMA */
945 hwif->dma_base = base + (ch ? 0x08 : 0x00); 901 hwif->dma_base = base + (ch ? 0x08 : 0x00);
946 hwif->dma_base2 = base + (ch ? 0x18 : 0x10); 902 hwif->dma_base2 = base + (ch ? 0x18 : 0x10);
947#endif /* SIIMAGE_LARGE_DMA */
948 hwif->mmio = 2; 903 hwif->mmio = 2;
949} 904}
950 905
@@ -1052,9 +1007,16 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
1052 hwif->reset_poll = &siimage_reset_poll; 1007 hwif->reset_poll = &siimage_reset_poll;
1053 hwif->pre_reset = &siimage_pre_reset; 1008 hwif->pre_reset = &siimage_pre_reset;
1054 1009
1055 if(is_sata(hwif)) 1010 if(is_sata(hwif)) {
1011 static int first = 1;
1012
1056 hwif->busproc = &siimage_busproc; 1013 hwif->busproc = &siimage_busproc;
1057 1014
1015 if (first) {
1016 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n");
1017 first = 0;
1018 }
1019 }
1058 if (!hwif->dma_base) { 1020 if (!hwif->dma_base) {
1059 hwif->drives[0].autotune = 1; 1021 hwif->drives[0].autotune = 1;
1060 hwif->drives[1].autotune = 1; 1022 hwif->drives[1].autotune = 1;
@@ -1121,10 +1083,10 @@ static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_devi
1121} 1083}
1122 1084
1123static struct pci_device_id siimage_pci_tbl[] = { 1085static struct pci_device_id siimage_pci_tbl[] = {
1124 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1086 { PCI_DEVICE(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680), 0},
1125#ifdef CONFIG_BLK_DEV_IDE_SATA 1087#ifdef CONFIG_BLK_DEV_IDE_SATA
1126 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 1088 { PCI_DEVICE(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112), 1},
1127 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 1089 { PCI_DEVICE(PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA), 2},
1128#endif 1090#endif
1129 { 0, }, 1091 { 0, },
1130}; 1092};
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 8a5c7b286b2b..900301e43818 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -447,7 +447,6 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
447 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n", 447 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
448 hwif->name, rev); 448 hwif->name, rev);
449 } else { 449 } else {
450#ifdef CONFIG_BLK_DEV_IDEDMA
451 dma_state |= 0x60; 450 dma_state |= 0x60;
452 451
453 hwif->atapi_dma = 1; 452 hwif->atapi_dma = 1;
@@ -468,7 +467,6 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
468 467
469 if (hwif->mate) 468 if (hwif->mate)
470 hwif->serialized = hwif->mate->serialized = 1; 469 hwif->serialized = hwif->mate->serialized = 1;
471#endif /* CONFIG_BLK_DEV_IDEDMA */
472 } 470 }
473 hwif->OUTB(dma_state, hwif->dma_base + 2); 471 hwif->OUTB(dma_state, hwif->dma_base + 2);
474} 472}
@@ -489,7 +487,7 @@ static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_dev
489} 487}
490 488
491static struct pci_device_id sl82c105_pci_tbl[] = { 489static struct pci_device_id sl82c105_pci_tbl[] = {
492 { PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 490 { PCI_DEVICE(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105), 0},
493 { 0, }, 491 { 0, },
494}; 492};
495MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl); 493MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl);
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index 5112c726633b..0968f6bc669a 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -72,7 +72,8 @@ static void slc90e66_tune_drive (ide_drive_t *drive, u8 pio)
72 u16 master_data; 72 u16 master_data;
73 u8 slave_data; 73 u8 slave_data;
74 /* ISP RTC */ 74 /* ISP RTC */
75 u8 timings[][2] = { { 0, 0 }, 75 static const u8 timings[][2]= {
76 { 0, 0 },
76 { 0, 0 }, 77 { 0, 0 },
77 { 1, 0 }, 78 { 1, 0 },
78 { 2, 1 }, 79 { 2, 1 },
@@ -119,7 +120,6 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
119 pci_read_config_word(dev, 0x4a, &reg4a); 120 pci_read_config_word(dev, 0x4a, &reg4a);
120 121
121 switch(speed) { 122 switch(speed) {
122#ifdef CONFIG_BLK_DEV_IDEDMA
123 case XFER_UDMA_4: u_speed = 4 << (drive->dn * 4); break; 123 case XFER_UDMA_4: u_speed = 4 << (drive->dn * 4); break;
124 case XFER_UDMA_3: u_speed = 3 << (drive->dn * 4); break; 124 case XFER_UDMA_3: u_speed = 3 << (drive->dn * 4); break;
125 case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break; 125 case XFER_UDMA_2: u_speed = 2 << (drive->dn * 4); break;
@@ -128,7 +128,6 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
128 case XFER_MW_DMA_2: 128 case XFER_MW_DMA_2:
129 case XFER_MW_DMA_1: 129 case XFER_MW_DMA_1:
130 case XFER_SW_DMA_2: break; 130 case XFER_SW_DMA_2: break;
131#endif /* CONFIG_BLK_DEV_IDEDMA */
132 case XFER_PIO_4: 131 case XFER_PIO_4:
133 case XFER_PIO_3: 132 case XFER_PIO_3:
134 case XFER_PIO_2: 133 case XFER_PIO_2:
@@ -156,7 +155,6 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
156 return (ide_config_drive_speed(drive, speed)); 155 return (ide_config_drive_speed(drive, speed));
157} 156}
158 157
159#ifdef CONFIG_BLK_DEV_IDEDMA
160static int slc90e66_config_drive_for_dma (ide_drive_t *drive) 158static int slc90e66_config_drive_for_dma (ide_drive_t *drive)
161{ 159{
162 u8 speed = ide_dma_speed(drive, slc90e66_ratemask(drive)); 160 u8 speed = ide_dma_speed(drive, slc90e66_ratemask(drive));
@@ -194,7 +192,6 @@ fast_ata_pio:
194 /* IORDY not supported */ 192 /* IORDY not supported */
195 return 0; 193 return 0;
196} 194}
197#endif /* CONFIG_BLK_DEV_IDEDMA */
198 195
199static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) 196static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
200{ 197{
@@ -222,7 +219,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
222 hwif->mwdma_mask = 0x07; 219 hwif->mwdma_mask = 0x07;
223 hwif->swdma_mask = 0x07; 220 hwif->swdma_mask = 0x07;
224 221
225#ifdef CONFIG_BLK_DEV_IDEDMA
226 if (!(hwif->udma_four)) 222 if (!(hwif->udma_four))
227 /* bit[0(1)]: 0:80, 1:40 */ 223 /* bit[0(1)]: 0:80, 1:40 */
228 hwif->udma_four = (reg47 & mask) ? 0 : 1; 224 hwif->udma_four = (reg47 & mask) ? 0 : 1;
@@ -232,7 +228,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
232 hwif->autodma = 1; 228 hwif->autodma = 1;
233 hwif->drives[0].autodma = hwif->autodma; 229 hwif->drives[0].autodma = hwif->autodma;
234 hwif->drives[1].autodma = hwif->autodma; 230 hwif->drives[1].autodma = hwif->autodma;
235#endif /* !CONFIG_BLK_DEV_IDEDMA */
236} 231}
237 232
238static ide_pci_device_t slc90e66_chipset __devinitdata = { 233static ide_pci_device_t slc90e66_chipset __devinitdata = {
@@ -250,7 +245,7 @@ static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_dev
250} 245}
251 246
252static struct pci_device_id slc90e66_pci_tbl[] = { 247static struct pci_device_id slc90e66_pci_tbl[] = {
253 { PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 248 { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1), 0},
254 { 0, }, 249 { 0, },
255}; 250};
256MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl); 251MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl);
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index 6f31f054d1bb..5080e15c6d30 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -584,7 +584,7 @@ static struct db9 __init *db9_probe(int parport, int mode)
584 goto err_out; 584 goto err_out;
585 } 585 }
586 586
587 if (db9_mode[mode].bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) { 587 if (db9_mode->bidirectional && !(pp->modes & PARPORT_MODE_TRISTATE)) {
588 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n"); 588 printk(KERN_ERR "db9.c: specified parport is not bidirectional\n");
589 err = -EINVAL; 589 err = -EINVAL;
590 goto err_put_pp; 590 goto err_put_pp;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ffde8f86e0fb..ce1f10e8984b 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -459,7 +459,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
459 } 459 }
460 460
461 input_regs(dev, regs); 461 input_regs(dev, regs);
462 input_report_key(dev, keycode, value); 462 input_event(dev, EV_KEY, keycode, value);
463 input_sync(dev); 463 input_sync(dev);
464 464
465 if (value && add_release_event) { 465 if (value && add_release_event) {
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index e4e5be111c96..ccf0faeee5c1 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -285,6 +285,15 @@ static struct key_entry keymap_fujitsu_n3510[] = {
285 { KE_END, 0 } 285 { KE_END, 0 }
286}; 286};
287 287
288static struct key_entry keymap_wistron_ms2111[] = {
289 { KE_KEY, 0x11, KEY_PROG1 },
290 { KE_KEY, 0x12, KEY_PROG2 },
291 { KE_KEY, 0x13, KEY_PROG3 },
292 { KE_KEY, 0x31, KEY_MAIL },
293 { KE_KEY, 0x36, KEY_WWW },
294 { KE_END, 0 }
295};
296
288static struct key_entry keymap_wistron_ms2141[] = { 297static struct key_entry keymap_wistron_ms2141[] = {
289 { KE_KEY, 0x11, KEY_PROG1 }, 298 { KE_KEY, 0x11, KEY_PROG1 },
290 { KE_KEY, 0x12, KEY_PROG2 }, 299 { KE_KEY, 0x12, KEY_PROG2 },
@@ -326,6 +335,7 @@ static struct key_entry keymap_aopen_1559as[] = {
326 { KE_WIFI, 0x30, 0 }, 335 { KE_WIFI, 0x30, 0 },
327 { KE_KEY, 0x31, KEY_MAIL }, 336 { KE_KEY, 0x31, KEY_MAIL },
328 { KE_KEY, 0x36, KEY_WWW }, 337 { KE_KEY, 0x36, KEY_WWW },
338 { KE_END, 0 },
329}; 339};
330 340
331/* 341/*
@@ -388,6 +398,15 @@ static struct dmi_system_id dmi_ids[] = {
388 }, 398 },
389 .driver_data = keymap_aopen_1559as 399 .driver_data = keymap_aopen_1559as
390 }, 400 },
401 {
402 .callback = dmi_matched,
403 .ident = "Medion MD 9783",
404 .matches = {
405 DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
406 DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"),
407 },
408 .driver_data = keymap_wistron_ms2111
409 },
391 { NULL, } 410 { NULL, }
392}; 411};
393 412
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index bccff400b198..f2fc81a9074d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -162,6 +162,16 @@ config RTC_DRV_PCF8583
162 This driver can also be built as a module. If so, the module 162 This driver can also be built as a module. If so, the module
163 will be called rtc-pcf8583. 163 will be called rtc-pcf8583.
164 164
165config RTC_DRV_RS5C348
166 tristate "Ricoh RS5C348A/B"
167 depends on RTC_CLASS && SPI
168 help
169 If you say yes here you get support for the
170 Ricoh RS5C348A and RS5C348B RTC chips.
171
172 This driver can also be built as a module. If so, the module
173 will be called rtc-rs5c348.
174
165config RTC_DRV_RS5C372 175config RTC_DRV_RS5C372
166 tristate "Ricoh RS5C372A/B" 176 tristate "Ricoh RS5C372A/B"
167 depends on RTC_CLASS && I2C 177 depends on RTC_CLASS && I2C
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 900d210dd1a2..da5e38774e13 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
19obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 19obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
20obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 20obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
21obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o 21obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
22obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
22obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o 23obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
23obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o 24obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o
24obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o 25obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
new file mode 100644
index 000000000000..0964d1dba925
--- /dev/null
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -0,0 +1,246 @@
1/*
2 * A SPI driver for the Ricoh RS5C348 RTC
3 *
4 * Copyright (C) 2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp>
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 * The board specific init code should provide characteristics of this
11 * device:
12 * Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS
13 */
14
15#include <linux/bcd.h>
16#include <linux/delay.h>
17#include <linux/device.h>
18#include <linux/errno.h>
19#include <linux/init.h>
20#include <linux/kernel.h>
21#include <linux/string.h>
22#include <linux/rtc.h>
23#include <linux/workqueue.h>
24#include <linux/spi/spi.h>
25
26#define DRV_VERSION "0.1"
27
28#define RS5C348_REG_SECS 0
29#define RS5C348_REG_MINS 1
30#define RS5C348_REG_HOURS 2
31#define RS5C348_REG_WDAY 3
32#define RS5C348_REG_DAY 4
33#define RS5C348_REG_MONTH 5
34#define RS5C348_REG_YEAR 6
35#define RS5C348_REG_CTL1 14
36#define RS5C348_REG_CTL2 15
37
38#define RS5C348_SECS_MASK 0x7f
39#define RS5C348_MINS_MASK 0x7f
40#define RS5C348_HOURS_MASK 0x3f
41#define RS5C348_WDAY_MASK 0x03
42#define RS5C348_DAY_MASK 0x3f
43#define RS5C348_MONTH_MASK 0x1f
44
45#define RS5C348_BIT_PM 0x20 /* REG_HOURS */
46#define RS5C348_BIT_Y2K 0x80 /* REG_MONTH */
47#define RS5C348_BIT_24H 0x20 /* REG_CTL1 */
48#define RS5C348_BIT_XSTP 0x10 /* REG_CTL2 */
49#define RS5C348_BIT_VDET 0x40 /* REG_CTL2 */
50
51#define RS5C348_CMD_W(addr) (((addr) << 4) | 0x08) /* single write */
52#define RS5C348_CMD_R(addr) (((addr) << 4) | 0x0c) /* single read */
53#define RS5C348_CMD_MW(addr) (((addr) << 4) | 0x00) /* burst write */
54#define RS5C348_CMD_MR(addr) (((addr) << 4) | 0x04) /* burst read */
55
56struct rs5c348_plat_data {
57 struct rtc_device *rtc;
58 int rtc_24h;
59};
60
61static int
62rs5c348_rtc_set_time(struct device *dev, struct rtc_time *tm)
63{
64 struct spi_device *spi = to_spi_device(dev);
65 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
66 u8 txbuf[5+7], *txp;
67 int ret;
68
69 /* Transfer 5 bytes before writing SEC. This gives 31us for carry. */
70 txp = txbuf;
71 txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
72 txbuf[1] = 0; /* dummy */
73 txbuf[2] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
74 txbuf[3] = 0; /* dummy */
75 txbuf[4] = RS5C348_CMD_MW(RS5C348_REG_SECS); /* cmd, sec, ... */
76 txp = &txbuf[5];
77 txp[RS5C348_REG_SECS] = BIN2BCD(tm->tm_sec);
78 txp[RS5C348_REG_MINS] = BIN2BCD(tm->tm_min);
79 if (pdata->rtc_24h) {
80 txp[RS5C348_REG_HOURS] = BIN2BCD(tm->tm_hour);
81 } else {
82 /* hour 0 is AM12, noon is PM12 */
83 txp[RS5C348_REG_HOURS] = BIN2BCD((tm->tm_hour + 11) % 12 + 1) |
84 (tm->tm_hour >= 12 ? RS5C348_BIT_PM : 0);
85 }
86 txp[RS5C348_REG_WDAY] = BIN2BCD(tm->tm_wday);
87 txp[RS5C348_REG_DAY] = BIN2BCD(tm->tm_mday);
88 txp[RS5C348_REG_MONTH] = BIN2BCD(tm->tm_mon + 1) |
89 (tm->tm_year >= 100 ? RS5C348_BIT_Y2K : 0);
90 txp[RS5C348_REG_YEAR] = BIN2BCD(tm->tm_year % 100);
91 /* write in one transfer to avoid data inconsistency */
92 ret = spi_write_then_read(spi, txbuf, sizeof(txbuf), NULL, 0);
93 udelay(62); /* Tcsr 62us */
94 return ret;
95}
96
97static int
98rs5c348_rtc_read_time(struct device *dev, struct rtc_time *tm)
99{
100 struct spi_device *spi = to_spi_device(dev);
101 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
102 u8 txbuf[5], rxbuf[7];
103 int ret;
104
105 /* Transfer 5 byte befores reading SEC. This gives 31us for carry. */
106 txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
107 txbuf[1] = 0; /* dummy */
108 txbuf[2] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */
109 txbuf[3] = 0; /* dummy */
110 txbuf[4] = RS5C348_CMD_MR(RS5C348_REG_SECS); /* cmd, sec, ... */
111
112 /* read in one transfer to avoid data inconsistency */
113 ret = spi_write_then_read(spi, txbuf, sizeof(txbuf),
114 rxbuf, sizeof(rxbuf));
115 udelay(62); /* Tcsr 62us */
116 if (ret < 0)
117 return ret;
118
119 tm->tm_sec = BCD2BIN(rxbuf[RS5C348_REG_SECS] & RS5C348_SECS_MASK);
120 tm->tm_min = BCD2BIN(rxbuf[RS5C348_REG_MINS] & RS5C348_MINS_MASK);
121 tm->tm_hour = BCD2BIN(rxbuf[RS5C348_REG_HOURS] & RS5C348_HOURS_MASK);
122 if (!pdata->rtc_24h) {
123 tm->tm_hour %= 12;
124 if (rxbuf[RS5C348_REG_HOURS] & RS5C348_BIT_PM)
125 tm->tm_hour += 12;
126 }
127 tm->tm_wday = BCD2BIN(rxbuf[RS5C348_REG_WDAY] & RS5C348_WDAY_MASK);
128 tm->tm_mday = BCD2BIN(rxbuf[RS5C348_REG_DAY] & RS5C348_DAY_MASK);
129 tm->tm_mon =
130 BCD2BIN(rxbuf[RS5C348_REG_MONTH] & RS5C348_MONTH_MASK) - 1;
131 /* year is 1900 + tm->tm_year */
132 tm->tm_year = BCD2BIN(rxbuf[RS5C348_REG_YEAR]) +
133 ((rxbuf[RS5C348_REG_MONTH] & RS5C348_BIT_Y2K) ? 100 : 0);
134
135 if (rtc_valid_tm(tm) < 0) {
136 dev_err(&spi->dev, "retrieved date/time is not valid.\n");
137 rtc_time_to_tm(0, tm);
138 }
139
140 return 0;
141}
142
143static struct rtc_class_ops rs5c348_rtc_ops = {
144 .read_time = rs5c348_rtc_read_time,
145 .set_time = rs5c348_rtc_set_time,
146};
147
148static struct spi_driver rs5c348_driver;
149
150static int __devinit rs5c348_probe(struct spi_device *spi)
151{
152 int ret;
153 struct rtc_device *rtc;
154 struct rs5c348_plat_data *pdata;
155
156 pdata = kzalloc(sizeof(struct rs5c348_plat_data), GFP_KERNEL);
157 if (!pdata)
158 return -ENOMEM;
159 spi->dev.platform_data = pdata;
160
161 /* Check D7 of SECOND register */
162 ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_SECS));
163 if (ret < 0 || (ret & 0x80)) {
164 dev_err(&spi->dev, "not found.\n");
165 goto kfree_exit;
166 }
167
168 dev_info(&spi->dev, "chip found, driver version " DRV_VERSION "\n");
169 dev_info(&spi->dev, "spiclk %u KHz.\n",
170 (spi->max_speed_hz + 500) / 1000);
171
172 /* turn RTC on if it was not on */
173 ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL2));
174 if (ret < 0)
175 goto kfree_exit;
176 if (ret & (RS5C348_BIT_XSTP | RS5C348_BIT_VDET)) {
177 u8 buf[2];
178 if (ret & RS5C348_BIT_VDET)
179 dev_warn(&spi->dev, "voltage-low detected.\n");
180 buf[0] = RS5C348_CMD_W(RS5C348_REG_CTL2);
181 buf[1] = 0;
182 ret = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0);
183 if (ret < 0)
184 goto kfree_exit;
185 }
186
187 ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL1));
188 if (ret < 0)
189 goto kfree_exit;
190 if (ret & RS5C348_BIT_24H)
191 pdata->rtc_24h = 1;
192
193 rtc = rtc_device_register(rs5c348_driver.driver.name, &spi->dev,
194 &rs5c348_rtc_ops, THIS_MODULE);
195
196 if (IS_ERR(rtc)) {
197 ret = PTR_ERR(rtc);
198 goto kfree_exit;
199 }
200
201 pdata->rtc = rtc;
202
203 return 0;
204 kfree_exit:
205 kfree(pdata);
206 return ret;
207}
208
209static int __devexit rs5c348_remove(struct spi_device *spi)
210{
211 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
212 struct rtc_device *rtc = pdata->rtc;
213
214 if (rtc)
215 rtc_device_unregister(rtc);
216 kfree(pdata);
217 return 0;
218}
219
220static struct spi_driver rs5c348_driver = {
221 .driver = {
222 .name = "rs5c348",
223 .bus = &spi_bus_type,
224 .owner = THIS_MODULE,
225 },
226 .probe = rs5c348_probe,
227 .remove = __devexit_p(rs5c348_remove),
228};
229
230static __init int rs5c348_init(void)
231{
232 return spi_register_driver(&rs5c348_driver);
233}
234
235static __exit void rs5c348_exit(void)
236{
237 spi_unregister_driver(&rs5c348_driver);
238}
239
240module_init(rs5c348_init);
241module_exit(rs5c348_exit);
242
243MODULE_AUTHOR("Atsushi Nemoto <anemo@mba.ocn.ne.jp>");
244MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver");
245MODULE_LICENSE("GPL");
246MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index b88a7c1158af..bff94541991c 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -131,17 +131,6 @@ static int m68328_console_baud = CONSOLE_BAUD_RATE;
131static int m68328_console_cbaud = DEFAULT_CBAUD; 131static int m68328_console_cbaud = DEFAULT_CBAUD;
132 132
133 133
134/*
135 * tmp_buf is used as a temporary buffer by serial_write. We need to
136 * lock it in case the memcpy_fromfs blocks while swapping in a page,
137 * and some other program tries to do a serial write at the same time.
138 * Since the lock will only come under contention when the system is
139 * swapping and available memory is low, it makes sense to share one
140 * buffer across all the serial ports, since it significantly saves
141 * memory if large numbers of serial ports are open.
142 */
143static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */
144
145static inline int serial_paranoia_check(struct m68k_serial *info, 134static inline int serial_paranoia_check(struct m68k_serial *info,
146 char *name, const char *routine) 135 char *name, const char *routine)
147{ 136{
@@ -211,16 +200,16 @@ static void rs_stop(struct tty_struct *tty)
211 if (serial_paranoia_check(info, tty->name, "rs_stop")) 200 if (serial_paranoia_check(info, tty->name, "rs_stop"))
212 return; 201 return;
213 202
214 save_flags(flags); cli(); 203 local_irq_save(flags);
215 uart->ustcnt &= ~USTCNT_TXEN; 204 uart->ustcnt &= ~USTCNT_TXEN;
216 restore_flags(flags); 205 local_irq_restore(flags);
217} 206}
218 207
219static void rs_put_char(char ch) 208static void rs_put_char(char ch)
220{ 209{
221 int flags, loops = 0; 210 int flags, loops = 0;
222 211
223 save_flags(flags); cli(); 212 local_irq_save(flags);
224 213
225 while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) { 214 while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
226 loops++; 215 loops++;
@@ -229,7 +218,7 @@ static void rs_put_char(char ch)
229 218
230 UTX_TXDATA = ch; 219 UTX_TXDATA = ch;
231 udelay(5); 220 udelay(5);
232 restore_flags(flags); 221 local_irq_restore(flags);
233} 222}
234 223
235static void rs_start(struct tty_struct *tty) 224static void rs_start(struct tty_struct *tty)
@@ -241,7 +230,7 @@ static void rs_start(struct tty_struct *tty)
241 if (serial_paranoia_check(info, tty->name, "rs_start")) 230 if (serial_paranoia_check(info, tty->name, "rs_start"))
242 return; 231 return;
243 232
244 save_flags(flags); cli(); 233 local_irq_save(flags);
245 if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) { 234 if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
246#ifdef USE_INTS 235#ifdef USE_INTS
247 uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK; 236 uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
@@ -249,7 +238,7 @@ static void rs_start(struct tty_struct *tty)
249 uart->ustcnt |= USTCNT_TXEN; 238 uart->ustcnt |= USTCNT_TXEN;
250#endif 239#endif
251 } 240 }
252 restore_flags(flags); 241 local_irq_restore(flags);
253} 242}
254 243
255/* Drop into either the boot monitor or kadb upon receiving a break 244/* Drop into either the boot monitor or kadb upon receiving a break
@@ -327,14 +316,6 @@ static void receive_chars(struct m68k_serial *info, struct pt_regs *regs,
327 if(!tty) 316 if(!tty)
328 goto clear_and_exit; 317 goto clear_and_exit;
329 318
330 /*
331 * Make sure that we do not overflow the buffer
332 */
333 if (tty_request_buffer_room(tty, 1) == 0) {
334 tty_schedule_flip(tty);
335 return;
336 }
337
338 flag = TTY_NORMAL; 319 flag = TTY_NORMAL;
339 320
340 if(rx & URX_PARITY_ERROR) { 321 if(rx & URX_PARITY_ERROR) {
@@ -473,7 +454,7 @@ static int startup(struct m68k_serial * info)
473 return -ENOMEM; 454 return -ENOMEM;
474 } 455 }
475 456
476 save_flags(flags); cli(); 457 local_irq_save(flags);
477 458
478 /* 459 /*
479 * Clear the FIFO buffers and disable them 460 * Clear the FIFO buffers and disable them
@@ -506,7 +487,7 @@ static int startup(struct m68k_serial * info)
506 change_speed(info); 487 change_speed(info);
507 488
508 info->flags |= S_INITIALIZED; 489 info->flags |= S_INITIALIZED;
509 restore_flags(flags); 490 local_irq_restore(flags);
510 return 0; 491 return 0;
511} 492}
512 493
@@ -523,7 +504,7 @@ static void shutdown(struct m68k_serial * info)
523 if (!(info->flags & S_INITIALIZED)) 504 if (!(info->flags & S_INITIALIZED))
524 return; 505 return;
525 506
526 save_flags(flags); cli(); /* Disable interrupts */ 507 local_irq_save(flags);
527 508
528 if (info->xmit_buf) { 509 if (info->xmit_buf) {
529 free_page((unsigned long) info->xmit_buf); 510 free_page((unsigned long) info->xmit_buf);
@@ -534,7 +515,7 @@ static void shutdown(struct m68k_serial * info)
534 set_bit(TTY_IO_ERROR, &info->tty->flags); 515 set_bit(TTY_IO_ERROR, &info->tty->flags);
535 516
536 info->flags &= ~S_INITIALIZED; 517 info->flags &= ~S_INITIALIZED;
537 restore_flags(flags); 518 local_irq_restore(flags);
538} 519}
539 520
540struct { 521struct {
@@ -655,24 +636,24 @@ static void rs_fair_output(void)
655 if (info == 0) return; 636 if (info == 0) return;
656 if (info->xmit_buf == 0) return; 637 if (info->xmit_buf == 0) return;
657 638
658 save_flags(flags); cli(); 639 local_irq_save(flags);
659 left = info->xmit_cnt; 640 left = info->xmit_cnt;
660 while (left != 0) { 641 while (left != 0) {
661 c = info->xmit_buf[info->xmit_tail]; 642 c = info->xmit_buf[info->xmit_tail];
662 info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1); 643 info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
663 info->xmit_cnt--; 644 info->xmit_cnt--;
664 restore_flags(flags); 645 local_irq_restore(flags);
665 646
666 rs_put_char(c); 647 rs_put_char(c);
667 648
668 save_flags(flags); cli(); 649 local_irq_save(flags);
669 left = min(info->xmit_cnt, left-1); 650 left = min(info->xmit_cnt, left-1);
670 } 651 }
671 652
672 /* Last character is being transmitted now (hopefully). */ 653 /* Last character is being transmitted now (hopefully). */
673 udelay(5); 654 udelay(5);
674 655
675 restore_flags(flags); 656 local_irq_restore(flags);
676 return; 657 return;
677} 658}
678 659
@@ -720,11 +701,11 @@ static void rs_flush_chars(struct tty_struct *tty)
720#endif 701#endif
721 702
722 /* Enable transmitter */ 703 /* Enable transmitter */
723 save_flags(flags); cli(); 704 local_irq_save(flags);
724 705
725 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 706 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
726 !info->xmit_buf) { 707 !info->xmit_buf) {
727 restore_flags(flags); 708 local_irq_restore(flags);
728 return; 709 return;
729 } 710 }
730 711
@@ -749,7 +730,7 @@ static void rs_flush_chars(struct tty_struct *tty)
749 while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5); 730 while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
750 } 731 }
751#endif 732#endif
752 restore_flags(flags); 733 local_irq_restore(flags);
753} 734}
754 735
755extern void console_printn(const char * b, int count); 736extern void console_printn(const char * b, int count);
@@ -768,18 +749,22 @@ static int rs_write(struct tty_struct * tty,
768 if (!tty || !info->xmit_buf) 749 if (!tty || !info->xmit_buf)
769 return 0; 750 return 0;
770 751
771 save_flags(flags); 752 local_save_flags(flags);
772 while (1) { 753 while (1) {
773 cli(); 754 local_irq_disable();
774 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, 755 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
775 SERIAL_XMIT_SIZE - info->xmit_head)); 756 SERIAL_XMIT_SIZE - info->xmit_head));
757 local_irq_restore(flags);
758
776 if (c <= 0) 759 if (c <= 0)
777 break; 760 break;
778 761
779 memcpy(info->xmit_buf + info->xmit_head, buf, c); 762 memcpy(info->xmit_buf + info->xmit_head, buf, c);
763
764 local_irq_disable();
780 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); 765 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
781 info->xmit_cnt += c; 766 info->xmit_cnt += c;
782 restore_flags(flags); 767 local_irq_restore(flags);
783 buf += c; 768 buf += c;
784 count -= c; 769 count -= c;
785 total += c; 770 total += c;
@@ -787,7 +772,7 @@ static int rs_write(struct tty_struct * tty,
787 772
788 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 773 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
789 /* Enable transmitter */ 774 /* Enable transmitter */
790 cli(); 775 local_irq_disable();
791#ifndef USE_INTS 776#ifndef USE_INTS
792 while(info->xmit_cnt) { 777 while(info->xmit_cnt) {
793#endif 778#endif
@@ -807,9 +792,9 @@ static int rs_write(struct tty_struct * tty,
807#ifndef USE_INTS 792#ifndef USE_INTS
808 } 793 }
809#endif 794#endif
810 restore_flags(flags); 795 local_irq_restore(flags);
811 } 796 }
812 restore_flags(flags); 797
813 return total; 798 return total;
814} 799}
815 800
@@ -838,12 +823,13 @@ static int rs_chars_in_buffer(struct tty_struct *tty)
838static void rs_flush_buffer(struct tty_struct *tty) 823static void rs_flush_buffer(struct tty_struct *tty)
839{ 824{
840 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; 825 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
826 unsigned long flags;
841 827
842 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) 828 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
843 return; 829 return;
844 cli(); 830 local_irq_save(flags);
845 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 831 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
846 sti(); 832 local_irq_restore(flags);
847 tty_wakeup(tty); 833 tty_wakeup(tty);
848} 834}
849 835
@@ -973,14 +959,15 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
973 m68328_uart *uart = &uart_addr[info->line]; 959 m68328_uart *uart = &uart_addr[info->line];
974#endif 960#endif
975 unsigned char status; 961 unsigned char status;
962 unsigned long flags;
976 963
977 cli(); 964 local_irq_save(flags);
978#ifdef CONFIG_SERIAL_68328_RTS_CTS 965#ifdef CONFIG_SERIAL_68328_RTS_CTS
979 status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0; 966 status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
980#else 967#else
981 status = 0; 968 status = 0;
982#endif 969#endif
983 sti(); 970 local_irq_restore(flags);
984 put_user(status,value); 971 put_user(status,value);
985 return 0; 972 return 0;
986} 973}
@@ -994,14 +981,13 @@ static void send_break(struct m68k_serial * info, unsigned int duration)
994 unsigned long flags; 981 unsigned long flags;
995 if (!info->port) 982 if (!info->port)
996 return; 983 return;
997 save_flags(flags); 984 local_irq_save(flags);
998 cli();
999#ifdef USE_INTS 985#ifdef USE_INTS
1000 uart->utx.w |= UTX_SEND_BREAK; 986 uart->utx.w |= UTX_SEND_BREAK;
1001 msleep_interruptible(duration); 987 msleep_interruptible(duration);
1002 uart->utx.w &= ~UTX_SEND_BREAK; 988 uart->utx.w &= ~UTX_SEND_BREAK;
1003#endif 989#endif
1004 restore_flags(flags); 990 local_irq_restore(flags);
1005} 991}
1006 992
1007static int rs_ioctl(struct tty_struct *tty, struct file * file, 993static int rs_ioctl(struct tty_struct *tty, struct file * file,
@@ -1060,7 +1046,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
1060 (struct serial_struct *) arg); 1046 (struct serial_struct *) arg);
1061 case TIOCSERGETLSR: /* Get line status register */ 1047 case TIOCSERGETLSR: /* Get line status register */
1062 if (access_ok(VERIFY_WRITE, (void *) arg, 1048 if (access_ok(VERIFY_WRITE, (void *) arg,
1063 sizeof(unsigned int)); 1049 sizeof(unsigned int)))
1064 return get_lsr_info(info, (unsigned int *) arg); 1050 return get_lsr_info(info, (unsigned int *) arg);
1065 return -EFAULT; 1051 return -EFAULT;
1066 case TIOCSERGSTRUCT: 1052 case TIOCSERGSTRUCT:
@@ -1113,10 +1099,10 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1113 if (!info || serial_paranoia_check(info, tty->name, "rs_close")) 1099 if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
1114 return; 1100 return;
1115 1101
1116 save_flags(flags); cli(); 1102 local_irq_save(flags);
1117 1103
1118 if (tty_hung_up_p(filp)) { 1104 if (tty_hung_up_p(filp)) {
1119 restore_flags(flags); 1105 local_irq_restore(flags);
1120 return; 1106 return;
1121 } 1107 }
1122 1108
@@ -1138,7 +1124,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1138 info->count = 0; 1124 info->count = 0;
1139 } 1125 }
1140 if (info->count) { 1126 if (info->count) {
1141 restore_flags(flags); 1127 local_irq_restore(flags);
1142 return; 1128 return;
1143 } 1129 }
1144 info->flags |= S_CLOSING; 1130 info->flags |= S_CLOSING;
@@ -1186,7 +1172,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1186 } 1172 }
1187 info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING); 1173 info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING);
1188 wake_up_interruptible(&info->close_wait); 1174 wake_up_interruptible(&info->close_wait);
1189 restore_flags(flags); 1175 local_irq_restore(flags);
1190} 1176}
1191 1177
1192/* 1178/*
@@ -1262,9 +1248,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1262 info->count--; 1248 info->count--;
1263 info->blocked_open++; 1249 info->blocked_open++;
1264 while (1) { 1250 while (1) {
1265 cli(); 1251 local_irq_disable();
1266 m68k_rtsdtr(info, 1); 1252 m68k_rtsdtr(info, 1);
1267 sti(); 1253 local_irq_enable();
1268 current->state = TASK_INTERRUPTIBLE; 1254 current->state = TASK_INTERRUPTIBLE;
1269 if (tty_hung_up_p(filp) || 1255 if (tty_hung_up_p(filp) ||
1270 !(info->flags & S_INITIALIZED)) { 1256 !(info->flags & S_INITIALIZED)) {
@@ -1444,7 +1430,7 @@ rs68328_init(void)
1444 return -ENOMEM; 1430 return -ENOMEM;
1445 } 1431 }
1446 1432
1447 save_flags(flags); cli(); 1433 local_irq_save(flags);
1448 1434
1449 for(i=0;i<NR_PORTS;i++) { 1435 for(i=0;i<NR_PORTS;i++) {
1450 1436
@@ -1489,7 +1475,7 @@ rs68328_init(void)
1489 serial_pm[i]->data = info; 1475 serial_pm[i]->data = info;
1490#endif 1476#endif
1491 } 1477 }
1492 restore_flags(flags); 1478 local_irq_restore(flags);
1493 return 0; 1479 return 0;
1494} 1480}
1495 1481
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 89700141f87e..5cacc5e74a92 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -2573,12 +2573,6 @@ static void flush_to_flip_buffer(struct e100_serial *info)
2573 2573
2574 DFLIP( 2574 DFLIP(
2575 if (1) { 2575 if (1) {
2576
2577 if (test_bit(TTY_DONT_FLIP, &tty->flags)) {
2578 DEBUG_LOG(info->line, "*** TTY_DONT_FLIP set flip.count %i ***\n", tty->flip.count);
2579 DEBUG_LOG(info->line, "*** recv_cnt %i\n", info->recv_cnt);
2580 } else {
2581 }
2582 DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx); 2576 DEBUG_LOG(info->line, "*** rxtot %i\n", info->icount.rx);
2583 DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty)); 2577 DEBUG_LOG(info->line, "ldisc %lu\n", tty->ldisc.chars_in_buffer(tty));
2584 DEBUG_LOG(info->line, "room %lu\n", tty->ldisc.receive_room(tty)); 2578 DEBUG_LOG(info->line, "room %lu\n", tty->ldisc.receive_room(tty));
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 7d823705193c..f8262e6ad8d3 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -589,13 +589,6 @@ void jsm_input(struct jsm_channel *ch)
589 ld = tty_ldisc_ref(tp); 589 ld = tty_ldisc_ref(tp);
590 590
591 /* 591 /*
592 * If the DONT_FLIP flag is on, don't flush our buffer, and act
593 * like the ld doesn't have any space to put the data right now.
594 */
595 if (test_bit(TTY_DONT_FLIP, &tp->flags))
596 len = 0;
597
598 /*
599 * If we were unable to get a reference to the ld, 592 * If we were unable to get a reference to the ld,
600 * don't flush our buffer, and act like the ld doesn't 593 * don't flush our buffer, and act like the ld doesn't
601 * have any space to put the data right now. 594 * have any space to put the data right now.
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 1cea4a6799fe..ed1cdf6ac8f3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -210,6 +210,7 @@ spi_new_device(struct spi_master *master, struct spi_board_info *chip)
210 proxy->master = master; 210 proxy->master = master;
211 proxy->chip_select = chip->chip_select; 211 proxy->chip_select = chip->chip_select;
212 proxy->max_speed_hz = chip->max_speed_hz; 212 proxy->max_speed_hz = chip->max_speed_hz;
213 proxy->mode = chip->mode;
213 proxy->irq = chip->irq; 214 proxy->irq = chip->irq;
214 proxy->modalias = chip->modalias; 215 proxy->modalias = chip->modalias;
215 216
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 9432c7302275..d7f3f736a692 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -453,8 +453,7 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
453 tty = port->tty; 453 tty = port->tty;
454 454
455 /* 455 /*
456 * FIXME: must not do this in IRQ context, 456 * FIXME: must not do this in IRQ context
457 * must honour TTY_DONT_FLIP
458 */ 457 */
459 tty->ldisc.receive_buf( 458 tty->ldisc.receive_buf(
460 tty, 459 tty,
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index 7de66b855d4e..1755dddf1899 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -40,14 +40,14 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata,
40 40
41 mutex_unlock(&info->bl_mutex); 41 mutex_unlock(&info->bl_mutex);
42 42
43 if (pdata->negative)
44 rlevel = MAX_RADEON_LEVEL - rlevel;
45
46 if (rlevel < 0) 43 if (rlevel < 0)
47 rlevel = 0; 44 rlevel = 0;
48 else if (rlevel > MAX_RADEON_LEVEL) 45 else if (rlevel > MAX_RADEON_LEVEL)
49 rlevel = MAX_RADEON_LEVEL; 46 rlevel = MAX_RADEON_LEVEL;
50 47
48 if (pdata->negative)
49 rlevel = MAX_RADEON_LEVEL - rlevel;
50
51 return rlevel; 51 return rlevel;
52} 52}
53 53