aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/cyclades.c88
-rw-r--r--include/linux/cyclades.h12
2 files changed, 45 insertions, 55 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 46a15d24ce7d..0634dd1c773a 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -662,7 +662,7 @@
662static void cy_throttle(struct tty_struct *tty); 662static void cy_throttle(struct tty_struct *tty);
663static void cy_send_xchar(struct tty_struct *tty, char ch); 663static void cy_send_xchar(struct tty_struct *tty, char ch);
664 664
665#define IS_CYC_Z(card) ((card).num_chips == -1) 665#define IS_CYC_Z(card) ((card).num_chips == (unsigned int)-1)
666 666
667#define Z_FPGA_CHECK(card) \ 667#define Z_FPGA_CHECK(card) \
668 ((readl(&((struct RUNTIME_9060 __iomem *) \ 668 ((readl(&((struct RUNTIME_9060 __iomem *) \
@@ -985,25 +985,23 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
985{ 985{
986 struct cyclades_port *info; 986 struct cyclades_port *info;
987 struct tty_struct *tty; 987 struct tty_struct *tty;
988 int char_count; 988 int len, index = cinfo->bus_index;
989 int j, len, index = cinfo->bus_index; 989 u8 save_xir, channel, save_car, data, char_count;
990 int save_xir, channel, save_car;
991 char data;
992 990
993#ifdef CY_DEBUG_INTERRUPTS 991#ifdef CY_DEBUG_INTERRUPTS
994 printk(KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n", chip); 992 printk(KERN_DEBUG "cyy_interrupt: rcvd intr, chip %d\n", chip);
995#endif 993#endif
996 /* determine the channel & change to that context */ 994 /* determine the channel & change to that context */
997 save_xir = (u_char) readb(base_addr + (CyRIR << index)); 995 save_xir = readb(base_addr + (CyRIR << index));
998 channel = (u_short) (save_xir & CyIRChannel); 996 channel = save_xir & CyIRChannel;
999 info = &cinfo->ports[channel + chip * 4]; 997 info = &cinfo->ports[channel + chip * 4];
1000 save_car = readb(base_addr + (CyCAR << index)); 998 save_car = readb(base_addr + (CyCAR << index));
1001 cy_writeb(base_addr + (CyCAR << index), save_xir); 999 cy_writeb(base_addr + (CyCAR << index), save_xir);
1002 1000
1003 /* if there is nowhere to put the data, discard it */ 1001 /* if there is nowhere to put the data, discard it */
1004 if (info->tty == NULL) { 1002 if (info->tty == NULL) {
1005 j = (readb(base_addr + (CyRIVR << index)) & CyIVRMask); 1003 if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
1006 if (j == CyIVRRxEx) { /* exception */ 1004 CyIVRRxEx) { /* exception */
1007 data = readb(base_addr + (CyRDSR << index)); 1005 data = readb(base_addr + (CyRDSR << index));
1008 } else { /* normal character reception */ 1006 } else { /* normal character reception */
1009 char_count = readb(base_addr + (CyRDCR << index)); 1007 char_count = readb(base_addr + (CyRDCR << index));
@@ -1014,8 +1012,8 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
1014 } 1012 }
1015 /* there is an open port for this data */ 1013 /* there is an open port for this data */
1016 tty = info->tty; 1014 tty = info->tty;
1017 j = readb(base_addr + (CyRIVR << index)) & CyIVRMask; 1015 if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
1018 if (j == CyIVRRxEx) { /* exception */ 1016 CyIVRRxEx) { /* exception */
1019 data = readb(base_addr + (CyRDSR << index)); 1017 data = readb(base_addr + (CyRDSR << index));
1020 1018
1021 /* For statistics only */ 1019 /* For statistics only */
@@ -1116,13 +1114,12 @@ end:
1116 cy_writeb(base_addr + (CyCAR << index), save_car); 1114 cy_writeb(base_addr + (CyCAR << index), save_car);
1117} 1115}
1118 1116
1119static void cyy_chip_tx(struct cyclades_card *cinfo, int chip, 1117static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
1120 void __iomem *base_addr) 1118 void __iomem *base_addr)
1121{ 1119{
1122 struct cyclades_port *info; 1120 struct cyclades_port *info;
1123 int char_count; 1121 int char_count, index = cinfo->bus_index;
1124 int outch; 1122 u8 save_xir, channel, save_car, outch;
1125 int save_xir, channel, save_car, index = cinfo->bus_index;
1126 1123
1127 /* Since we only get here when the transmit buffer 1124 /* Since we only get here when the transmit buffer
1128 is empty, we know we can always stuff a dozen 1125 is empty, we know we can always stuff a dozen
@@ -1132,8 +1129,8 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, int chip,
1132#endif 1129#endif
1133 1130
1134 /* determine the channel & change to that context */ 1131 /* determine the channel & change to that context */
1135 save_xir = (u_char) readb(base_addr + (CyTIR << index)); 1132 save_xir = readb(base_addr + (CyTIR << index));
1136 channel = (u_short) (save_xir & CyIRChannel); 1133 channel = save_xir & CyIRChannel;
1137 save_car = readb(base_addr + (CyCAR << index)); 1134 save_car = readb(base_addr + (CyCAR << index));
1138 cy_writeb(base_addr + (CyCAR << index), save_xir); 1135 cy_writeb(base_addr + (CyCAR << index), save_xir);
1139 1136
@@ -1242,12 +1239,12 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
1242 void __iomem *base_addr) 1239 void __iomem *base_addr)
1243{ 1240{
1244 struct cyclades_port *info; 1241 struct cyclades_port *info;
1245 int mdm_change, mdm_status; 1242 int index = cinfo->bus_index;
1246 int save_xir, channel, save_car, index = cinfo->bus_index; 1243 u8 save_xir, channel, save_car, mdm_change, mdm_status;
1247 1244
1248 /* determine the channel & change to that context */ 1245 /* determine the channel & change to that context */
1249 save_xir = (u_char) readb(base_addr + (CyMIR << index)); 1246 save_xir = readb(base_addr + (CyMIR << index));
1250 channel = (u_short) (save_xir & CyIRChannel); 1247 channel = save_xir & CyIRChannel;
1251 info = &cinfo->ports[channel + chip * 4]; 1248 info = &cinfo->ports[channel + chip * 4];
1252 save_car = readb(base_addr + (CyCAR << index)); 1249 save_car = readb(base_addr + (CyCAR << index));
1253 cy_writeb(base_addr + (CyCAR << index), save_xir); 1250 cy_writeb(base_addr + (CyCAR << index), save_xir);
@@ -1320,10 +1317,8 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
1320 int status; 1317 int status;
1321 struct cyclades_card *cinfo = dev_id; 1318 struct cyclades_card *cinfo = dev_id;
1322 void __iomem *base_addr, *card_base_addr; 1319 void __iomem *base_addr, *card_base_addr;
1323 int chip; 1320 unsigned int chip, too_many, had_work;
1324 int index; 1321 int index;
1325 int too_many;
1326 int had_work;
1327 1322
1328 if (unlikely(cinfo == NULL)) { 1323 if (unlikely(cinfo == NULL)) {
1329#ifdef CY_DEBUG_INTERRUPTS 1324#ifdef CY_DEBUG_INTERRUPTS
@@ -1422,7 +1417,7 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1422 struct ZFW_CTRL __iomem *zfw_ctrl; 1417 struct ZFW_CTRL __iomem *zfw_ctrl;
1423 struct BOARD_CTRL __iomem *board_ctrl; 1418 struct BOARD_CTRL __iomem *board_ctrl;
1424 __u32 __iomem *pci_doorbell; 1419 __u32 __iomem *pci_doorbell;
1425 int index; 1420 unsigned int index;
1426 1421
1427 firm_id = cinfo->base_addr + ID_ADDRESS; 1422 firm_id = cinfo->base_addr + ID_ADDRESS;
1428 if (!ISZLOADED(*cinfo)) { 1423 if (!ISZLOADED(*cinfo)) {
@@ -1447,13 +1442,12 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1447 return 0; 1442 return 0;
1448} /* cyz_issue_cmd */ 1443} /* cyz_issue_cmd */
1449 1444
1450static void 1445static void cyz_handle_rx(struct cyclades_port *info,
1451cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
1452 struct BUF_CTRL __iomem *buf_ctrl) 1446 struct BUF_CTRL __iomem *buf_ctrl)
1453{ 1447{
1454 struct cyclades_card *cinfo = info->card; 1448 struct cyclades_card *cinfo = info->card;
1455 struct tty_struct *tty = info->tty; 1449 struct tty_struct *tty = info->tty;
1456 int char_count; 1450 unsigned int char_count;
1457 int len; 1451 int len;
1458#ifdef BLOCKMOVE 1452#ifdef BLOCKMOVE
1459 unsigned char *buf; 1453 unsigned char *buf;
@@ -1526,7 +1520,7 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
1526 char_count = rx_put - rx_get; 1520 char_count = rx_put - rx_get;
1527 else 1521 else
1528 char_count = rx_put - rx_get + rx_bufsize; 1522 char_count = rx_put - rx_get + rx_bufsize;
1529 if (char_count >= (int)readl(&buf_ctrl->rx_threshold) && 1523 if (char_count >= readl(&buf_ctrl->rx_threshold) &&
1530 !timer_pending(&cyz_rx_full_timer[ 1524 !timer_pending(&cyz_rx_full_timer[
1531 info->line])) 1525 info->line]))
1532 mod_timer(&cyz_rx_full_timer[info->line], 1526 mod_timer(&cyz_rx_full_timer[info->line],
@@ -1540,14 +1534,13 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
1540 } 1534 }
1541} 1535}
1542 1536
1543static void 1537static void cyz_handle_tx(struct cyclades_port *info,
1544cyz_handle_tx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
1545 struct BUF_CTRL __iomem *buf_ctrl) 1538 struct BUF_CTRL __iomem *buf_ctrl)
1546{ 1539{
1547 struct cyclades_card *cinfo = info->card; 1540 struct cyclades_card *cinfo = info->card;
1548 struct tty_struct *tty = info->tty; 1541 struct tty_struct *tty = info->tty;
1549 char data; 1542 u8 data;
1550 int char_count; 1543 unsigned int char_count;
1551#ifdef BLOCKMOVE 1544#ifdef BLOCKMOVE
1552 int small_count; 1545 int small_count;
1553#endif 1546#endif
@@ -1708,7 +1701,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1708 printk(KERN_DEBUG "cyz_interrupt: rcvd intr, card %d, " 1701 printk(KERN_DEBUG "cyz_interrupt: rcvd intr, card %d, "
1709 "port %ld\n", info->card, channel); 1702 "port %ld\n", info->card, channel);
1710#endif 1703#endif
1711 cyz_handle_rx(info, ch_ctrl, buf_ctrl); 1704 cyz_handle_rx(info, buf_ctrl);
1712 break; 1705 break;
1713 case C_CM_TXBEMPTY: 1706 case C_CM_TXBEMPTY:
1714 case C_CM_TXLOWWM: 1707 case C_CM_TXLOWWM:
@@ -1718,7 +1711,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1718 printk(KERN_DEBUG "cyz_interrupt: xmit intr, card %d, " 1711 printk(KERN_DEBUG "cyz_interrupt: xmit intr, card %d, "
1719 "port %ld\n", info->card, channel); 1712 "port %ld\n", info->card, channel);
1720#endif 1713#endif
1721 cyz_handle_tx(info, ch_ctrl, buf_ctrl); 1714 cyz_handle_tx(info, buf_ctrl);
1722 break; 1715 break;
1723#endif /* CONFIG_CYZ_INTR */ 1716#endif /* CONFIG_CYZ_INTR */
1724 case C_CM_FATAL: 1717 case C_CM_FATAL:
@@ -1787,10 +1780,9 @@ static void cyz_poll(unsigned long arg)
1787 struct FIRM_ID __iomem *firm_id; 1780 struct FIRM_ID __iomem *firm_id;
1788 struct ZFW_CTRL __iomem *zfw_ctrl; 1781 struct ZFW_CTRL __iomem *zfw_ctrl;
1789 struct BOARD_CTRL __iomem *board_ctrl; 1782 struct BOARD_CTRL __iomem *board_ctrl;
1790 struct CH_CTRL __iomem *ch_ctrl;
1791 struct BUF_CTRL __iomem *buf_ctrl; 1783 struct BUF_CTRL __iomem *buf_ctrl;
1792 unsigned long expires = jiffies + HZ; 1784 unsigned long expires = jiffies + HZ;
1793 int card, port; 1785 unsigned int port, card;
1794 1786
1795 for (card = 0; card < NR_CARDS; card++) { 1787 for (card = 0; card < NR_CARDS; card++) {
1796 cinfo = &cy_card[card]; 1788 cinfo = &cy_card[card];
@@ -1817,12 +1809,11 @@ static void cyz_poll(unsigned long arg)
1817 for (port = 0; port < cinfo->nports; port++) { 1809 for (port = 0; port < cinfo->nports; port++) {
1818 info = &cinfo->ports[port]; 1810 info = &cinfo->ports[port];
1819 tty = info->tty; 1811 tty = info->tty;
1820 ch_ctrl = &(zfw_ctrl->ch_ctrl[port]);
1821 buf_ctrl = &(zfw_ctrl->buf_ctrl[port]); 1812 buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);
1822 1813
1823 if (!info->throttle) 1814 if (!info->throttle)
1824 cyz_handle_rx(info, ch_ctrl, buf_ctrl); 1815 cyz_handle_rx(info, buf_ctrl);
1825 cyz_handle_tx(info, ch_ctrl, buf_ctrl); 1816 cyz_handle_tx(info, buf_ctrl);
1826 } 1817 }
1827 /* poll every 'cyz_polling_cycle' period */ 1818 /* poll every 'cyz_polling_cycle' period */
1828 expires = jiffies + cyz_polling_cycle; 1819 expires = jiffies + cyz_polling_cycle;
@@ -2385,11 +2376,11 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2385static int cy_open(struct tty_struct *tty, struct file *filp) 2376static int cy_open(struct tty_struct *tty, struct file *filp)
2386{ 2377{
2387 struct cyclades_port *info; 2378 struct cyclades_port *info;
2388 unsigned int i; 2379 unsigned int i, line;
2389 int retval, line; 2380 int retval;
2390 2381
2391 line = tty->index; 2382 line = tty->index;
2392 if ((line < 0) || (NR_PORTS <= line)) { 2383 if ((tty->index < 0) || (NR_PORTS <= line)) {
2393 return -ENODEV; 2384 return -ENODEV;
2394 } 2385 }
2395 for (i = 0; i < NR_CARDS; i++) 2386 for (i = 0; i < NR_CARDS; i++)
@@ -4359,9 +4350,9 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
4359{ 4350{
4360 struct cyclades_port *info; 4351 struct cyclades_port *info;
4361 u32 uninitialized_var(mailbox); 4352 u32 uninitialized_var(mailbox);
4362 unsigned int nports; 4353 unsigned int nports, port;
4363 unsigned short chip_number; 4354 unsigned short chip_number;
4364 int uninitialized_var(index), port; 4355 int uninitialized_var(index);
4365 4356
4366 spin_lock_init(&cinfo->card_lock); 4357 spin_lock_init(&cinfo->card_lock);
4367 4358
@@ -5127,7 +5118,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
5127 } 5118 }
5128 } 5119 }
5129#endif /* CONFIG_CYZ_INTR */ 5120#endif /* CONFIG_CYZ_INTR */
5130 cy_card[card_no].num_chips = -1; 5121 cy_card[card_no].num_chips = (unsigned int)-1;
5131 } 5122 }
5132 5123
5133 /* set cy_card */ 5124 /* set cy_card */
@@ -5387,7 +5378,7 @@ err:
5387static void __exit cy_cleanup_module(void) 5378static void __exit cy_cleanup_module(void)
5388{ 5379{
5389 struct cyclades_card *card; 5380 struct cyclades_card *card;
5390 int i, e1; 5381 unsigned int i, e1;
5391 5382
5392#ifndef CONFIG_CYZ_INTR 5383#ifndef CONFIG_CYZ_INTR
5393 del_timer_sync(&cyz_timerlist); 5384 del_timer_sync(&cyz_timerlist);
@@ -5415,8 +5406,7 @@ static void __exit cy_cleanup_module(void)
5415#endif /* CONFIG_CYZ_INTR */ 5406#endif /* CONFIG_CYZ_INTR */
5416 ) 5407 )
5417 free_irq(card->irq, card); 5408 free_irq(card->irq, card);
5418 for (e1 = card->first_line; 5409 for (e1 = card->first_line; e1 < card->first_line +
5419 e1 < card->first_line +
5420 card->nports; e1++) 5410 card->nports; e1++)
5421 tty_unregister_device(cy_serial_driver, e1); 5411 tty_unregister_device(cy_serial_driver, e1);
5422 kfree(card->ports); 5412 kfree(card->ports);
diff --git a/include/linux/cyclades.h b/include/linux/cyclades.h
index 06b272590776..8f3dcd30828f 100644
--- a/include/linux/cyclades.h
+++ b/include/linux/cyclades.h
@@ -512,11 +512,11 @@ struct cyclades_card {
512 void __iomem *base_addr; 512 void __iomem *base_addr;
513 void __iomem *ctl_addr; 513 void __iomem *ctl_addr;
514 int irq; 514 int irq;
515 int num_chips; /* 0 if card absent, -1 if Z/PCI, else Y */ 515 unsigned int num_chips; /* 0 if card absent, -1 if Z/PCI, else Y */
516 int first_line; /* minor number of first channel on card */ 516 unsigned int first_line; /* minor number of first channel on card */
517 int nports; /* Number of ports in the card */ 517 unsigned int nports; /* Number of ports in the card */
518 int bus_index; /* address shift - 0 for ISA, 1 for PCI */ 518 int bus_index; /* address shift - 0 for ISA, 1 for PCI */
519 int intr_enabled; /* FW Interrupt flag - 0 disabled, 1 enabled */ 519 int intr_enabled; /* FW Interrupt flag - 0 disabled, 1 enabled */
520 spinlock_t card_lock; 520 spinlock_t card_lock;
521 struct cyclades_port *ports; 521 struct cyclades_port *ports;
522}; 522};
@@ -566,7 +566,7 @@ struct cyclades_port {
566 int rtsdtr_inv; 566 int rtsdtr_inv;
567 int chip_rev; 567 int chip_rev;
568 int custom_divisor; 568 int custom_divisor;
569 int x_char; /* to be pushed out ASAP */ 569 u8 x_char; /* to be pushed out ASAP */
570 int close_delay; 570 int close_delay;
571 unsigned short closing_wait; 571 unsigned short closing_wait;
572 int count; /* # of fd on device */ 572 int count; /* # of fd on device */