aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/epca.c276
1 files changed, 158 insertions, 118 deletions
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 39c6a36e395b..60a4df7dac12 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -38,8 +38,8 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <asm/uaccess.h> 41#include <linux/uaccess.h>
42#include <asm/io.h> 42#include <linux/io.h>
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include "digiPCI.h" 45#include "digiPCI.h"
@@ -73,7 +73,8 @@ static int invalid_lilo_config;
73 */ 73 */
74static DEFINE_SPINLOCK(epca_lock); 74static DEFINE_SPINLOCK(epca_lock);
75 75
76/* MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 7 below. */ 76/* MAXBOARDS is typically 12, but ISA and EISA cards are restricted
77 to 7 below. */
77static struct board_info boards[MAXBOARDS]; 78static struct board_info boards[MAXBOARDS];
78 79
79static struct tty_driver *pc_driver; 80static struct tty_driver *pc_driver;
@@ -162,7 +163,7 @@ static int pc_chars_in_buffer(struct tty_struct *);
162static void pc_flush_buffer(struct tty_struct *); 163static void pc_flush_buffer(struct tty_struct *);
163static void pc_flush_chars(struct tty_struct *); 164static void pc_flush_chars(struct tty_struct *);
164static int block_til_ready(struct tty_struct *, struct file *, 165static int block_til_ready(struct tty_struct *, struct file *,
165 struct channel *); 166 struct channel *);
166static int pc_open(struct tty_struct *, struct file *); 167static int pc_open(struct tty_struct *, struct file *);
167static void post_fep_init(unsigned int crd); 168static void post_fep_init(unsigned int crd);
168static void epcapoll(unsigned long); 169static void epcapoll(unsigned long);
@@ -174,18 +175,18 @@ static unsigned termios2digi_c(struct channel *ch, unsigned);
174static void epcaparam(struct tty_struct *, struct channel *); 175static void epcaparam(struct tty_struct *, struct channel *);
175static void receive_data(struct channel *); 176static void receive_data(struct channel *);
176static int pc_ioctl(struct tty_struct *, struct file *, 177static int pc_ioctl(struct tty_struct *, struct file *,
177 unsigned int, unsigned long); 178 unsigned int, unsigned long);
178static int info_ioctl(struct tty_struct *, struct file *, 179static int info_ioctl(struct tty_struct *, struct file *,
179 unsigned int, unsigned long); 180 unsigned int, unsigned long);
180static void pc_set_termios(struct tty_struct *, struct ktermios *); 181static void pc_set_termios(struct tty_struct *, struct ktermios *);
181static void do_softint(struct work_struct *work); 182static void do_softint(struct work_struct *work);
182static void pc_stop(struct tty_struct *); 183static void pc_stop(struct tty_struct *);
183static void pc_start(struct tty_struct *); 184static void pc_start(struct tty_struct *);
184static void pc_throttle(struct tty_struct * tty); 185static void pc_throttle(struct tty_struct *tty);
185static void pc_unthrottle(struct tty_struct *tty); 186static void pc_unthrottle(struct tty_struct *tty);
186static void digi_send_break(struct channel *ch, int msec); 187static void digi_send_break(struct channel *ch, int msec);
187static void setup_empty_event(struct tty_struct *tty, struct channel *ch); 188static void setup_empty_event(struct tty_struct *tty, struct channel *ch);
188void epca_setup(char *, int *); 189static void epca_setup(char *, int *);
189 190
190static int pc_write(struct tty_struct *, const unsigned char *, int); 191static int pc_write(struct tty_struct *, const unsigned char *, int);
191static int pc_init(void); 192static int pc_init(void);
@@ -242,7 +243,7 @@ static void assertmemoff(struct channel *ch)
242/* PCXEM windowing is the same as that used in the PCXR and CX series cards. */ 243/* PCXEM windowing is the same as that used in the PCXR and CX series cards. */
243static void pcxem_memwinon(struct board_info *b, unsigned int win) 244static void pcxem_memwinon(struct board_info *b, unsigned int win)
244{ 245{
245 outb_p(FEPWIN|win, b->port + 1); 246 outb_p(FEPWIN | win, b->port + 1);
246} 247}
247 248
248static void pcxem_memwinoff(struct board_info *b, unsigned int win) 249static void pcxem_memwinoff(struct board_info *b, unsigned int win)
@@ -252,7 +253,7 @@ static void pcxem_memwinoff(struct board_info *b, unsigned int win)
252 253
253static void pcxem_globalwinon(struct channel *ch) 254static void pcxem_globalwinon(struct channel *ch)
254{ 255{
255 outb_p( FEPWIN, (int)ch->board->port + 1); 256 outb_p(FEPWIN, (int)ch->board->port + 1);
256} 257}
257 258
258static void pcxem_rxwinon(struct channel *ch) 259static void pcxem_rxwinon(struct channel *ch)
@@ -393,7 +394,7 @@ static struct channel *verifyChannel(struct tty_struct *tty)
393 */ 394 */
394 if (tty) { 395 if (tty) {
395 struct channel *ch = (struct channel *)tty->driver_data; 396 struct channel *ch = (struct channel *)tty->driver_data;
396 if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) { 397 if (ch >= &digi_channels[0] && ch < &digi_channels[nbdevs]) {
397 if (ch->magic == EPCA_MAGIC) 398 if (ch->magic == EPCA_MAGIC)
398 return ch; 399 return ch;
399 } 400 }
@@ -413,7 +414,7 @@ static void pc_sched_event(struct channel *ch, int event)
413 414
414static void epca_error(int line, char *msg) 415static void epca_error(int line, char *msg)
415{ 416{
416 printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); 417 printk(KERN_ERR "epca_error (Digi): line = %d %s\n", line, msg);
417} 418}
418 419
419static void pc_close(struct tty_struct *tty, struct file *filp) 420static void pc_close(struct tty_struct *tty, struct file *filp)
@@ -424,7 +425,8 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
424 * verifyChannel returns the channel from the tty struct if it is 425 * verifyChannel returns the channel from the tty struct if it is
425 * valid. This serves as a sanity check. 426 * valid. This serves as a sanity check.
426 */ 427 */
427 if ((ch = verifyChannel(tty)) != NULL) { 428 ch = verifyChannel(tty);
429 if (ch != NULL) {
428 spin_lock_irqsave(&epca_lock, flags); 430 spin_lock_irqsave(&epca_lock, flags);
429 if (tty_hung_up_p(filp)) { 431 if (tty_hung_up_p(filp)) {
430 spin_unlock_irqrestore(&epca_lock, flags); 432 spin_unlock_irqrestore(&epca_lock, flags);
@@ -439,7 +441,6 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
439 spin_unlock_irqrestore(&epca_lock, flags); 441 spin_unlock_irqrestore(&epca_lock, flags);
440 return; 442 return;
441 } 443 }
442
443 /* Port open only once go ahead with shutdown & reset */ 444 /* Port open only once go ahead with shutdown & reset */
444 BUG_ON(ch->count < 0); 445 BUG_ON(ch->count < 0);
445 446
@@ -454,9 +455,11 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
454 spin_unlock_irqrestore(&epca_lock, flags); 455 spin_unlock_irqrestore(&epca_lock, flags);
455 456
456 if (ch->asyncflags & ASYNC_INITIALIZED) { 457 if (ch->asyncflags & ASYNC_INITIALIZED) {
457 /* Setup an event to indicate when the transmit buffer empties */ 458 /* Setup an event to indicate when the
459 transmit buffer empties */
458 setup_empty_event(tty, ch); 460 setup_empty_event(tty, ch);
459 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 461 /* 30 seconds timeout */
462 tty_wait_until_sent(tty, 3000);
460 } 463 }
461 pc_flush_buffer(tty); 464 pc_flush_buffer(tty);
462 465
@@ -475,7 +478,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
475 wake_up_interruptible(&ch->open_wait); 478 wake_up_interruptible(&ch->open_wait);
476 } 479 }
477 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | 480 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
478 ASYNC_CLOSING); 481 ASYNC_CLOSING);
479 wake_up_interruptible(&ch->close_wait); 482 wake_up_interruptible(&ch->close_wait);
480 } 483 }
481} 484}
@@ -522,12 +525,12 @@ static void shutdown(struct channel *ch)
522static void pc_hangup(struct tty_struct *tty) 525static void pc_hangup(struct tty_struct *tty)
523{ 526{
524 struct channel *ch; 527 struct channel *ch;
525
526 /* 528 /*
527 * verifyChannel returns the channel from the tty struct if it is 529 * verifyChannel returns the channel from the tty struct if it is
528 * valid. This serves as a sanity check. 530 * valid. This serves as a sanity check.
529 */ 531 */
530 if ((ch = verifyChannel(tty)) != NULL) { 532 ch = verifyChannel(tty);
533 if (ch != NULL) {
531 unsigned long flags; 534 unsigned long flags;
532 535
533 pc_flush_buffer(tty); 536 pc_flush_buffer(tty);
@@ -545,7 +548,7 @@ static void pc_hangup(struct tty_struct *tty)
545} 548}
546 549
547static int pc_write(struct tty_struct *tty, 550static int pc_write(struct tty_struct *tty,
548 const unsigned char *buf, int bytesAvailable) 551 const unsigned char *buf, int bytesAvailable)
549{ 552{
550 unsigned int head, tail; 553 unsigned int head, tail;
551 int dataLen; 554 int dataLen;
@@ -569,7 +572,8 @@ static int pc_write(struct tty_struct *tty,
569 * verifyChannel returns the channel from the tty struct if it is 572 * verifyChannel returns the channel from the tty struct if it is
570 * valid. This serves as a sanity check. 573 * valid. This serves as a sanity check.
571 */ 574 */
572 if ((ch = verifyChannel(tty)) == NULL) 575 ch = verifyChannel(tty);
576 if (ch == NULL)
573 return 0; 577 return 0;
574 578
575 /* Make a pointer to the channel data structure found on the board. */ 579 /* Make a pointer to the channel data structure found on the board. */
@@ -644,19 +648,17 @@ static int pc_write(struct tty_struct *tty,
644 648
645static int pc_write_room(struct tty_struct *tty) 649static int pc_write_room(struct tty_struct *tty)
646{ 650{
647 int remain; 651 int remain = 0;
648 struct channel *ch; 652 struct channel *ch;
649 unsigned long flags; 653 unsigned long flags;
650 unsigned int head, tail; 654 unsigned int head, tail;
651 struct board_chan __iomem *bc; 655 struct board_chan __iomem *bc;
652
653 remain = 0;
654
655 /* 656 /*
656 * verifyChannel returns the channel from the tty struct if it is 657 * verifyChannel returns the channel from the tty struct if it is
657 * valid. This serves as a sanity check. 658 * valid. This serves as a sanity check.
658 */ 659 */
659 if ((ch = verifyChannel(tty)) != NULL) { 660 ch = verifyChannel(tty);
661 if (ch != NULL) {
660 spin_lock_irqsave(&epca_lock, flags); 662 spin_lock_irqsave(&epca_lock, flags);
661 globalwinon(ch); 663 globalwinon(ch);
662 664
@@ -668,8 +670,8 @@ static int pc_write_room(struct tty_struct *tty)
668 tail = readw(&bc->tout); 670 tail = readw(&bc->tout);
669 /* Wrap tail if necessary */ 671 /* Wrap tail if necessary */
670 tail &= (ch->txbufsize - 1); 672 tail &= (ch->txbufsize - 1);
671 673 remain = tail - head - 1;
672 if ((remain = tail - head - 1) < 0 ) 674 if (remain < 0)
673 remain += ch->txbufsize; 675 remain += ch->txbufsize;
674 676
675 if (remain && (ch->statusflags & LOWWAIT) == 0) { 677 if (remain && (ch->statusflags & LOWWAIT) == 0) {
@@ -691,12 +693,12 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
691 unsigned long flags; 693 unsigned long flags;
692 struct channel *ch; 694 struct channel *ch;
693 struct board_chan __iomem *bc; 695 struct board_chan __iomem *bc;
694
695 /* 696 /*
696 * verifyChannel returns the channel from the tty struct if it is 697 * verifyChannel returns the channel from the tty struct if it is
697 * valid. This serves as a sanity check. 698 * valid. This serves as a sanity check.
698 */ 699 */
699 if ((ch = verifyChannel(tty)) == NULL) 700 ch = verifyChannel(tty);
701 if (ch == NULL)
700 return 0; 702 return 0;
701 703
702 spin_lock_irqsave(&epca_lock, flags); 704 spin_lock_irqsave(&epca_lock, flags);
@@ -707,7 +709,8 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
707 head = readw(&bc->tin); 709 head = readw(&bc->tin);
708 ctail = readw(&ch->mailbox->cout); 710 ctail = readw(&ch->mailbox->cout);
709 711
710 if (tail == head && readw(&ch->mailbox->cin) == ctail && readb(&bc->tbusy) == 0) 712 if (tail == head && readw(&ch->mailbox->cin) == ctail &&
713 readb(&bc->tbusy) == 0)
711 chars = 0; 714 chars = 0;
712 else { /* Begin if some space on the card has been used */ 715 else { /* Begin if some space on the card has been used */
713 head = readw(&bc->tin) & (ch->txbufsize - 1); 716 head = readw(&bc->tin) & (ch->txbufsize - 1);
@@ -717,7 +720,8 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
717 * pc_write_room here we are finding the amount of bytes in the 720 * pc_write_room here we are finding the amount of bytes in the
718 * buffer filled. Not the amount of bytes empty. 721 * buffer filled. Not the amount of bytes empty.
719 */ 722 */
720 if ((remain = tail - head - 1) < 0 ) 723 remain = tail - head - 1;
724 if (remain < 0)
721 remain += ch->txbufsize; 725 remain += ch->txbufsize;
722 chars = (int)(ch->txbufsize - remain); 726 chars = (int)(ch->txbufsize - remain);
723 /* 727 /*
@@ -728,7 +732,7 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
728 * transmit buffer empties. 732 * transmit buffer empties.
729 */ 733 */
730 if (!(ch->statusflags & EMPTYWAIT)) 734 if (!(ch->statusflags & EMPTYWAIT))
731 setup_empty_event(tty,ch); 735 setup_empty_event(tty, ch);
732 } /* End if some space on the card has been used */ 736 } /* End if some space on the card has been used */
733 memoff(ch); 737 memoff(ch);
734 spin_unlock_irqrestore(&epca_lock, flags); 738 spin_unlock_irqrestore(&epca_lock, flags);
@@ -746,7 +750,8 @@ static void pc_flush_buffer(struct tty_struct *tty)
746 * verifyChannel returns the channel from the tty struct if it is 750 * verifyChannel returns the channel from the tty struct if it is
747 * valid. This serves as a sanity check. 751 * valid. This serves as a sanity check.
748 */ 752 */
749 if ((ch = verifyChannel(tty)) == NULL) 753 ch = verifyChannel(tty);
754 if (ch == NULL)
750 return; 755 return;
751 756
752 spin_lock_irqsave(&epca_lock, flags); 757 spin_lock_irqsave(&epca_lock, flags);
@@ -767,23 +772,25 @@ static void pc_flush_chars(struct tty_struct *tty)
767 * verifyChannel returns the channel from the tty struct if it is 772 * verifyChannel returns the channel from the tty struct if it is
768 * valid. This serves as a sanity check. 773 * valid. This serves as a sanity check.
769 */ 774 */
770 if ((ch = verifyChannel(tty)) != NULL) { 775 ch = verifyChannel(tty);
776 if (ch != NULL) {
771 unsigned long flags; 777 unsigned long flags;
772 spin_lock_irqsave(&epca_lock, flags); 778 spin_lock_irqsave(&epca_lock, flags);
773 /* 779 /*
774 * If not already set and the transmitter is busy setup an 780 * If not already set and the transmitter is busy setup an
775 * event to indicate when the transmit empties. 781 * event to indicate when the transmit empties.
776 */ 782 */
777 if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) 783 if ((ch->statusflags & TXBUSY) &&
778 setup_empty_event(tty,ch); 784 !(ch->statusflags & EMPTYWAIT))
785 setup_empty_event(tty, ch);
779 spin_unlock_irqrestore(&epca_lock, flags); 786 spin_unlock_irqrestore(&epca_lock, flags);
780 } 787 }
781} 788}
782 789
783static int block_til_ready(struct tty_struct *tty, 790static int block_til_ready(struct tty_struct *tty,
784 struct file *filp, struct channel *ch) 791 struct file *filp, struct channel *ch)
785{ 792{
786 DECLARE_WAITQUEUE(wait,current); 793 DECLARE_WAITQUEUE(wait, current);
787 int retval, do_clocal = 0; 794 int retval, do_clocal = 0;
788 unsigned long flags; 795 unsigned long flags;
789 796
@@ -831,8 +838,7 @@ static int block_til_ready(struct tty_struct *tty,
831 while (1) { 838 while (1) {
832 set_current_state(TASK_INTERRUPTIBLE); 839 set_current_state(TASK_INTERRUPTIBLE);
833 if (tty_hung_up_p(filp) || 840 if (tty_hung_up_p(filp) ||
834 !(ch->asyncflags & ASYNC_INITIALIZED)) 841 !(ch->asyncflags & ASYNC_INITIALIZED)) {
835 {
836 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 842 if (ch->asyncflags & ASYNC_HUP_NOTIFY)
837 retval = -EAGAIN; 843 retval = -EAGAIN;
838 else 844 else
@@ -872,7 +878,7 @@ static int block_til_ready(struct tty_struct *tty,
872 return 0; 878 return 0;
873} 879}
874 880
875static int pc_open(struct tty_struct *tty, struct file * filp) 881static int pc_open(struct tty_struct *tty, struct file *filp)
876{ 882{
877 struct channel *ch; 883 struct channel *ch;
878 unsigned long flags; 884 unsigned long flags;
@@ -957,7 +963,7 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
957 * The below routine generally sets up parity, baud, flow control 963 * The below routine generally sets up parity, baud, flow control
958 * issues, etc.... It effect both control flags and input flags. 964 * issues, etc.... It effect both control flags and input flags.
959 */ 965 */
960 epcaparam(tty,ch); 966 epcaparam(tty, ch);
961 ch->asyncflags |= ASYNC_INITIALIZED; 967 ch->asyncflags |= ASYNC_INITIALIZED;
962 memoff(ch); 968 memoff(ch);
963 spin_unlock_irqrestore(&epca_lock, flags); 969 spin_unlock_irqrestore(&epca_lock, flags);
@@ -995,8 +1001,8 @@ static void __exit epca_module_exit(void)
995 1001
996 del_timer_sync(&epca_timer); 1002 del_timer_sync(&epca_timer);
997 1003
998 if (tty_unregister_driver(pc_driver) || tty_unregister_driver(pc_info)) 1004 if (tty_unregister_driver(pc_driver) ||
999 { 1005 tty_unregister_driver(pc_info)) {
1000 printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n"); 1006 printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n");
1001 return; 1007 return;
1002 } 1008 }
@@ -1036,7 +1042,7 @@ static const struct tty_operations pc_ops = {
1036 .hangup = pc_hangup, 1042 .hangup = pc_hangup,
1037}; 1043};
1038 1044
1039static int info_open(struct tty_struct *tty, struct file * filp) 1045static int info_open(struct tty_struct *tty, struct file *filp)
1040{ 1046{
1041 return 0; 1047 return 0;
1042} 1048}
@@ -1091,7 +1097,7 @@ static int __init pc_init(void)
1091 * Set up interrupt, we will worry about memory allocation in 1097 * Set up interrupt, we will worry about memory allocation in
1092 * post_fep_init. 1098 * post_fep_init.
1093 */ 1099 */
1094 printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); 1100 printk(KERN_INFO "DIGI epca driver version %s loaded.\n", VERSION);
1095 1101
1096 /* 1102 /*
1097 * NOTE : This code assumes that the number of ports found in the 1103 * NOTE : This code assumes that the number of ports found in the
@@ -1244,7 +1250,7 @@ static int __init pc_init(void)
1244 if ((board_id & 0x30) == 0x30) 1250 if ((board_id & 0x30) == 0x30)
1245 bd->memory_seg = 0x8000; 1251 bd->memory_seg = 0x8000;
1246 } else 1252 } else
1247 printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); 1253 printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n", (int)bd->port);
1248 break; 1254 break;
1249 } 1255 }
1250 } 1256 }
@@ -1318,12 +1324,12 @@ static void post_fep_init(unsigned int crd)
1318 */ 1324 */
1319 /* PCI cards are already remapped at this point ISA are not */ 1325 /* PCI cards are already remapped at this point ISA are not */
1320 bd->numports = readw(bd->re_map_membase + XEMPORTS); 1326 bd->numports = readw(bd->re_map_membase + XEMPORTS);
1321 epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); 1327 epcaassert(bd->numports <= 64, "PCI returned a invalid number of ports");
1322 nbdevs += (bd->numports); 1328 nbdevs += (bd->numports);
1323 } else { 1329 } else {
1324 /* Fix up the mappings for ISA/EISA etc */ 1330 /* Fix up the mappings for ISA/EISA etc */
1325 /* FIXME: 64K - can we be smarter ? */ 1331 /* FIXME: 64K - can we be smarter ? */
1326 bd->re_map_membase = ioremap(bd->membase, 0x10000); 1332 bd->re_map_membase = ioremap_nocache(bd->membase, 0x10000);
1327 } 1333 }
1328 1334
1329 if (crd != 0) 1335 if (crd != 0)
@@ -1354,7 +1360,8 @@ static void post_fep_init(unsigned int crd)
1354 * XEPORTS (address 0xc22) points at the number of channels the card 1360 * XEPORTS (address 0xc22) points at the number of channels the card
1355 * supports. (For 64XE, XI, XEM, and XR use 0xc02) 1361 * supports. (For 64XE, XI, XEM, and XR use 0xc02)
1356 */ 1362 */
1357 if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3)) 1363 if ((bd->type == PCXEVE || bd->type == PCXE) &&
1364 (readw(memaddr + XEPORTS) < 3))
1358 shrinkmem = 1; 1365 shrinkmem = 1;
1359 if (bd->type < PCIXEM) 1366 if (bd->type < PCIXEM)
1360 if (!request_region((int)bd->port, 4, board_desc[bd->type])) 1367 if (!request_region((int)bd->port, 4, board_desc[bd->type]))
@@ -1453,10 +1460,12 @@ static void post_fep_init(unsigned int crd)
1453 1460
1454 case PCXEVE: 1461 case PCXEVE:
1455 case PCXE: 1462 case PCXE:
1456 ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4) & 0x1fff); 1463 ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4)
1464 & 0x1fff);
1457 ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9); 1465 ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9);
1458 ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4) & 0x1fff); 1466 ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4)
1459 ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >>9 ); 1467 & 0x1fff);
1468 ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >> 9);
1460 break; 1469 break;
1461 1470
1462 case PCXI: 1471 case PCXI:
@@ -1510,8 +1519,9 @@ static void post_fep_init(unsigned int crd)
1510 } 1519 }
1511 1520
1512 printk(KERN_INFO 1521 printk(KERN_INFO
1513 "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", 1522 "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n",
1514 VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); 1523 VERSION, board_desc[bd->type], (long)bd->port,
1524 (long)bd->membase, bd->numports);
1515 memwinoff(bd, 0); 1525 memwinoff(bd, 0);
1516} 1526}
1517 1527
@@ -1519,7 +1529,7 @@ static void epcapoll(unsigned long ignored)
1519{ 1529{
1520 unsigned long flags; 1530 unsigned long flags;
1521 int crd; 1531 int crd;
1522 volatile unsigned int head, tail; 1532 unsigned int head, tail;
1523 struct channel *ch; 1533 struct channel *ch;
1524 struct board_info *bd; 1534 struct board_info *bd;
1525 1535
@@ -1585,7 +1595,9 @@ static void doevent(int crd)
1585 chan0 = card_ptr[crd]; 1595 chan0 = card_ptr[crd];
1586 epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); 1596 epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range");
1587 assertgwinon(chan0); 1597 assertgwinon(chan0);
1588 while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) { /* Begin while something in event queue */ 1598 while ((tail = readw(&chan0->mailbox->eout)) !=
1599 (head = readw(&chan0->mailbox->ein))) {
1600 /* Begin while something in event queue */
1589 assertgwinon(chan0); 1601 assertgwinon(chan0);
1590 eventbuf = bd->re_map_membase + tail + ISTART; 1602 eventbuf = bd->re_map_membase + tail + ISTART;
1591 /* Get the channel the event occurred on */ 1603 /* Get the channel the event occurred on */
@@ -1609,7 +1621,8 @@ static void doevent(int crd)
1609 goto next; 1621 goto next;
1610 } 1622 }
1611 1623
1612 if ((bc = ch->brdchan) == NULL) 1624 bc = ch->brdchan;
1625 if (bc == NULL)
1613 goto next; 1626 goto next;
1614 1627
1615 if (event & DATA_IND) { /* Begin DATA_IND */ 1628 if (event & DATA_IND) { /* Begin DATA_IND */
@@ -1621,10 +1634,11 @@ static void doevent(int crd)
1621 /* A modem signal change has been indicated */ 1634 /* A modem signal change has been indicated */
1622 ch->imodem = mstat; 1635 ch->imodem = mstat;
1623 if (ch->asyncflags & ASYNC_CHECK_CD) { 1636 if (ch->asyncflags & ASYNC_CHECK_CD) {
1624 if (mstat & ch->dcd) /* We are now receiving dcd */ 1637 /* We are now receiving dcd */
1638 if (mstat & ch->dcd)
1625 wake_up_interruptible(&ch->open_wait); 1639 wake_up_interruptible(&ch->open_wait);
1626 else 1640 else /* No dcd; hangup */
1627 pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ 1641 pc_sched_event(ch, EPCA_EVENT_HANGUP);
1628 } 1642 }
1629 } 1643 }
1630 tty = ch->tty; 1644 tty = ch->tty;
@@ -1639,7 +1653,8 @@ static void doevent(int crd)
1639 tty_wakeup(tty); 1653 tty_wakeup(tty);
1640 } 1654 }
1641 } else if (event & EMPTYTX_IND) { 1655 } else if (event & EMPTYTX_IND) {
1642 /* This event is generated by setup_empty_event */ 1656 /* This event is generated by
1657 setup_empty_event */
1643 ch->statusflags &= ~TXBUSY; 1658 ch->statusflags &= ~TXBUSY;
1644 if (ch->statusflags & EMPTYWAIT) { 1659 if (ch->statusflags & EMPTYWAIT) {
1645 ch->statusflags &= ~EMPTYWAIT; 1660 ch->statusflags &= ~EMPTYWAIT;
@@ -1647,7 +1662,7 @@ static void doevent(int crd)
1647 } 1662 }
1648 } 1663 }
1649 } 1664 }
1650 next: 1665next:
1651 globalwinon(ch); 1666 globalwinon(ch);
1652 BUG_ON(!bc); 1667 BUG_ON(!bc);
1653 writew(1, &bc->idata); 1668 writew(1, &bc->idata);
@@ -1657,7 +1672,7 @@ static void doevent(int crd)
1657} 1672}
1658 1673
1659static void fepcmd(struct channel *ch, int cmd, int word_or_byte, 1674static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1660 int byte2, int ncmds, int bytecmd) 1675 int byte2, int ncmds, int bytecmd)
1661{ 1676{
1662 unchar __iomem *memaddr; 1677 unchar __iomem *memaddr;
1663 unsigned int head, cmdTail, cmdStart, cmdMax; 1678 unsigned int head, cmdTail, cmdStart, cmdMax;
@@ -1682,8 +1697,10 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1682 memaddr = ch->board->re_map_membase; 1697 memaddr = ch->board->re_map_membase;
1683 1698
1684 if (head >= (cmdMax - cmdStart) || (head & 03)) { 1699 if (head >= (cmdMax - cmdStart) || (head & 03)) {
1685 printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, cmd, head); 1700 printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n",
1686 printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, cmdMax, cmdStart); 1701 __LINE__, cmd, head);
1702 printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n",
1703 __LINE__, cmdMax, cmdStart);
1687 return; 1704 return;
1688 } 1705 }
1689 if (bytecmd) { 1706 if (bytecmd) {
@@ -1762,7 +1779,7 @@ static unsigned termios2digi_h(struct channel *ch, unsigned cflag)
1762static unsigned termios2digi_i(struct channel *ch, unsigned iflag) 1779static unsigned termios2digi_i(struct channel *ch, unsigned iflag)
1763{ 1780{
1764 unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | 1781 unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK |
1765 INPCK | ISTRIP|IXON|IXANY|IXOFF); 1782 INPCK | ISTRIP | IXON | IXANY | IXOFF);
1766 if (ch->digiext.digi_flags & DIGI_AIXON) 1783 if (ch->digiext.digi_flags & DIGI_AIXON)
1767 res |= IAIXON; 1784 res |= IAIXON;
1768 return res; 1785 return res;
@@ -1876,8 +1893,10 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
1876 * Command sets channels iflag structure on the board. Such 1893 * Command sets channels iflag structure on the board. Such
1877 * things as input soft flow control, handling of parity 1894 * things as input soft flow control, handling of parity
1878 * errors, and break handling are all set here. 1895 * errors, and break handling are all set here.
1896 *
1897 * break handling, parity handling, input stripping,
1898 * flow control chars
1879 */ 1899 */
1880 /* break handling, parity handling, input stripping, flow control chars */
1881 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); 1900 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0);
1882 } 1901 }
1883 /* 1902 /*
@@ -1973,7 +1992,7 @@ static void receive_data(struct channel *ch)
1973 return; 1992 return;
1974 1993
1975 /* If CREAD bit is off or device not open, set TX tail to head */ 1994 /* If CREAD bit is off or device not open, set TX tail to head */
1976 if (!tty || !ts || !(ts->c_cflag & CREAD)) { 1995 if (!tty || !ts || !(ts->c_cflag & CREAD)) {
1977 writew(head, &bc->rout); 1996 writew(head, &bc->rout);
1978 return; 1997 return;
1979 } 1998 }
@@ -1983,18 +2002,21 @@ static void receive_data(struct channel *ch)
1983 2002
1984 if (readb(&bc->orun)) { 2003 if (readb(&bc->orun)) {
1985 writeb(0, &bc->orun); 2004 writeb(0, &bc->orun);
1986 printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); 2005 printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",
2006 tty->name);
1987 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 2007 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1988 } 2008 }
1989 rxwinon(ch); 2009 rxwinon(ch);
1990 while (bytesAvailable > 0) { /* Begin while there is data on the card */ 2010 while (bytesAvailable > 0) {
2011 /* Begin while there is data on the card */
1991 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; 2012 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail;
1992 /* 2013 /*
1993 * Even if head has wrapped around only report the amount of 2014 * Even if head has wrapped around only report the amount of
1994 * data to be equal to the size - tail. Remember memcpy can't 2015 * data to be equal to the size - tail. Remember memcpy can't
1995 * automaticly wrap around the receive buffer. 2016 * automaticly wrap around the receive buffer.
1996 */ 2017 */
1997 dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; 2018 dataToRead = (wrapgap < bytesAvailable) ? wrapgap
2019 : bytesAvailable;
1998 /* Make sure we don't overflow the buffer */ 2020 /* Make sure we don't overflow the buffer */
1999 dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead); 2021 dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead);
2000 if (dataToRead == 0) 2022 if (dataToRead == 0)
@@ -2145,14 +2167,14 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file,
2145 * The below routine generally sets up parity, baud, flow control 2167 * The below routine generally sets up parity, baud, flow control
2146 * issues, etc.... It effect both control flags and input flags. 2168 * issues, etc.... It effect both control flags and input flags.
2147 */ 2169 */
2148 epcaparam(tty,ch); 2170 epcaparam(tty, ch);
2149 memoff(ch); 2171 memoff(ch);
2150 spin_unlock_irqrestore(&epca_lock, flags); 2172 spin_unlock_irqrestore(&epca_lock, flags);
2151 return 0; 2173 return 0;
2152} 2174}
2153 2175
2154static int pc_ioctl(struct tty_struct *tty, struct file * file, 2176static int pc_ioctl(struct tty_struct *tty, struct file *file,
2155 unsigned int cmd, unsigned long arg) 2177 unsigned int cmd, unsigned long arg)
2156{ 2178{
2157 digiflow_t dflow; 2179 digiflow_t dflow;
2158 int retval; 2180 int retval;
@@ -2167,7 +2189,6 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2167 bc = ch->brdchan; 2189 bc = ch->brdchan;
2168 else 2190 else
2169 return -EINVAL; 2191 return -EINVAL;
2170
2171 /* 2192 /*
2172 * For POSIX compliance we need to add more ioctls. See tty_ioctl.c in 2193 * For POSIX compliance we need to add more ioctls. See tty_ioctl.c in
2173 * /usr/src/linux/drivers/char for a good example. In particular think 2194 * /usr/src/linux/drivers/char for a good example. In particular think
@@ -2178,9 +2199,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2178 retval = tty_check_change(tty); 2199 retval = tty_check_change(tty);
2179 if (retval) 2200 if (retval)
2180 return retval; 2201 return retval;
2181 /* Setup an event to indicate when the transmit buffer empties */ 2202 /* Setup an event to indicate when the transmit
2203 buffer empties */
2182 spin_lock_irqsave(&epca_lock, flags); 2204 spin_lock_irqsave(&epca_lock, flags);
2183 setup_empty_event(tty,ch); 2205 setup_empty_event(tty, ch);
2184 spin_unlock_irqrestore(&epca_lock, flags); 2206 spin_unlock_irqrestore(&epca_lock, flags);
2185 tty_wait_until_sent(tty, 0); 2207 tty_wait_until_sent(tty, 0);
2186 if (!arg) 2208 if (!arg)
@@ -2190,10 +2212,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2190 retval = tty_check_change(tty); 2212 retval = tty_check_change(tty);
2191 if (retval) 2213 if (retval)
2192 return retval; 2214 return retval;
2193 2215 /* Setup an event to indicate when the transmit buffer
2194 /* Setup an event to indicate when the transmit buffer empties */ 2216 empties */
2195 spin_lock_irqsave(&epca_lock, flags); 2217 spin_lock_irqsave(&epca_lock, flags);
2196 setup_empty_event(tty,ch); 2218 setup_empty_event(tty, ch);
2197 spin_unlock_irqrestore(&epca_lock, flags); 2219 spin_unlock_irqrestore(&epca_lock, flags);
2198 tty_wait_until_sent(tty, 0); 2220 tty_wait_until_sent(tty, 0);
2199 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); 2221 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4);
@@ -2232,9 +2254,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2232 case DIGI_SETAF: 2254 case DIGI_SETAF:
2233 lock_kernel(); 2255 lock_kernel();
2234 if (cmd == DIGI_SETAW) { 2256 if (cmd == DIGI_SETAW) {
2235 /* Setup an event to indicate when the transmit buffer empties */ 2257 /* Setup an event to indicate when the transmit
2258 buffer empties */
2236 spin_lock_irqsave(&epca_lock, flags); 2259 spin_lock_irqsave(&epca_lock, flags);
2237 setup_empty_event(tty,ch); 2260 setup_empty_event(tty, ch);
2238 spin_unlock_irqrestore(&epca_lock, flags); 2261 spin_unlock_irqrestore(&epca_lock, flags);
2239 tty_wait_until_sent(tty, 0); 2262 tty_wait_until_sent(tty, 0);
2240 } else { 2263 } else {
@@ -2264,7 +2287,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2264 * control issues, etc.... It effect both control flags and 2287 * control issues, etc.... It effect both control flags and
2265 * input flags. 2288 * input flags.
2266 */ 2289 */
2267 epcaparam(tty,ch); 2290 epcaparam(tty, ch);
2268 memoff(ch); 2291 memoff(ch);
2269 spin_unlock_irqrestore(&epca_lock, flags); 2292 spin_unlock_irqrestore(&epca_lock, flags);
2270 break; 2293 break;
@@ -2300,18 +2323,21 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2300 if (copy_from_user(&dflow, argp, sizeof(dflow))) 2323 if (copy_from_user(&dflow, argp, sizeof(dflow)))
2301 return -EFAULT; 2324 return -EFAULT;
2302 2325
2303 if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ 2326 if (dflow.startc != startc || dflow.stopc != stopc) {
2327 /* Begin if setflow toggled */
2304 spin_lock_irqsave(&epca_lock, flags); 2328 spin_lock_irqsave(&epca_lock, flags);
2305 globalwinon(ch); 2329 globalwinon(ch);
2306 2330
2307 if (cmd == DIGI_SETFLOW) { 2331 if (cmd == DIGI_SETFLOW) {
2308 ch->fepstartc = ch->startc = dflow.startc; 2332 ch->fepstartc = ch->startc = dflow.startc;
2309 ch->fepstopc = ch->stopc = dflow.stopc; 2333 ch->fepstopc = ch->stopc = dflow.stopc;
2310 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); 2334 fepcmd(ch, SONOFFC, ch->fepstartc,
2335 ch->fepstopc, 0, 1);
2311 } else { 2336 } else {
2312 ch->fepstartca = ch->startca = dflow.startc; 2337 ch->fepstartca = ch->startca = dflow.startc;
2313 ch->fepstopca = ch->stopca = dflow.stopc; 2338 ch->fepstopca = ch->stopca = dflow.stopc;
2314 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); 2339 fepcmd(ch, SAUXONOFFC, ch->fepstartca,
2340 ch->fepstopca, 0, 1);
2315 } 2341 }
2316 2342
2317 if (ch->statusflags & TXSTOPPED) 2343 if (ch->statusflags & TXSTOPPED)
@@ -2335,7 +2361,9 @@ static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
2335 * verifyChannel returns the channel from the tty struct if it is 2361 * verifyChannel returns the channel from the tty struct if it is
2336 * valid. This serves as a sanity check. 2362 * valid. This serves as a sanity check.
2337 */ 2363 */
2338 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ 2364 ch = verifyChannel(tty);
2365
2366 if (ch != NULL) { /* Begin if channel valid */
2339 spin_lock_irqsave(&epca_lock, flags); 2367 spin_lock_irqsave(&epca_lock, flags);
2340 globalwinon(ch); 2368 globalwinon(ch);
2341 epcaparam(tty, ch); 2369 epcaparam(tty, ch);
@@ -2362,7 +2390,7 @@ static void do_softint(struct work_struct *work)
2362 2390
2363 if (tty && tty->driver_data) { 2391 if (tty && tty->driver_data) {
2364 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { 2392 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
2365 tty_hangup(tty); /* FIXME: module removal race here - AKPM */ 2393 tty_hangup(tty);
2366 wake_up_interruptible(&ch->open_wait); 2394 wake_up_interruptible(&ch->open_wait);
2367 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; 2395 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
2368 } 2396 }
@@ -2382,9 +2410,11 @@ static void pc_stop(struct tty_struct *tty)
2382 * verifyChannel returns the channel from the tty struct if it is 2410 * verifyChannel returns the channel from the tty struct if it is
2383 * valid. This serves as a sanity check. 2411 * valid. This serves as a sanity check.
2384 */ 2412 */
2385 if ((ch = verifyChannel(tty)) != NULL) { 2413 ch = verifyChannel(tty);
2414 if (ch != NULL) {
2386 spin_lock_irqsave(&epca_lock, flags); 2415 spin_lock_irqsave(&epca_lock, flags);
2387 if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */ 2416 if ((ch->statusflags & TXSTOPPED) == 0) {
2417 /* Begin if transmit stop requested */
2388 globalwinon(ch); 2418 globalwinon(ch);
2389 /* STOP transmitting now !! */ 2419 /* STOP transmitting now !! */
2390 fepcmd(ch, PAUSETX, 0, 0, 0, 0); 2420 fepcmd(ch, PAUSETX, 0, 0, 0, 0);
@@ -2402,11 +2432,14 @@ static void pc_start(struct tty_struct *tty)
2402 * verifyChannel returns the channel from the tty struct if it is 2432 * verifyChannel returns the channel from the tty struct if it is
2403 * valid. This serves as a sanity check. 2433 * valid. This serves as a sanity check.
2404 */ 2434 */
2405 if ((ch = verifyChannel(tty)) != NULL) { 2435 ch = verifyChannel(tty);
2436 if (ch != NULL) {
2406 unsigned long flags; 2437 unsigned long flags;
2407 spin_lock_irqsave(&epca_lock, flags); 2438 spin_lock_irqsave(&epca_lock, flags);
2408 /* Just in case output was resumed because of a change in Digi-flow */ 2439 /* Just in case output was resumed because of a change
2409 if (ch->statusflags & TXSTOPPED) { /* Begin transmit resume requested */ 2440 in Digi-flow */
2441 if (ch->statusflags & TXSTOPPED) {
2442 /* Begin transmit resume requested */
2410 struct board_chan __iomem *bc; 2443 struct board_chan __iomem *bc;
2411 globalwinon(ch); 2444 globalwinon(ch);
2412 bc = ch->brdchan; 2445 bc = ch->brdchan;
@@ -2436,7 +2469,8 @@ static void pc_throttle(struct tty_struct *tty)
2436 * verifyChannel returns the channel from the tty struct if it is 2469 * verifyChannel returns the channel from the tty struct if it is
2437 * valid. This serves as a sanity check. 2470 * valid. This serves as a sanity check.
2438 */ 2471 */
2439 if ((ch = verifyChannel(tty)) != NULL) { 2472 ch = verifyChannel(tty);
2473 if (ch != NULL) {
2440 spin_lock_irqsave(&epca_lock, flags); 2474 spin_lock_irqsave(&epca_lock, flags);
2441 if ((ch->statusflags & RXSTOPPED) == 0) { 2475 if ((ch->statusflags & RXSTOPPED) == 0) {
2442 globalwinon(ch); 2476 globalwinon(ch);
@@ -2456,8 +2490,10 @@ static void pc_unthrottle(struct tty_struct *tty)
2456 * verifyChannel returns the channel from the tty struct if it is 2490 * verifyChannel returns the channel from the tty struct if it is
2457 * valid. This serves as a sanity check. 2491 * valid. This serves as a sanity check.
2458 */ 2492 */
2459 if ((ch = verifyChannel(tty)) != NULL) { 2493 ch = verifyChannel(tty);
2460 /* Just in case output was resumed because of a change in Digi-flow */ 2494 if (ch != NULL) {
2495 /* Just in case output was resumed because of a change
2496 in Digi-flow */
2461 spin_lock_irqsave(&epca_lock, flags); 2497 spin_lock_irqsave(&epca_lock, flags);
2462 if (ch->statusflags & RXSTOPPED) { 2498 if (ch->statusflags & RXSTOPPED) {
2463 globalwinon(ch); 2499 globalwinon(ch);
@@ -2502,7 +2538,7 @@ static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
2502 memoff(ch); 2538 memoff(ch);
2503} 2539}
2504 2540
2505void epca_setup(char *str, int *ints) 2541static void epca_setup(char *str, int *ints)
2506{ 2542{
2507 struct board_info board; 2543 struct board_info board;
2508 int index, loop, last; 2544 int index, loop, last;
@@ -2531,14 +2567,16 @@ void epca_setup(char *str, int *ints)
2531 * instructing the driver to ignore epcaconfig.) For 2567 * instructing the driver to ignore epcaconfig.) For
2532 * this reason we check for 2. 2568 * this reason we check for 2.
2533 */ 2569 */
2534 if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */ 2570 if (board.status == 2) {
2571 /* Begin ignore epcaconfig as well as lilo cmd line */
2535 nbdevs = 0; 2572 nbdevs = 0;
2536 num_cards = 0; 2573 num_cards = 0;
2537 return; 2574 return;
2538 } /* End ignore epcaconfig as well as lilo cmd line */ 2575 } /* End ignore epcaconfig as well as lilo cmd line */
2539 2576
2540 if (board.status > 2) { 2577 if (board.status > 2) {
2541 printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status); 2578 printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n",
2579 board.status);
2542 invalid_lilo_config = 1; 2580 invalid_lilo_config = 1;
2543 setup_error_code |= INVALID_BOARD_STATUS; 2581 setup_error_code |= INVALID_BOARD_STATUS;
2544 return; 2582 return;
@@ -2592,7 +2630,8 @@ void epca_setup(char *str, int *ints)
2592 case 6: 2630 case 6:
2593 board.membase = ints[index]; 2631 board.membase = ints[index];
2594 if (ints[index] <= 0) { 2632 if (ints[index] <= 0) {
2595 printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); 2633 printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",
2634 (unsigned int)board.membase);
2596 invalid_lilo_config = 1; 2635 invalid_lilo_config = 1;
2597 setup_error_code |= INVALID_MEM_BASE; 2636 setup_error_code |= INVALID_MEM_BASE;
2598 return; 2637 return;
@@ -2723,7 +2762,7 @@ void epca_setup(char *str, int *ints)
2723 t2++; 2762 t2++;
2724 2763
2725 if (*t2) { 2764 if (*t2) {
2726 printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str); 2765 printk(KERN_ERR "epca_setup: Invalid memory base %s\n", str);
2727 invalid_lilo_config = 1; 2766 invalid_lilo_config = 1;
2728 setup_error_code |= INVALID_MEM_BASE; 2767 setup_error_code |= INVALID_MEM_BASE;
2729 return; 2768 return;
@@ -2745,7 +2784,7 @@ void epca_setup(char *str, int *ints)
2745 2784
2746 /* I should REALLY validate the stuff here */ 2785 /* I should REALLY validate the stuff here */
2747 /* Copies our local copy of board into boards */ 2786 /* Copies our local copy of board into boards */
2748 memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); 2787 memcpy((void *)&boards[num_cards], (void *)&board, sizeof(board));
2749 /* Does this get called once per lilo arg are what ? */ 2788 /* Does this get called once per lilo arg are what ? */
2750 printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", 2789 printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n",
2751 num_cards, board_desc[board.type], 2790 num_cards, board_desc[board.type],
@@ -2786,9 +2825,9 @@ static int __devinit epca_init_one(struct pci_dev *pdev,
2786 if (board_idx >= MAXBOARDS) 2825 if (board_idx >= MAXBOARDS)
2787 goto err_out; 2826 goto err_out;
2788 2827
2789 addr = pci_resource_start (pdev, epca_info_tbl[info_idx].bar_idx); 2828 addr = pci_resource_start(pdev, epca_info_tbl[info_idx].bar_idx);
2790 if (!addr) { 2829 if (!addr) {
2791 printk (KERN_ERR PFX "PCI region #%d not available (size 0)\n", 2830 printk(KERN_ERR PFX "PCI region #%d not available (size 0)\n",
2792 epca_info_tbl[info_idx].bar_idx); 2831 epca_info_tbl[info_idx].bar_idx);
2793 goto err_out; 2832 goto err_out;
2794 } 2833 }
@@ -2799,28 +2838,29 @@ static int __devinit epca_init_one(struct pci_dev *pdev,
2799 boards[board_idx].port = addr + PCI_IO_OFFSET; 2838 boards[board_idx].port = addr + PCI_IO_OFFSET;
2800 boards[board_idx].membase = addr; 2839 boards[board_idx].membase = addr;
2801 2840
2802 if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { 2841 if (!request_mem_region(addr + PCI_IO_OFFSET, 0x200000, "epca")) {
2803 printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", 2842 printk(KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n",
2804 0x200000, addr + PCI_IO_OFFSET); 2843 0x200000, addr + PCI_IO_OFFSET);
2805 goto err_out; 2844 goto err_out;
2806 } 2845 }
2807 2846
2808 boards[board_idx].re_map_port = ioremap(addr + PCI_IO_OFFSET, 0x200000); 2847 boards[board_idx].re_map_port = ioremap_nocache(addr + PCI_IO_OFFSET,
2848 0x200000);
2809 if (!boards[board_idx].re_map_port) { 2849 if (!boards[board_idx].re_map_port) {
2810 printk (KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n", 2850 printk(KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n",
2811 0x200000, addr + PCI_IO_OFFSET); 2851 0x200000, addr + PCI_IO_OFFSET);
2812 goto err_out_free_pciio; 2852 goto err_out_free_pciio;
2813 } 2853 }
2814 2854
2815 if (!request_mem_region (addr, 0x200000, "epca")) { 2855 if (!request_mem_region(addr, 0x200000, "epca")) {
2816 printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", 2856 printk(KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n",
2817 0x200000, addr); 2857 0x200000, addr);
2818 goto err_out_free_iounmap; 2858 goto err_out_free_iounmap;
2819 } 2859 }
2820 2860
2821 boards[board_idx].re_map_membase = ioremap(addr, 0x200000); 2861 boards[board_idx].re_map_membase = ioremap_nocache(addr, 0x200000);
2822 if (!boards[board_idx].re_map_membase) { 2862 if (!boards[board_idx].re_map_membase) {
2823 printk (KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n", 2863 printk(KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n",
2824 0x200000, addr + PCI_IO_OFFSET); 2864 0x200000, addr + PCI_IO_OFFSET);
2825 goto err_out_free_memregion; 2865 goto err_out_free_memregion;
2826 } 2866 }
@@ -2837,11 +2877,11 @@ static int __devinit epca_init_one(struct pci_dev *pdev,
2837 return 0; 2877 return 0;
2838 2878
2839err_out_free_memregion: 2879err_out_free_memregion:
2840 release_mem_region (addr, 0x200000); 2880 release_mem_region(addr, 0x200000);
2841err_out_free_iounmap: 2881err_out_free_iounmap:
2842 iounmap (boards[board_idx].re_map_port); 2882 iounmap(boards[board_idx].re_map_port);
2843err_out_free_pciio: 2883err_out_free_pciio:
2844 release_mem_region (addr + PCI_IO_OFFSET, 0x200000); 2884 release_mem_region(addr + PCI_IO_OFFSET, 0x200000);
2845err_out: 2885err_out:
2846 return -ENODEV; 2886 return -ENODEV;
2847} 2887}
@@ -2859,7 +2899,7 @@ MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
2859 2899
2860static int __init init_PCI(void) 2900static int __init init_PCI(void)
2861{ 2901{
2862 memset (&epca_driver, 0, sizeof (epca_driver)); 2902 memset(&epca_driver, 0, sizeof(epca_driver));
2863 epca_driver.name = "epca"; 2903 epca_driver.name = "epca";
2864 epca_driver.id_table = epca_pci_tbl; 2904 epca_driver.id_table = epca_pci_tbl;
2865 epca_driver.probe = epca_init_one; 2905 epca_driver.probe = epca_init_one;