aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-04-30 03:53:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:44 -0400
commit15ed6cc0ba6b7beaf31c6756b0c838188800051b (patch)
tree44d30ead17f09afaf488c1b878b3a9687c804a6a /drivers/char
parente5b393e4f1178faaf3d7c22ef63e70c79633bd66 (diff)
cyclades: coding style & review
Signed-off-by: Alan Cox <alan@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/cyclades.c308
1 files changed, 149 insertions, 159 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 028db1b8fc4e..ba795c757db0 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -21,7 +21,6 @@
21 * 21 *
22 * This version supports shared IRQ's (only for PCI boards). 22 * This version supports shared IRQ's (only for PCI boards).
23 * 23 *
24 * $Log: cyclades.c,v $
25 * Prevent users from opening non-existing Z ports. 24 * Prevent users from opening non-existing Z ports.
26 * 25 *
27 * Revision 2.3.2.8 2000/07/06 18:14:16 ivan 26 * Revision 2.3.2.8 2000/07/06 18:14:16 ivan
@@ -62,7 +61,7 @@
62 * Driver now makes sure that the constant SERIAL_XMIT_SIZE is defined; 61 * Driver now makes sure that the constant SERIAL_XMIT_SIZE is defined;
63 * 62 *
64 * Revision 2.3.2.2 1999/10/01 11:27:43 ivan 63 * Revision 2.3.2.2 1999/10/01 11:27:43 ivan
65 * Fixed bug in cyz_poll that would make all ports but port 0 64 * Fixed bug in cyz_poll that would make all ports but port 0
66 * unable to transmit/receive data (Cyclades-Z only); 65 * unable to transmit/receive data (Cyclades-Z only);
67 * Implemented logic to prevent the RX buffer from being stuck with data 66 * Implemented logic to prevent the RX buffer from being stuck with data
68 * due to a driver / firmware race condition in interrupt op mode 67 * due to a driver / firmware race condition in interrupt op mode
@@ -83,25 +82,25 @@
83 * Revision 2.3.1.1 1999/07/15 16:45:53 ivan 82 * Revision 2.3.1.1 1999/07/15 16:45:53 ivan
84 * Removed CY_PROC conditional compilation; 83 * Removed CY_PROC conditional compilation;
85 * Implemented SMP-awareness for the driver; 84 * Implemented SMP-awareness for the driver;
86 * Implemented a new ISA IRQ autoprobe that uses the irq_probe_[on|off] 85 * Implemented a new ISA IRQ autoprobe that uses the irq_probe_[on|off]
87 * functions; 86 * functions;
88 * The driver now accepts memory addresses (maddr=0xMMMMM) and IRQs 87 * The driver now accepts memory addresses (maddr=0xMMMMM) and IRQs
89 * (irq=NN) as parameters (only for ISA boards); 88 * (irq=NN) as parameters (only for ISA boards);
90 * Fixed bug in set_line_char that would prevent the Cyclades-Z 89 * Fixed bug in set_line_char that would prevent the Cyclades-Z
91 * ports from being configured at speeds above 115.2Kbps; 90 * ports from being configured at speeds above 115.2Kbps;
92 * Fixed bug in cy_set_termios that would prevent XON/XOFF flow control 91 * Fixed bug in cy_set_termios that would prevent XON/XOFF flow control
93 * switching from working properly; 92 * switching from working properly;
94 * The driver now only prints IRQ info for the Cyclades-Z if it's 93 * The driver now only prints IRQ info for the Cyclades-Z if it's
95 * configured to work in interrupt mode; 94 * configured to work in interrupt mode;
96 * 95 *
97 * Revision 2.2.2.3 1999/06/28 11:13:29 ivan 96 * Revision 2.2.2.3 1999/06/28 11:13:29 ivan
98 * Added support for interrupt mode operation for the Z cards; 97 * Added support for interrupt mode operation for the Z cards;
99 * Removed the driver inactivity control for the Z; 98 * Removed the driver inactivity control for the Z;
100 * Added a missing MOD_DEC_USE_COUNT in the cy_open function for when 99 * Added a missing MOD_DEC_USE_COUNT in the cy_open function for when
101 * the Z firmware is not loaded yet; 100 * the Z firmware is not loaded yet;
102 * Replaced the "manual" Z Tx flush buffer by a call to a FW command of 101 * Replaced the "manual" Z Tx flush buffer by a call to a FW command of
103 * same functionality; 102 * same functionality;
104 * Implemented workaround for IRQ setting loss on the PCI configuration 103 * Implemented workaround for IRQ setting loss on the PCI configuration
105 * registers after a PCI bridge EEPROM reload (affects PLX9060 only); 104 * registers after a PCI bridge EEPROM reload (affects PLX9060 only);
106 * 105 *
107 * Revision 2.2.2.2 1999/05/14 17:18:15 ivan 106 * Revision 2.2.2.2 1999/05/14 17:18:15 ivan
@@ -112,22 +111,22 @@
112 * BREAK implementation changed in order to make use of the 'break_ctl' 111 * BREAK implementation changed in order to make use of the 'break_ctl'
113 * TTY facility; 112 * TTY facility;
114 * Fixed typo in TTY structure field 'driver_name'; 113 * Fixed typo in TTY structure field 'driver_name';
115 * Included a PCI bridge reset and EEPROM reload in the board 114 * Included a PCI bridge reset and EEPROM reload in the board
116 * initialization code (for both Y and Z series). 115 * initialization code (for both Y and Z series).
117 * 116 *
118 * Revision 2.2.2.1 1999/04/08 16:17:43 ivan 117 * Revision 2.2.2.1 1999/04/08 16:17:43 ivan
119 * Fixed a bug in cy_wait_until_sent that was preventing the port to be 118 * Fixed a bug in cy_wait_until_sent that was preventing the port to be
120 * closed properly after a SIGINT; 119 * closed properly after a SIGINT;
121 * Module usage counter scheme revisited; 120 * Module usage counter scheme revisited;
122 * Added support to the upcoming Y PCI boards (i.e., support to additional 121 * Added support to the upcoming Y PCI boards (i.e., support to additional
123 * PCI Device ID's). 122 * PCI Device ID's).
124 * 123 *
125 * Revision 2.2.1.10 1999/01/20 16:14:29 ivan 124 * Revision 2.2.1.10 1999/01/20 16:14:29 ivan
126 * Removed all unnecessary page-alignement operations in ioremap calls 125 * Removed all unnecessary page-alignement operations in ioremap calls
127 * (ioremap is currently safe for these operations). 126 * (ioremap is currently safe for these operations).
128 * 127 *
129 * Revision 2.2.1.9 1998/12/30 18:18:30 ivan 128 * Revision 2.2.1.9 1998/12/30 18:18:30 ivan
130 * Changed access to PLX PCI bridge registers from I/O to MMIO, in 129 * Changed access to PLX PCI bridge registers from I/O to MMIO, in
131 * order to make PLX9050-based boards work with certain motherboards. 130 * order to make PLX9050-based boards work with certain motherboards.
132 * 131 *
133 * Revision 2.2.1.8 1998/11/13 12:46:20 ivan 132 * Revision 2.2.1.8 1998/11/13 12:46:20 ivan
@@ -148,7 +147,7 @@
148 * Fixed Cyclom-4Yo hardware detection bug. 147 * Fixed Cyclom-4Yo hardware detection bug.
149 * 148 *
150 * Revision 2.2.1.4 1998/08/04 11:02:50 ivan 149 * Revision 2.2.1.4 1998/08/04 11:02:50 ivan
151 * /proc/cyclades implementation with great collaboration of 150 * /proc/cyclades implementation with great collaboration of
152 * Marc Lewis <marc@blarg.net>; 151 * Marc Lewis <marc@blarg.net>;
153 * cyy_interrupt was changed to avoid occurrence of kernel oopses 152 * cyy_interrupt was changed to avoid occurrence of kernel oopses
154 * during PPP operation. 153 * during PPP operation.
@@ -157,7 +156,7 @@
157 * General code review in order to comply with 2.1 kernel standards; 156 * General code review in order to comply with 2.1 kernel standards;
158 * data loss prevention for slow devices revisited (cy_wait_until_sent 157 * data loss prevention for slow devices revisited (cy_wait_until_sent
159 * was created); 158 * was created);
160 * removed conditional compilation for new/old PCI structure support 159 * removed conditional compilation for new/old PCI structure support
161 * (now the driver only supports the new PCI structure). 160 * (now the driver only supports the new PCI structure).
162 * 161 *
163 * Revision 2.2.1.1 1998/03/19 16:43:12 ivan 162 * Revision 2.2.1.1 1998/03/19 16:43:12 ivan
@@ -168,7 +167,7 @@
168 * cleaned up the data loss fix; 167 * cleaned up the data loss fix;
169 * fixed XON/XOFF handling once more (Cyclades-Z); 168 * fixed XON/XOFF handling once more (Cyclades-Z);
170 * general review of the driver routines; 169 * general review of the driver routines;
171 * introduction of a mechanism to prevent data loss with slow 170 * introduction of a mechanism to prevent data loss with slow
172 * printers, by forcing a delay before closing the port. 171 * printers, by forcing a delay before closing the port.
173 * 172 *
174 * Revision 2.1.1.2 1998/02/17 16:50:00 ivan 173 * Revision 2.1.1.2 1998/02/17 16:50:00 ivan
@@ -182,12 +181,12 @@
182 * Code review for the module cleanup routine; 181 * Code review for the module cleanup routine;
183 * fixed RTS and DTR status report for new CD1400's in get_modem_info; 182 * fixed RTS and DTR status report for new CD1400's in get_modem_info;
184 * includes anonymous changes regarding signal_pending. 183 * includes anonymous changes regarding signal_pending.
185 * 184 *
186 * Revision 2.1 1997/11/01 17:42:41 ivan 185 * Revision 2.1 1997/11/01 17:42:41 ivan
187 * Changes in the driver to support Alpha systems (except 8Zo V_1); 186 * Changes in the driver to support Alpha systems (except 8Zo V_1);
188 * BREAK fix for the Cyclades-Z boards; 187 * BREAK fix for the Cyclades-Z boards;
189 * driver inactivity control by FW implemented; 188 * driver inactivity control by FW implemented;
190 * introduction of flag that allows driver to take advantage of 189 * introduction of flag that allows driver to take advantage of
191 * a special CD1400 feature related to HW flow control; 190 * a special CD1400 feature related to HW flow control;
192 * added support for the CD1400 rev. J (Cyclom-Y boards); 191 * added support for the CD1400 rev. J (Cyclom-Y boards);
193 * introduction of ioctls to: 192 * introduction of ioctls to:
@@ -196,17 +195,17 @@
196 * - adjust the polling interval (Cyclades-Z); 195 * - adjust the polling interval (Cyclades-Z);
197 * 196 *
198 * Revision 1.36.4.33 1997/06/27 19:00:00 ivan 197 * Revision 1.36.4.33 1997/06/27 19:00:00 ivan
199 * Fixes related to kernel version conditional 198 * Fixes related to kernel version conditional
200 * compilation. 199 * compilation.
201 * 200 *
202 * Revision 1.36.4.32 1997/06/14 19:30:00 ivan 201 * Revision 1.36.4.32 1997/06/14 19:30:00 ivan
203 * Compatibility issues between kernels 2.0.x and 202 * Compatibility issues between kernels 2.0.x and
204 * 2.1.x (mainly related to clear_bit function). 203 * 2.1.x (mainly related to clear_bit function).
205 * 204 *
206 * Revision 1.36.4.31 1997/06/03 15:30:00 ivan 205 * Revision 1.36.4.31 1997/06/03 15:30:00 ivan
207 * Changes to define the memory window according to the 206 * Changes to define the memory window according to the
208 * board type. 207 * board type.
209 * 208 *
210 * Revision 1.36.4.30 1997/05/16 15:30:00 daniel 209 * Revision 1.36.4.30 1997/05/16 15:30:00 daniel
211 * Changes to support new cycladesZ boards. 210 * Changes to support new cycladesZ boards.
212 * 211 *
@@ -624,7 +623,7 @@
624#undef CY_PCI_DEBUG 623#undef CY_PCI_DEBUG
625 624
626/* 625/*
627 * Include section 626 * Include section
628 */ 627 */
629#include <linux/module.h> 628#include <linux/module.h>
630#include <linux/errno.h> 629#include <linux/errno.h>
@@ -649,9 +648,9 @@
649#include <linux/firmware.h> 648#include <linux/firmware.h>
650 649
651#include <asm/system.h> 650#include <asm/system.h>
652#include <asm/io.h> 651#include <linux/io.h>
653#include <asm/irq.h> 652#include <asm/irq.h>
654#include <asm/uaccess.h> 653#include <linux/uaccess.h>
655 654
656#include <linux/kernel.h> 655#include <linux/kernel.h>
657#include <linux/pci.h> 656#include <linux/pci.h>
@@ -668,10 +667,10 @@ static void cy_send_xchar(struct tty_struct *tty, char ch);
668 ((readl(&((struct RUNTIME_9060 __iomem *) \ 667 ((readl(&((struct RUNTIME_9060 __iomem *) \
669 ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0) 668 ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
670 669
671#define ISZLOADED(card) (((ZO_V1==readl(&((struct RUNTIME_9060 __iomem *) \ 670#define ISZLOADED(card) (((ZO_V1 == readl(&((struct RUNTIME_9060 __iomem *) \
672 ((card).ctl_addr))->mail_box_0)) || \ 671 ((card).ctl_addr))->mail_box_0)) || \
673 Z_FPGA_CHECK(card)) && \ 672 Z_FPGA_CHECK(card)) && \
674 (ZFIRM_ID==readl(&((struct FIRM_ID __iomem *) \ 673 (ZFIRM_ID == readl(&((struct FIRM_ID __iomem *) \
675 ((card).base_addr+ID_ADDRESS))->signature))) 674 ((card).base_addr+ID_ADDRESS))->signature)))
676 675
677#ifndef SERIAL_XMIT_SIZE 676#ifndef SERIAL_XMIT_SIZE
@@ -809,12 +808,12 @@ static char baud_cor3[] = { /* receive threshold */
809 808
810/* 809/*
811 * The Cyclades driver implements HW flow control as any serial driver. 810 * The Cyclades driver implements HW flow control as any serial driver.
812 * The cyclades_port structure member rflow and the vector rflow_thr 811 * The cyclades_port structure member rflow and the vector rflow_thr
813 * allows us to take advantage of a special feature in the CD1400 to avoid 812 * allows us to take advantage of a special feature in the CD1400 to avoid
814 * data loss even when the system interrupt latency is too high. These flags 813 * data loss even when the system interrupt latency is too high. These flags
815 * are to be used only with very special applications. Setting these flags 814 * are to be used only with very special applications. Setting these flags
816 * requires the use of a special cable (DTR and RTS reversed). In the new 815 * requires the use of a special cable (DTR and RTS reversed). In the new
817 * CD1400-based boards (rev. 6.00 or later), there is no need for special 816 * CD1400-based boards (rev. 6.00 or later), there is no need for special
818 * cables. 817 * cables.
819 */ 818 */
820 819
@@ -841,14 +840,22 @@ static int cy_chip_offset[] = { 0x0000,
841 840
842#ifdef CONFIG_PCI 841#ifdef CONFIG_PCI
843static struct pci_device_id cy_pci_dev_id[] __devinitdata = { 842static struct pci_device_id cy_pci_dev_id[] __devinitdata = {
844 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Lo) }, /* PCI < 1Mb */ 843 /* PCI < 1Mb */
845 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Hi) }, /* PCI > 1Mb */ 844 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Lo) },
846 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Lo) }, /* 4Y PCI < 1Mb */ 845 /* PCI > 1Mb */
847 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Hi) }, /* 4Y PCI > 1Mb */ 846 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Hi) },
848 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Lo) }, /* 8Y PCI < 1Mb */ 847 /* 4Y PCI < 1Mb */
849 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Hi) }, /* 8Y PCI > 1Mb */ 848 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Lo) },
850 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Lo) }, /* Z PCI < 1Mb */ 849 /* 4Y PCI > 1Mb */
851 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Hi) }, /* Z PCI > 1Mb */ 850 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Hi) },
851 /* 8Y PCI < 1Mb */
852 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Lo) },
853 /* 8Y PCI > 1Mb */
854 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Hi) },
855 /* Z PCI < 1Mb */
856 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Lo) },
857 /* Z PCI > 1Mb */
858 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Hi) },
852 { } /* end of table */ 859 { } /* end of table */
853}; 860};
854MODULE_DEVICE_TABLE(pci, cy_pci_dev_id); 861MODULE_DEVICE_TABLE(pci, cy_pci_dev_id);
@@ -905,15 +912,14 @@ static inline int serial_paranoia_check(struct cyclades_port *info,
905 912
906 This function is only called from inside spinlock-protected code. 913 This function is only called from inside spinlock-protected code.
907 */ 914 */
908static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index) 915static int cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index)
909{ 916{
910 unsigned int i; 917 unsigned int i;
911 918
912 /* Check to see that the previous command has completed */ 919 /* Check to see that the previous command has completed */
913 for (i = 0; i < 100; i++) { 920 for (i = 0; i < 100; i++) {
914 if (readb(base_addr + (CyCCR << index)) == 0) { 921 if (readb(base_addr + (CyCCR << index)) == 0)
915 break; 922 break;
916 }
917 udelay(10L); 923 udelay(10L);
918 } 924 }
919 /* if the CCR never cleared, the previous command 925 /* if the CCR never cleared, the previous command
@@ -929,7 +935,7 @@ static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index)
929 935
930#ifdef CONFIG_ISA 936#ifdef CONFIG_ISA
931/* ISA interrupt detection code */ 937/* ISA interrupt detection code */
932static unsigned detect_isa_irq(void __iomem * address) 938static unsigned detect_isa_irq(void __iomem *address)
933{ 939{
934 int irq; 940 int irq;
935 unsigned long irqs, flags; 941 unsigned long irqs, flags;
@@ -1038,7 +1044,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
1038 if (info->flags & ASYNC_SAK) 1044 if (info->flags & ASYNC_SAK)
1039 do_SAK(tty); 1045 do_SAK(tty);
1040 } else if (data & CyFRAME) { 1046 } else if (data & CyFRAME) {
1041 tty_insert_flip_char( tty, 1047 tty_insert_flip_char(tty,
1042 readb(base_addr + (CyRDSR << 1048 readb(base_addr + (CyRDSR <<
1043 index)), TTY_FRAME); 1049 index)), TTY_FRAME);
1044 info->icount.rx++; 1050 info->icount.rx++;
@@ -1320,7 +1326,8 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
1320 1326
1321 if (unlikely(cinfo == NULL)) { 1327 if (unlikely(cinfo == NULL)) {
1322#ifdef CY_DEBUG_INTERRUPTS 1328#ifdef CY_DEBUG_INTERRUPTS
1323 printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",irq); 1329 printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",
1330 irq);
1324#endif 1331#endif
1325 return IRQ_NONE; /* spurious interrupt */ 1332 return IRQ_NONE; /* spurious interrupt */
1326 } 1333 }
@@ -1375,12 +1382,12 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
1375 1382
1376/***********************************************************/ 1383/***********************************************************/
1377/********* End of block of Cyclom-Y specific code **********/ 1384/********* End of block of Cyclom-Y specific code **********/
1378/******** Start of block of Cyclades-Z specific code *********/ 1385/******** Start of block of Cyclades-Z specific code *******/
1379/***********************************************************/ 1386/***********************************************************/
1380 1387
1381static int 1388static int
1382cyz_fetch_msg(struct cyclades_card *cinfo, 1389cyz_fetch_msg(struct cyclades_card *cinfo,
1383 __u32 * channel, __u8 * cmd, __u32 * param) 1390 __u32 *channel, __u8 *cmd, __u32 *param)
1384{ 1391{
1385 struct FIRM_ID __iomem *firm_id; 1392 struct FIRM_ID __iomem *firm_id;
1386 struct ZFW_CTRL __iomem *zfw_ctrl; 1393 struct ZFW_CTRL __iomem *zfw_ctrl;
@@ -1388,9 +1395,8 @@ cyz_fetch_msg(struct cyclades_card *cinfo,
1388 unsigned long loc_doorbell; 1395 unsigned long loc_doorbell;
1389 1396
1390 firm_id = cinfo->base_addr + ID_ADDRESS; 1397 firm_id = cinfo->base_addr + ID_ADDRESS;
1391 if (!ISZLOADED(*cinfo)) { 1398 if (!ISZLOADED(*cinfo))
1392 return -1; 1399 return -1;
1393 }
1394 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1400 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
1395 board_ctrl = &zfw_ctrl->board_ctrl; 1401 board_ctrl = &zfw_ctrl->board_ctrl;
1396 1402
@@ -1418,9 +1424,9 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1418 unsigned int index; 1424 unsigned int index;
1419 1425
1420 firm_id = cinfo->base_addr + ID_ADDRESS; 1426 firm_id = cinfo->base_addr + ID_ADDRESS;
1421 if (!ISZLOADED(*cinfo)) { 1427 if (!ISZLOADED(*cinfo))
1422 return -1; 1428 return -1;
1423 } 1429
1424 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1430 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
1425 board_ctrl = &zfw_ctrl->board_ctrl; 1431 board_ctrl = &zfw_ctrl->board_ctrl;
1426 1432
@@ -1428,9 +1434,8 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1428 pci_doorbell = 1434 pci_doorbell =
1429 &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell; 1435 &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
1430 while ((readl(pci_doorbell) & 0xff) != 0) { 1436 while ((readl(pci_doorbell) & 0xff) != 0) {
1431 if (index++ == 1000) { 1437 if (index++ == 1000)
1432 return (int)(readl(pci_doorbell) & 0xff); 1438 return (int)(readl(pci_doorbell) & 0xff);
1433 }
1434 udelay(50L); 1439 udelay(50L);
1435 } 1440 }
1436 cy_writel(&board_ctrl->hcmd_channel, channel); 1441 cy_writel(&board_ctrl->hcmd_channel, channel);
@@ -1504,7 +1509,8 @@ static void cyz_handle_rx(struct cyclades_port *info,
1504 while (len--) { 1509 while (len--) {
1505 data = readb(cinfo->base_addr + rx_bufaddr + 1510 data = readb(cinfo->base_addr + rx_bufaddr +
1506 new_rx_get); 1511 new_rx_get);
1507 new_rx_get = (new_rx_get + 1)& (rx_bufsize - 1); 1512 new_rx_get = (new_rx_get + 1) &
1513 (rx_bufsize - 1);
1508 tty_insert_flip_char(tty, data, TTY_NORMAL); 1514 tty_insert_flip_char(tty, data, TTY_NORMAL);
1509 info->idle_stats.recv_bytes++; 1515 info->idle_stats.recv_bytes++;
1510 info->icount.rx++; 1516 info->icount.rx++;
@@ -1636,7 +1642,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1636 special_count = 0; 1642 special_count = 0;
1637 delta_count = 0; 1643 delta_count = 0;
1638 info = &cinfo->ports[channel]; 1644 info = &cinfo->ports[channel];
1639 if ((tty = info->tty) == NULL) 1645 tty = info->tty;
1646 if (tty == NULL)
1640 continue; 1647 continue;
1641 1648
1642 ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); 1649 ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
@@ -1732,7 +1739,8 @@ static irqreturn_t cyz_interrupt(int irq, void *dev_id)
1732 1739
1733 if (unlikely(cinfo == NULL)) { 1740 if (unlikely(cinfo == NULL)) {
1734#ifdef CY_DEBUG_INTERRUPTS 1741#ifdef CY_DEBUG_INTERRUPTS
1735 printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",irq); 1742 printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",
1743 irq);
1736#endif 1744#endif
1737 return IRQ_NONE; /* spurious interrupt */ 1745 return IRQ_NONE; /* spurious interrupt */
1738 } 1746 }
@@ -1851,9 +1859,8 @@ static int startup(struct cyclades_port *info)
1851 } 1859 }
1852 1860
1853 if (!info->type) { 1861 if (!info->type) {
1854 if (info->tty) { 1862 if (info->tty)
1855 set_bit(TTY_IO_ERROR, &info->tty->flags); 1863 set_bit(TTY_IO_ERROR, &info->tty->flags);
1856 }
1857 free_page(page); 1864 free_page(page);
1858 goto errout; 1865 goto errout;
1859 } 1866 }
@@ -1904,9 +1911,8 @@ static int startup(struct cyclades_port *info)
1904 readb(base_addr + (CySRER << index)) | CyRxData); 1911 readb(base_addr + (CySRER << index)) | CyRxData);
1905 info->flags |= ASYNC_INITIALIZED; 1912 info->flags |= ASYNC_INITIALIZED;
1906 1913
1907 if (info->tty) { 1914 if (info->tty)
1908 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1915 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1909 }
1910 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1916 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1911 info->breakon = info->breakoff = 0; 1917 info->breakon = info->breakoff = 0;
1912 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); 1918 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -1925,9 +1931,8 @@ static int startup(struct cyclades_port *info)
1925 base_addr = card->base_addr; 1931 base_addr = card->base_addr;
1926 1932
1927 firm_id = base_addr + ID_ADDRESS; 1933 firm_id = base_addr + ID_ADDRESS;
1928 if (!ISZLOADED(*card)) { 1934 if (!ISZLOADED(*card))
1929 return -ENODEV; 1935 return -ENODEV;
1930 }
1931 1936
1932 zfw_ctrl = card->base_addr + 1937 zfw_ctrl = card->base_addr +
1933 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1938 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -1990,9 +1995,8 @@ static int startup(struct cyclades_port *info)
1990 /* enable send, recv, modem !!! */ 1995 /* enable send, recv, modem !!! */
1991 1996
1992 info->flags |= ASYNC_INITIALIZED; 1997 info->flags |= ASYNC_INITIALIZED;
1993 if (info->tty) { 1998 if (info->tty)
1994 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1999 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1995 }
1996 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 2000 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1997 info->breakon = info->breakoff = 0; 2001 info->breakon = info->breakoff = 0;
1998 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); 2002 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -2061,9 +2065,8 @@ static void shutdown(struct cyclades_port *info)
2061 void __iomem *base_addr; 2065 void __iomem *base_addr;
2062 int chip, channel, index; 2066 int chip, channel, index;
2063 2067
2064 if (!(info->flags & ASYNC_INITIALIZED)) { 2068 if (!(info->flags & ASYNC_INITIALIZED))
2065 return; 2069 return;
2066 }
2067 2070
2068 card = info->card; 2071 card = info->card;
2069 channel = info->line - card->first_line; 2072 channel = info->line - card->first_line;
@@ -2105,9 +2108,8 @@ static void shutdown(struct cyclades_port *info)
2105 /* it may be appropriate to clear _XMIT at 2108 /* it may be appropriate to clear _XMIT at
2106 some later date (after testing)!!! */ 2109 some later date (after testing)!!! */
2107 2110
2108 if (info->tty) { 2111 if (info->tty)
2109 set_bit(TTY_IO_ERROR, &info->tty->flags); 2112 set_bit(TTY_IO_ERROR, &info->tty->flags);
2110 }
2111 info->flags &= ~ASYNC_INITIALIZED; 2113 info->flags &= ~ASYNC_INITIALIZED;
2112 spin_unlock_irqrestore(&card->card_lock, flags); 2114 spin_unlock_irqrestore(&card->card_lock, flags);
2113 } else { 2115 } else {
@@ -2124,9 +2126,8 @@ static void shutdown(struct cyclades_port *info)
2124#endif 2126#endif
2125 2127
2126 firm_id = base_addr + ID_ADDRESS; 2128 firm_id = base_addr + ID_ADDRESS;
2127 if (!ISZLOADED(*card)) { 2129 if (!ISZLOADED(*card))
2128 return; 2130 return;
2129 }
2130 2131
2131 zfw_ctrl = card->base_addr + 2132 zfw_ctrl = card->base_addr +
2132 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 2133 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -2157,9 +2158,8 @@ static void shutdown(struct cyclades_port *info)
2157#endif 2158#endif
2158 } 2159 }
2159 2160
2160 if (info->tty) { 2161 if (info->tty)
2161 set_bit(TTY_IO_ERROR, &info->tty->flags); 2162 set_bit(TTY_IO_ERROR, &info->tty->flags);
2162 }
2163 info->flags &= ~ASYNC_INITIALIZED; 2163 info->flags &= ~ASYNC_INITIALIZED;
2164 2164
2165 spin_unlock_irqrestore(&card->card_lock, flags); 2165 spin_unlock_irqrestore(&card->card_lock, flags);
@@ -2204,7 +2204,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2204 * If non-blocking mode is set, then make the check up front 2204 * If non-blocking mode is set, then make the check up front
2205 * and then exit. 2205 * and then exit.
2206 */ 2206 */
2207 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { 2207 if ((filp->f_flags & O_NONBLOCK) ||
2208 (tty->flags & (1 << TTY_IO_ERROR))) {
2208 info->flags |= ASYNC_NORMAL_ACTIVE; 2209 info->flags |= ASYNC_NORMAL_ACTIVE;
2209 return 0; 2210 return 0;
2210 } 2211 }
@@ -2301,7 +2302,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2301 return -EINVAL; 2302 return -EINVAL;
2302 } 2303 }
2303 2304
2304 zfw_ctrl = base_addr + (readl(&firm_id->zfwctrl_addr)& 0xfffff); 2305 zfw_ctrl = base_addr + (readl(&firm_id->zfwctrl_addr)
2306 & 0xfffff);
2305 board_ctrl = &zfw_ctrl->board_ctrl; 2307 board_ctrl = &zfw_ctrl->board_ctrl;
2306 ch_ctrl = zfw_ctrl->ch_ctrl; 2308 ch_ctrl = zfw_ctrl->ch_ctrl;
2307 2309
@@ -2378,9 +2380,9 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2378 int retval; 2380 int retval;
2379 2381
2380 line = tty->index; 2382 line = tty->index;
2381 if ((tty->index < 0) || (NR_PORTS <= line)) { 2383 if (tty->index < 0 || NR_PORTS <= line)
2382 return -ENODEV; 2384 return -ENODEV;
2383 } 2385
2384 for (i = 0; i < NR_CARDS; i++) 2386 for (i = 0; i < NR_CARDS; i++)
2385 if (line < cy_card[i].first_line + cy_card[i].nports && 2387 if (line < cy_card[i].first_line + cy_card[i].nports &&
2386 line >= cy_card[i].first_line) 2388 line >= cy_card[i].first_line)
@@ -2388,9 +2390,8 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2388 if (i >= NR_CARDS) 2390 if (i >= NR_CARDS)
2389 return -ENODEV; 2391 return -ENODEV;
2390 info = &cy_card[i].ports[line - cy_card[i].first_line]; 2392 info = &cy_card[i].ports[line - cy_card[i].first_line];
2391 if (info->line < 0) { 2393 if (info->line < 0)
2392 return -ENODEV; 2394 return -ENODEV;
2393 }
2394 2395
2395 /* If the card's firmware hasn't been loaded, 2396 /* If the card's firmware hasn't been loaded,
2396 treat it as absent from the system. This 2397 treat it as absent from the system. This
@@ -2456,9 +2457,9 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2456#endif 2457#endif
2457 tty->driver_data = info; 2458 tty->driver_data = info;
2458 info->tty = tty; 2459 info->tty = tty;
2459 if (serial_paranoia_check(info, tty->name, "cy_open")) { 2460 if (serial_paranoia_check(info, tty->name, "cy_open"))
2460 return -ENODEV; 2461 return -ENODEV;
2461 } 2462
2462#ifdef CY_DEBUG_OPEN 2463#ifdef CY_DEBUG_OPEN
2463 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line, 2464 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
2464 info->count); 2465 info->count);
@@ -2482,9 +2483,8 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2482 * Start up serial port 2483 * Start up serial port
2483 */ 2484 */
2484 retval = startup(info); 2485 retval = startup(info);
2485 if (retval) { 2486 if (retval)
2486 return retval; 2487 return retval;
2487 }
2488 2488
2489 retval = block_til_ready(tty, filp, info); 2489 retval = block_til_ready(tty, filp, info);
2490 if (retval) { 2490 if (retval) {
@@ -2591,9 +2591,8 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2591 printk(KERN_DEBUG "cyc:cy_close ttyC%d\n", info->line); 2591 printk(KERN_DEBUG "cyc:cy_close ttyC%d\n", info->line);
2592#endif 2592#endif
2593 2593
2594 if (!info || serial_paranoia_check(info, tty->name, "cy_close")) { 2594 if (!info || serial_paranoia_check(info, tty->name, "cy_close"))
2595 return; 2595 return;
2596 }
2597 2596
2598 card = info->card; 2597 card = info->card;
2599 2598
@@ -2641,9 +2640,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2641 */ 2640 */
2642 tty->closing = 1; 2641 tty->closing = 1;
2643 spin_unlock_irqrestore(&card->card_lock, flags); 2642 spin_unlock_irqrestore(&card->card_lock, flags);
2644 if (info->closing_wait != CY_CLOSING_WAIT_NONE) { 2643 if (info->closing_wait != CY_CLOSING_WAIT_NONE)
2645 tty_wait_until_sent(tty, info->closing_wait); 2644 tty_wait_until_sent(tty, info->closing_wait);
2646 } 2645
2647 spin_lock_irqsave(&card->card_lock, flags); 2646 spin_lock_irqsave(&card->card_lock, flags);
2648 2647
2649 if (!IS_CYC_Z(*card)) { 2648 if (!IS_CYC_Z(*card)) {
@@ -2657,15 +2656,16 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2657 cy_writeb(base_addr + (CySRER << index), 2656 cy_writeb(base_addr + (CySRER << index),
2658 readb(base_addr + (CySRER << index)) & ~CyRxData); 2657 readb(base_addr + (CySRER << index)) & ~CyRxData);
2659 if (info->flags & ASYNC_INITIALIZED) { 2658 if (info->flags & ASYNC_INITIALIZED) {
2660 /* Waiting for on-board buffers to be empty before closing 2659 /* Waiting for on-board buffers to be empty before
2661 the port */ 2660 closing the port */
2662 spin_unlock_irqrestore(&card->card_lock, flags); 2661 spin_unlock_irqrestore(&card->card_lock, flags);
2663 cy_wait_until_sent(tty, info->timeout); 2662 cy_wait_until_sent(tty, info->timeout);
2664 spin_lock_irqsave(&card->card_lock, flags); 2663 spin_lock_irqsave(&card->card_lock, flags);
2665 } 2664 }
2666 } else { 2665 } else {
2667#ifdef Z_WAKE 2666#ifdef Z_WAKE
2668 /* Waiting for on-board buffers to be empty before closing the port */ 2667 /* Waiting for on-board buffers to be empty before closing
2668 the port */
2669 void __iomem *base_addr = card->base_addr; 2669 void __iomem *base_addr = card->base_addr;
2670 struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; 2670 struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
2671 struct ZFW_CTRL __iomem *zfw_ctrl = 2671 struct ZFW_CTRL __iomem *zfw_ctrl =
@@ -2738,9 +2738,8 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2738 printk(KERN_DEBUG "cyc:cy_write ttyC%d\n", info->line); 2738 printk(KERN_DEBUG "cyc:cy_write ttyC%d\n", info->line);
2739#endif 2739#endif
2740 2740
2741 if (serial_paranoia_check(info, tty->name, "cy_write")) { 2741 if (serial_paranoia_check(info, tty->name, "cy_write"))
2742 return 0; 2742 return 0;
2743 }
2744 2743
2745 if (!info->xmit_buf) 2744 if (!info->xmit_buf)
2746 return 0; 2745 return 0;
@@ -2766,9 +2765,9 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2766 info->idle_stats.xmit_bytes += ret; 2765 info->idle_stats.xmit_bytes += ret;
2767 info->idle_stats.xmit_idle = jiffies; 2766 info->idle_stats.xmit_idle = jiffies;
2768 2767
2769 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 2768 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped)
2770 start_xmit(info); 2769 start_xmit(info);
2771 } 2770
2772 return ret; 2771 return ret;
2773} /* cy_write */ 2772} /* cy_write */
2774 2773
@@ -2810,7 +2809,7 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
2810 2809
2811/* 2810/*
2812 * This routine is called by the kernel after it has written a 2811 * This routine is called by the kernel after it has written a
2813 * series of characters to the tty device using put_char(). 2812 * series of characters to the tty device using put_char().
2814 */ 2813 */
2815static void cy_flush_chars(struct tty_struct *tty) 2814static void cy_flush_chars(struct tty_struct *tty)
2816{ 2815{
@@ -2950,12 +2949,12 @@ static void set_line_char(struct cyclades_port *info)
2950 int baud, baud_rate = 0; 2949 int baud, baud_rate = 0;
2951 int i; 2950 int i;
2952 2951
2953 if (!info->tty || !info->tty->termios) { 2952 if (!info->tty || !info->tty->termios)
2954 return; 2953 return;
2955 } 2954
2956 if (info->line == -1) { 2955 if (info->line == -1)
2957 return; 2956 return;
2958 } 2957
2959 cflag = info->tty->termios->c_cflag; 2958 cflag = info->tty->termios->c_cflag;
2960 iflag = info->tty->termios->c_iflag; 2959 iflag = info->tty->termios->c_iflag;
2961 2960
@@ -2994,13 +2993,11 @@ static void set_line_char(struct cyclades_port *info)
2994 } 2993 }
2995 /* find the baud index */ 2994 /* find the baud index */
2996 for (i = 0; i < 20; i++) { 2995 for (i = 0; i < 20; i++) {
2997 if (baud == baud_table[i]) { 2996 if (baud == baud_table[i])
2998 break; 2997 break;
2999 }
3000 } 2998 }
3001 if (i == 20) { 2999 if (i == 20)
3002 i = 19; /* CD1400_MAX_SPEED */ 3000 i = 19; /* CD1400_MAX_SPEED */
3003 }
3004 3001
3005 if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == 3002 if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
3006 ASYNC_SPD_CUST) { 3003 ASYNC_SPD_CUST) {
@@ -3059,18 +3056,16 @@ static void set_line_char(struct cyclades_port *info)
3059 info->cor1 = Cy_8_BITS; 3056 info->cor1 = Cy_8_BITS;
3060 break; 3057 break;
3061 } 3058 }
3062 if (cflag & CSTOPB) { 3059 if (cflag & CSTOPB)
3063 info->cor1 |= Cy_2_STOP; 3060 info->cor1 |= Cy_2_STOP;
3064 } 3061
3065 if (cflag & PARENB) { 3062 if (cflag & PARENB) {
3066 if (cflag & PARODD) { 3063 if (cflag & PARODD)
3067 info->cor1 |= CyPARITY_O; 3064 info->cor1 |= CyPARITY_O;
3068 } else { 3065 else
3069 info->cor1 |= CyPARITY_E; 3066 info->cor1 |= CyPARITY_E;
3070 } 3067 } else
3071 } else {
3072 info->cor1 |= CyPARITY_NONE; 3068 info->cor1 |= CyPARITY_NONE;
3073 }
3074 3069
3075 /* CTS flow control flag */ 3070 /* CTS flow control flag */
3076 if (cflag & CRTSCTS) { 3071 if (cflag & CRTSCTS) {
@@ -3123,7 +3118,8 @@ static void set_line_char(struct cyclades_port *info)
3123 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch | 3118 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch |
3124 CyCOR3ch, index); 3119 CyCOR3ch, index);
3125 3120
3126 cy_writeb(base_addr + (CyCAR << index), (u_char) channel); /* !!! Is this needed? */ 3121 /* !!! Is this needed? */
3122 cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
3127 cy_writeb(base_addr + (CyRTPR << index), 3123 cy_writeb(base_addr + (CyRTPR << index),
3128 (info->default_timeout ? info->default_timeout : 0x02)); 3124 (info->default_timeout ? info->default_timeout : 0x02));
3129 /* 10ms rx timeout */ 3125 /* 10ms rx timeout */
@@ -3191,9 +3187,8 @@ static void set_line_char(struct cyclades_port *info)
3191#endif 3187#endif
3192 } 3188 }
3193 3189
3194 if (info->tty) { 3190 if (info->tty)
3195 clear_bit(TTY_IO_ERROR, &info->tty->flags); 3191 clear_bit(TTY_IO_ERROR, &info->tty->flags);
3196 }
3197 spin_unlock_irqrestore(&card->card_lock, flags); 3192 spin_unlock_irqrestore(&card->card_lock, flags);
3198 3193
3199 } else { 3194 } else {
@@ -3206,9 +3201,8 @@ static void set_line_char(struct cyclades_port *info)
3206 int retval; 3201 int retval;
3207 3202
3208 firm_id = card->base_addr + ID_ADDRESS; 3203 firm_id = card->base_addr + ID_ADDRESS;
3209 if (!ISZLOADED(*card)) { 3204 if (!ISZLOADED(*card))
3210 return; 3205 return;
3211 }
3212 3206
3213 zfw_ctrl = card->base_addr + 3207 zfw_ctrl = card->base_addr +
3214 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 3208 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -3268,14 +3262,12 @@ static void set_line_char(struct cyclades_port *info)
3268 readl(&ch_ctrl->comm_data_l) | C_DL_1STOP); 3262 readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
3269 } 3263 }
3270 if (cflag & PARENB) { 3264 if (cflag & PARENB) {
3271 if (cflag & PARODD) { 3265 if (cflag & PARODD)
3272 cy_writel(&ch_ctrl->comm_parity, C_PR_ODD); 3266 cy_writel(&ch_ctrl->comm_parity, C_PR_ODD);
3273 } else { 3267 else
3274 cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN); 3268 cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN);
3275 } 3269 } else
3276 } else {
3277 cy_writel(&ch_ctrl->comm_parity, C_PR_NONE); 3270 cy_writel(&ch_ctrl->comm_parity, C_PR_NONE);
3278 }
3279 3271
3280 /* CTS flow control flag */ 3272 /* CTS flow control flag */
3281 if (cflag & CRTSCTS) { 3273 if (cflag & CRTSCTS) {
@@ -3305,11 +3297,10 @@ static void set_line_char(struct cyclades_port *info)
3305 } 3297 }
3306 3298
3307 /* CD sensitivity */ 3299 /* CD sensitivity */
3308 if (cflag & CLOCAL) { 3300 if (cflag & CLOCAL)
3309 info->flags &= ~ASYNC_CHECK_CD; 3301 info->flags &= ~ASYNC_CHECK_CD;
3310 } else { 3302 else
3311 info->flags |= ASYNC_CHECK_CD; 3303 info->flags |= ASYNC_CHECK_CD;
3312 }
3313 3304
3314 if (baud == 0) { /* baud rate is zero, turn off line */ 3305 if (baud == 0) { /* baud rate is zero, turn off line */
3315 cy_writel(&ch_ctrl->rs_control, 3306 cy_writel(&ch_ctrl->rs_control,
@@ -3325,21 +3316,20 @@ static void set_line_char(struct cyclades_port *info)
3325#endif 3316#endif
3326 } 3317 }
3327 3318
3328 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM,0L); 3319 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM, 0L);
3329 if (retval != 0) { 3320 if (retval != 0) {
3330 printk(KERN_ERR "cyc:set_line_char(2) retval on ttyC%d " 3321 printk(KERN_ERR "cyc:set_line_char(2) retval on ttyC%d "
3331 "was %x\n", info->line, retval); 3322 "was %x\n", info->line, retval);
3332 } 3323 }
3333 3324
3334 if (info->tty) { 3325 if (info->tty)
3335 clear_bit(TTY_IO_ERROR, &info->tty->flags); 3326 clear_bit(TTY_IO_ERROR, &info->tty->flags);
3336 }
3337 } 3327 }
3338} /* set_line_char */ 3328} /* set_line_char */
3339 3329
3340static int 3330static int
3341get_serial_info(struct cyclades_port *info, 3331get_serial_info(struct cyclades_port *info,
3342 struct serial_struct __user * retinfo) 3332 struct serial_struct __user *retinfo)
3343{ 3333{
3344 struct serial_struct tmp; 3334 struct serial_struct tmp;
3345 struct cyclades_card *cinfo = info->card; 3335 struct cyclades_card *cinfo = info->card;
@@ -3363,7 +3353,7 @@ get_serial_info(struct cyclades_port *info,
3363 3353
3364static int 3354static int
3365set_serial_info(struct cyclades_port *info, 3355set_serial_info(struct cyclades_port *info,
3366 struct serial_struct __user * new_info) 3356 struct serial_struct __user *new_info)
3367{ 3357{
3368 struct serial_struct new_serial; 3358 struct serial_struct new_serial;
3369 struct cyclades_port old_info; 3359 struct cyclades_port old_info;
@@ -3417,7 +3407,7 @@ check_and_exit:
3417 * transmit holding register is empty. This functionality 3407 * transmit holding register is empty. This functionality
3418 * allows an RS485 driver to be written in user space. 3408 * allows an RS485 driver to be written in user space.
3419 */ 3409 */
3420static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value) 3410static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
3421{ 3411{
3422 struct cyclades_card *card; 3412 struct cyclades_card *card;
3423 int chip, channel, index; 3413 int chip, channel, index;
@@ -3731,8 +3721,8 @@ static void cy_break(struct tty_struct *tty, int break_state)
3731 spin_unlock_irqrestore(&card->card_lock, flags); 3721 spin_unlock_irqrestore(&card->card_lock, flags);
3732} /* cy_break */ 3722} /* cy_break */
3733 3723
3734static int 3724static int get_mon_info(struct cyclades_port *info,
3735get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon) 3725 struct cyclades_monitor __user *mon)
3736{ 3726{
3737 3727
3738 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 3728 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
@@ -3771,8 +3761,8 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
3771 return 0; 3761 return 0;
3772} /* set_threshold */ 3762} /* set_threshold */
3773 3763
3774static int 3764static int get_threshold(struct cyclades_port *info,
3775get_threshold(struct cyclades_port *info, unsigned long __user * value) 3765 unsigned long __user *value)
3776{ 3766{
3777 struct cyclades_card *card; 3767 struct cyclades_card *card;
3778 void __iomem *base_addr; 3768 void __iomem *base_addr;
@@ -3793,15 +3783,15 @@ get_threshold(struct cyclades_port *info, unsigned long __user * value)
3793 return 0; 3783 return 0;
3794} /* get_threshold */ 3784} /* get_threshold */
3795 3785
3796static int 3786static int set_default_threshold(struct cyclades_port *info,
3797set_default_threshold(struct cyclades_port *info, unsigned long value) 3787 unsigned long value)
3798{ 3788{
3799 info->default_threshold = value & 0x0f; 3789 info->default_threshold = value & 0x0f;
3800 return 0; 3790 return 0;
3801} /* set_default_threshold */ 3791} /* set_default_threshold */
3802 3792
3803static int 3793static int get_default_threshold(struct cyclades_port *info,
3804get_default_threshold(struct cyclades_port *info, unsigned long __user * value) 3794 unsigned long __user *value)
3805{ 3795{
3806 return put_user(info->default_threshold, value); 3796 return put_user(info->default_threshold, value);
3807} /* get_default_threshold */ 3797} /* get_default_threshold */
@@ -3828,7 +3818,8 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
3828 return 0; 3818 return 0;
3829} /* set_timeout */ 3819} /* set_timeout */
3830 3820
3831static int get_timeout(struct cyclades_port *info, unsigned long __user * value) 3821static int get_timeout(struct cyclades_port *info,
3822 unsigned long __user *value)
3832{ 3823{
3833 struct cyclades_card *card; 3824 struct cyclades_card *card;
3834 void __iomem *base_addr; 3825 void __iomem *base_addr;
@@ -3855,8 +3846,8 @@ static int set_default_timeout(struct cyclades_port *info, unsigned long value)
3855 return 0; 3846 return 0;
3856} /* set_default_timeout */ 3847} /* set_default_timeout */
3857 3848
3858static int 3849static int get_default_timeout(struct cyclades_port *info,
3859get_default_timeout(struct cyclades_port *info, unsigned long __user * value) 3850 unsigned long __user *value)
3860{ 3851{
3861 return put_user(info->default_timeout, value); 3852 return put_user(info->default_timeout, value);
3862} /* get_default_timeout */ 3853} /* get_default_timeout */
@@ -3941,7 +3932,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
3941 break; 3932 break;
3942#endif /* CONFIG_CYZ_INTR */ 3933#endif /* CONFIG_CYZ_INTR */
3943 case CYSETWAIT: 3934 case CYSETWAIT:
3944 info->closing_wait = (unsigned short)arg *HZ / 100; 3935 info->closing_wait = (unsigned short)arg * HZ / 100;
3945 ret_val = 0; 3936 ret_val = 0;
3946 break; 3937 break;
3947 case CYGETWAIT: 3938 case CYGETWAIT:
@@ -4118,9 +4109,8 @@ static void cy_throttle(struct tty_struct *tty)
4118 tty->ldisc.chars_in_buffer(tty), info->line); 4109 tty->ldisc.chars_in_buffer(tty), info->line);
4119#endif 4110#endif
4120 4111
4121 if (serial_paranoia_check(info, tty->name, "cy_throttle")) { 4112 if (serial_paranoia_check(info, tty->name, "cy_throttle"))
4122 return; 4113 return;
4123 }
4124 4114
4125 card = info->card; 4115 card = info->card;
4126 4116
@@ -4174,12 +4164,11 @@ static void cy_unthrottle(struct tty_struct *tty)
4174 char buf[64]; 4164 char buf[64];
4175 4165
4176 printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n", 4166 printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n",
4177 tty_name(tty, buf), tty->ldisc.chars_in_buffer(tty),info->line); 4167 tty_name(tty, buf), tty_chars_in_buffer(tty), info->line);
4178#endif 4168#endif
4179 4169
4180 if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) { 4170 if (serial_paranoia_check(info, tty->name, "cy_unthrottle"))
4181 return; 4171 return;
4182 }
4183 4172
4184 if (I_IXOFF(tty)) { 4173 if (I_IXOFF(tty)) {
4185 if (info->x_char) 4174 if (info->x_char)
@@ -4274,7 +4263,8 @@ static void cy_start(struct tty_struct *tty)
4274 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index); 4263 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
4275 4264
4276 spin_lock_irqsave(&cinfo->card_lock, flags); 4265 spin_lock_irqsave(&cinfo->card_lock, flags);
4277 cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003)); /* index channel */ 4266 cy_writeb(base_addr + (CyCAR << index),
4267 (u_char) (channel & 0x0003)); /* index channel */
4278 cy_writeb(base_addr + (CySRER << index), 4268 cy_writeb(base_addr + (CySRER << index),
4279 readb(base_addr + (CySRER << index)) | CyTxRdy); 4269 readb(base_addr + (CySRER << index)) | CyTxRdy);
4280 spin_unlock_irqrestore(&cinfo->card_lock, flags); 4270 spin_unlock_irqrestore(&cinfo->card_lock, flags);
@@ -4411,10 +4401,11 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
4411 info->cor3 = 0x08; /* _very_ small rcv threshold */ 4401 info->cor3 = 0x08; /* _very_ small rcv threshold */
4412 4402
4413 chip_number = (port - cinfo->first_line) / 4; 4403 chip_number = (port - cinfo->first_line) / 4;
4414 if ((info->chip_rev = readb(cinfo->base_addr + 4404 info->chip_rev = readb(cinfo->base_addr +
4415 (cy_chip_offset[chip_number] << 4405 (cy_chip_offset[chip_number] << index) +
4416 index) + (CyGFRCR << index))) >= 4406 (CyGFRCR << index));
4417 CD1400_REV_J) { 4407
4408 if (info->chip_rev >= CD1400_REV_J) {
4418 /* It is a CD1400 rev. J or later */ 4409 /* It is a CD1400 rev. J or later */
4419 info->tbpr = baud_bpr_60[13]; /* Tx BPR */ 4410 info->tbpr = baud_bpr_60[13]; /* Tx BPR */
4420 info->tco = baud_co_60[13]; /* Tx CO */ 4411 info->tco = baud_co_60[13]; /* Tx CO */
@@ -4459,7 +4450,8 @@ static unsigned short __devinit cyy_init_card(void __iomem *true_base_addr,
4459 /* Cy_ClrIntr is 0x1800 */ 4450 /* Cy_ClrIntr is 0x1800 */
4460 udelay(500L); 4451 udelay(500L);
4461 4452
4462 for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD; chip_number++) { 4453 for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD;
4454 chip_number++) {
4463 base_addr = 4455 base_addr =
4464 true_base_addr + (cy_chip_offset[chip_number] << index); 4456 true_base_addr + (cy_chip_offset[chip_number] << index);
4465 mdelay(1); 4457 mdelay(1);
@@ -4560,9 +4552,8 @@ static int __init cy_detect_isa(void)
4560 /* scan the address table probing for Cyclom-Y/ISA boards */ 4552 /* scan the address table probing for Cyclom-Y/ISA boards */
4561 for (i = 0; i < NR_ISA_ADDRS; i++) { 4553 for (i = 0; i < NR_ISA_ADDRS; i++) {
4562 unsigned int isa_address = cy_isa_addresses[i]; 4554 unsigned int isa_address = cy_isa_addresses[i];
4563 if (isa_address == 0x0000) { 4555 if (isa_address == 0x0000)
4564 return nboard; 4556 return nboard;
4565 }
4566 4557
4567 /* probe for CD1400... */ 4558 /* probe for CD1400... */
4568 cy_isa_address = ioremap(isa_address, CyISA_Ywin); 4559 cy_isa_address = ioremap(isa_address, CyISA_Ywin);
@@ -4852,12 +4843,10 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
4852 if (mailbox != 0) { 4843 if (mailbox != 0) {
4853 /* set window to last 512K of RAM */ 4844 /* set window to last 512K of RAM */
4854 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM + RAM_SIZE); 4845 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM + RAM_SIZE);
4855 //sleep(1);
4856 for (tmp = base_addr; tmp < base_addr + RAM_SIZE; tmp++) 4846 for (tmp = base_addr; tmp < base_addr + RAM_SIZE; tmp++)
4857 cy_writeb(tmp, 255); 4847 cy_writeb(tmp, 255);
4858 /* set window to beginning of RAM */ 4848 /* set window to beginning of RAM */
4859 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); 4849 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM);
4860 //sleep(1);
4861 } 4850 }
4862 4851
4863 retval = __cyz_load_fw(fw, "Cyclom-Z", mailbox, base_addr, NULL); 4852 retval = __cyz_load_fw(fw, "Cyclom-Z", mailbox, base_addr, NULL);
@@ -5387,7 +5376,8 @@ static void __exit cy_cleanup_module(void)
5387 del_timer_sync(&cyz_timerlist); 5376 del_timer_sync(&cyz_timerlist);
5388#endif /* CONFIG_CYZ_INTR */ 5377#endif /* CONFIG_CYZ_INTR */
5389 5378
5390 if ((e1 = tty_unregister_driver(cy_serial_driver))) 5379 e1 = tty_unregister_driver(cy_serial_driver);
5380 if (e1)
5391 printk(KERN_ERR "failed to unregister Cyclades serial " 5381 printk(KERN_ERR "failed to unregister Cyclades serial "
5392 "driver(%d)\n", e1); 5382 "driver(%d)\n", e1);
5393 5383