aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/cyclades.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-05-08 03:36:59 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:25 -0400
commitf742903424aae3fc7ea7079a3618d90634c0b301 (patch)
tree841906118e68f4adc7bbdb8a4a0c80c1d229d9e2 /drivers/char/cyclades.c
parent9fa1b3b185a802fa0b3f764ad468efd64e1b582e (diff)
Char: cyclades, conditions cleanup
- 0 is not NULL - use unlikely to hit the icache in isr more likely - remove or comment empty if/else paths [akpm@linux-foundation.org: build fix] Signed-off-by: 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/cyclades.c')
-rw-r--r--drivers/char/cyclades.c60
1 files changed, 21 insertions, 39 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 6e5fca9c393a..e559ce9e7147 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -1043,7 +1043,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1043 cy_writeb(base_addr + (CyCAR << index), save_xir); 1043 cy_writeb(base_addr + (CyCAR << index), save_xir);
1044 1044
1045 /* if there is nowhere to put the data, discard it */ 1045 /* if there is nowhere to put the data, discard it */
1046 if (info->tty == 0) { 1046 if (info->tty == NULL) {
1047 j = (readb(base_addr + (CyRIVR << index)) & 1047 j = (readb(base_addr + (CyRIVR << index)) &
1048 CyIVRMask); 1048 CyIVRMask);
1049 if (j == CyIVRRxEx) { /* exception */ 1049 if (j == CyIVRRxEx) { /* exception */
@@ -1214,7 +1214,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1214 goto txend; 1214 goto txend;
1215 } 1215 }
1216 info = &cy_port[i]; 1216 info = &cy_port[i];
1217 if (info->tty == 0) { 1217 if (info->tty == NULL) {
1218 cy_writeb(base_addr + (CySRER << index), 1218 cy_writeb(base_addr + (CySRER << index),
1219 readb(base_addr + (CySRER << index)) & 1219 readb(base_addr + (CySRER << index)) &
1220 ~CyTxRdy); 1220 ~CyTxRdy);
@@ -1263,7 +1263,7 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1263 } 1263 }
1264 goto txdone; 1264 goto txdone;
1265 } 1265 }
1266 if (info->xmit_buf == 0) { 1266 if (info->xmit_buf == NULL) {
1267 cy_writeb(base_addr + (CySRER << index), 1267 cy_writeb(base_addr + (CySRER << index),
1268 readb(base_addr + (CySRER << index)) & 1268 readb(base_addr + (CySRER << index)) &
1269 ~CyTxRdy); 1269 ~CyTxRdy);
@@ -1304,7 +1304,6 @@ static void cyy_intr_chip(struct cyclades_card *cinfo, int chip,
1304 0); 1304 0);
1305 info->icount.tx++; 1305 info->icount.tx++;
1306 char_count--; 1306 char_count--;
1307 } else {
1308 } 1307 }
1309 } 1308 }
1310 } 1309 }
@@ -1333,9 +1332,7 @@ txend:
1333 mdm_change = readb(base_addr + (CyMISR << index)); 1332 mdm_change = readb(base_addr + (CyMISR << index));
1334 mdm_status = readb(base_addr + (CyMSVR1 << index)); 1333 mdm_status = readb(base_addr + (CyMSVR1 << index));
1335 1334
1336 if (info->tty == 0) { /* no place for data, ignore it */ 1335 if (info->tty) {
1337 ;
1338 } else {
1339 if (mdm_change & CyANY_DELTA) { 1336 if (mdm_change & CyANY_DELTA) {
1340 /* For statistics only */ 1337 /* For statistics only */
1341 if (mdm_change & CyDCD) 1338 if (mdm_change & CyDCD)
@@ -1389,10 +1386,10 @@ txend:
1389 } 1386 }
1390 } 1387 }
1391 } 1388 }
1392 if (mdm_change & CyDSR) { 1389/* if (mdm_change & CyDSR) {
1393 } 1390 }
1394 if (mdm_change & CyRI) { 1391 if (mdm_change & CyRI) {
1395 } 1392 }*/
1396 } 1393 }
1397 /* end of service */ 1394 /* end of service */
1398 cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f)); 1395 cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f));
@@ -1408,14 +1405,14 @@ txend:
1408static irqreturn_t cyy_interrupt(int irq, void *dev_id) 1405static irqreturn_t cyy_interrupt(int irq, void *dev_id)
1409{ 1406{
1410 int status; 1407 int status;
1411 struct cyclades_card *cinfo; 1408 struct cyclades_card *cinfo = dev_id;
1412 void __iomem *base_addr, *card_base_addr; 1409 void __iomem *base_addr, *card_base_addr;
1413 int chip; 1410 int chip;
1414 int index; 1411 int index;
1415 int too_many; 1412 int too_many;
1416 int had_work; 1413 int had_work;
1417 1414
1418 if ((cinfo = (struct cyclades_card *)dev_id) == 0) { 1415 if (unlikely(cinfo == NULL)) {
1419#ifdef CY_DEBUG_INTERRUPTS 1416#ifdef CY_DEBUG_INTERRUPTS
1420 printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",irq); 1417 printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",irq);
1421#endif 1418#endif
@@ -1564,7 +1561,7 @@ cyz_handle_rx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
1564 info->mon.char_max = char_count; 1561 info->mon.char_max = char_count;
1565 info->mon.char_last = char_count; 1562 info->mon.char_last = char_count;
1566#endif 1563#endif
1567 if (tty == 0) { 1564 if (tty == NULL) {
1568 /* flush received characters */ 1565 /* flush received characters */
1569 new_rx_get = (new_rx_get + char_count) & 1566 new_rx_get = (new_rx_get + char_count) &
1570 (rx_bufsize - 1); 1567 (rx_bufsize - 1);
@@ -1650,9 +1647,8 @@ cyz_handle_tx(struct cyclades_port *info, struct CH_CTRL __iomem *ch_ctrl,
1650 1647
1651 if (char_count) { 1648 if (char_count) {
1652 1649
1653 if (tty == 0) { 1650 if (tty == NULL)
1654 goto ztxdone; 1651 goto ztxdone;
1655 }
1656 1652
1657 if (info->x_char) { /* send special char */ 1653 if (info->x_char) { /* send special char */
1658 data = info->x_char; 1654 data = info->x_char;
@@ -1731,9 +1727,9 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1731 special_count = 0; 1727 special_count = 0;
1732 delta_count = 0; 1728 delta_count = 0;
1733 info = &cy_port[channel + cinfo->first_line]; 1729 info = &cy_port[channel + cinfo->first_line];
1734 if ((tty = info->tty) == 0) { 1730 if ((tty = info->tty) == NULL)
1735 continue; 1731 continue;
1736 } 1732
1737 ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); 1733 ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
1738 buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); 1734 buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]);
1739 1735
@@ -1822,16 +1818,16 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1822#ifdef CONFIG_CYZ_INTR 1818#ifdef CONFIG_CYZ_INTR
1823static irqreturn_t cyz_interrupt(int irq, void *dev_id) 1819static irqreturn_t cyz_interrupt(int irq, void *dev_id)
1824{ 1820{
1825 struct cyclades_card *cinfo; 1821 struct cyclades_card *cinfo = dev_id;
1826 1822
1827 if ((cinfo = (struct cyclades_card *)dev_id) == 0) { 1823 if (unlikely(cinfo == NULL)) {
1828#ifdef CY_DEBUG_INTERRUPTS 1824#ifdef CY_DEBUG_INTERRUPTS
1829 printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",irq); 1825 printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",irq);
1830#endif 1826#endif
1831 return IRQ_NONE; /* spurious interrupt */ 1827 return IRQ_NONE; /* spurious interrupt */
1832 } 1828 }
1833 1829
1834 if (!ISZLOADED(*cinfo)) { 1830 if (unlikely(!ISZLOADED(*cinfo))) {
1835#ifdef CY_DEBUG_INTERRUPTS 1831#ifdef CY_DEBUG_INTERRUPTS
1836 printk(KERN_DEBUG "cyz_interrupt: board not yet loaded " 1832 printk(KERN_DEBUG "cyz_interrupt: board not yet loaded "
1837 "(IRQ%d).\n", irq); 1833 "(IRQ%d).\n", irq);
@@ -2661,8 +2657,6 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
2661 timeout)) 2657 timeout))
2662 break; 2658 break;
2663 } 2659 }
2664 } else {
2665 /* Nothing to do! */
2666 } 2660 }
2667 /* Run one more char cycle */ 2661 /* Run one more char cycle */
2668 msleep_interruptible(jiffies_to_msecs(char_time * 5)); 2662 msleep_interruptible(jiffies_to_msecs(char_time * 5));
@@ -3857,8 +3851,6 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
3857 cy_writeb(base_addr + (CyCOR3 << index), info->cor3); 3851 cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
3858 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index); 3852 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index);
3859 spin_unlock_irqrestore(&card->card_lock, flags); 3853 spin_unlock_irqrestore(&card->card_lock, flags);
3860 } else {
3861 /* Nothing to do! */
3862 } 3854 }
3863 return 0; 3855 return 0;
3864} /* set_threshold */ 3856} /* set_threshold */
@@ -3881,10 +3873,8 @@ get_threshold(struct cyclades_port *info, unsigned long __user * value)
3881 3873
3882 tmp = readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO; 3874 tmp = readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO;
3883 return put_user(tmp, value); 3875 return put_user(tmp, value);
3884 } else {
3885 /* Nothing to do! */
3886 return 0;
3887 } 3876 }
3877 return 0;
3888} /* get_threshold */ 3878} /* get_threshold */
3889 3879
3890static int 3880static int
@@ -3918,8 +3908,6 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
3918 spin_lock_irqsave(&card->card_lock, flags); 3908 spin_lock_irqsave(&card->card_lock, flags);
3919 cy_writeb(base_addr + (CyRTPR << index), value & 0xff); 3909 cy_writeb(base_addr + (CyRTPR << index), value & 0xff);
3920 spin_unlock_irqrestore(&card->card_lock, flags); 3910 spin_unlock_irqrestore(&card->card_lock, flags);
3921 } else {
3922 /* Nothing to do! */
3923 } 3911 }
3924 return 0; 3912 return 0;
3925} /* set_timeout */ 3913} /* set_timeout */
@@ -3941,10 +3929,8 @@ static int get_timeout(struct cyclades_port *info, unsigned long __user * value)
3941 3929
3942 tmp = readb(base_addr + (CyRTPR << index)); 3930 tmp = readb(base_addr + (CyRTPR << index));
3943 return put_user(tmp, value); 3931 return put_user(tmp, value);
3944 } else {
3945 /* Nothing to do! */
3946 return 0;
3947 } 3932 }
3933 return 0;
3948} /* get_timeout */ 3934} /* get_timeout */
3949 3935
3950static int set_default_timeout(struct cyclades_port *info, unsigned long value) 3936static int set_default_timeout(struct cyclades_port *info, unsigned long value)
@@ -4348,8 +4334,6 @@ static void cy_stop(struct tty_struct *tty)
4348 cy_writeb(base_addr + (CySRER << index), 4334 cy_writeb(base_addr + (CySRER << index),
4349 readb(base_addr + (CySRER << index)) & ~CyTxRdy); 4335 readb(base_addr + (CySRER << index)) & ~CyTxRdy);
4350 spin_unlock_irqrestore(&cinfo->card_lock, flags); 4336 spin_unlock_irqrestore(&cinfo->card_lock, flags);
4351 } else {
4352 /* Nothing to do! */
4353 } 4337 }
4354} /* cy_stop */ 4338} /* cy_stop */
4355 4339
@@ -4381,8 +4365,6 @@ static void cy_start(struct tty_struct *tty)
4381 cy_writeb(base_addr + (CySRER << index), 4365 cy_writeb(base_addr + (CySRER << index),
4382 readb(base_addr + (CySRER << index)) | CyTxRdy); 4366 readb(base_addr + (CySRER << index)) | CyTxRdy);
4383 spin_unlock_irqrestore(&cinfo->card_lock, flags); 4367 spin_unlock_irqrestore(&cinfo->card_lock, flags);
4384 } else {
4385 /* Nothing to do! */
4386 } 4368 }
4387} /* cy_start */ 4369} /* cy_start */
4388 4370
@@ -4694,7 +4676,7 @@ static int __init cy_detect_isa(void)
4694 } 4676 }
4695 /* fill the next cy_card structure available */ 4677 /* fill the next cy_card structure available */
4696 for (j = 0; j < NR_CARDS; j++) { 4678 for (j = 0; j < NR_CARDS; j++) {
4697 if (cy_card[j].base_addr == 0) 4679 if (cy_card[j].base_addr == NULL)
4698 break; 4680 break;
4699 } 4681 }
4700 if (j == NR_CARDS) { /* no more cy_cards available */ 4682 if (j == NR_CARDS) { /* no more cy_cards available */
@@ -4779,7 +4761,7 @@ static int __devinit cy_init_Ze(struct RUNTIME_9060 __iomem *cy_pci_addr0,
4779 4761
4780 /* fill the next cy_card structure available */ 4762 /* fill the next cy_card structure available */
4781 for (j = 0; j < NR_CARDS; j++) { 4763 for (j = 0; j < NR_CARDS; j++) {
4782 if (cy_card[j].base_addr == 0) 4764 if (cy_card[j].base_addr == NULL)
4783 break; 4765 break;
4784 } 4766 }
4785 if (j == NR_CARDS) { /* no more cy_cards available */ 4767 if (j == NR_CARDS) { /* no more cy_cards available */
@@ -4889,7 +4871,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
4889 } 4871 }
4890 /* fill the next cy_card structure available */ 4872 /* fill the next cy_card structure available */
4891 for (j = 0; j < NR_CARDS; j++) { 4873 for (j = 0; j < NR_CARDS; j++) {
4892 if (cy_card[j].base_addr == 0) 4874 if (cy_card[j].base_addr == NULL)
4893 break; 4875 break;
4894 } 4876 }
4895 if (j == NR_CARDS) { /* no more cy_cards available */ 4877 if (j == NR_CARDS) { /* no more cy_cards available */
@@ -5039,7 +5021,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
5039 5021
5040 /* fill the next cy_card structure available */ 5022 /* fill the next cy_card structure available */
5041 for (j = 0; j < NR_CARDS; j++) { 5023 for (j = 0; j < NR_CARDS; j++) {
5042 if (cy_card[j].base_addr == 0) 5024 if (cy_card[j].base_addr == NULL)
5043 break; 5025 break;
5044 } 5026 }
5045 if (j == NR_CARDS) { /* no more cy_cards available */ 5027 if (j == NR_CARDS) { /* no more cy_cards available */