aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tokenring
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-04 05:52:56 -0500
committerDavid S. Miller <davem@davemloft.net>2012-02-04 16:26:59 -0500
commit76a82abc0598f9cd881154369c3afdff9c28568b (patch)
tree3192aba2a0f43ea34ef85387eb53b72454bd591a /drivers/net/tokenring
parente5e1ee89461543043a0144e6dac90547fefe2f89 (diff)
tms380tr: Fix cascading if/else tab abuse
Cascading "if/else if"'s are ugly. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tokenring')
-rw-r--r--drivers/net/tokenring/tms380tr.c179
1 files changed, 67 insertions, 112 deletions
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c
index 65e9cf3a71fe..102f896bbc58 100644
--- a/drivers/net/tokenring/tms380tr.c
+++ b/drivers/net/tokenring/tms380tr.c
@@ -1525,10 +1525,8 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev)
1525 /* Check if adapter is opened, avoiding COMMAND_REJECT 1525 /* Check if adapter is opened, avoiding COMMAND_REJECT
1526 * interrupt by the adapter! 1526 * interrupt by the adapter!
1527 */ 1527 */
1528 if(tp->AdapterOpenFlag == 0) 1528 if (tp->AdapterOpenFlag == 0) {
1529 { 1529 if (tp->CMDqueue & OC_OPEN) {
1530 if(tp->CMDqueue & OC_OPEN)
1531 {
1532 /* Execute OPEN command */ 1530 /* Execute OPEN command */
1533 tp->CMDqueue ^= OC_OPEN; 1531 tp->CMDqueue ^= OC_OPEN;
1534 1532
@@ -1536,21 +1534,17 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev)
1536 tp->scb.Parm[0] = LOWORD(Addr); 1534 tp->scb.Parm[0] = LOWORD(Addr);
1537 tp->scb.Parm[1] = HIWORD(Addr); 1535 tp->scb.Parm[1] = HIWORD(Addr);
1538 tp->scb.CMD = OPEN; 1536 tp->scb.CMD = OPEN;
1539 } 1537 } else
1540 else
1541 /* No OPEN command queued, but adapter closed. Note: 1538 /* No OPEN command queued, but adapter closed. Note:
1542 * We'll try to re-open the adapter in DriverPoll() 1539 * We'll try to re-open the adapter in DriverPoll()
1543 */ 1540 */
1544 return; /* No adapter command issued */ 1541 return; /* No adapter command issued */
1545 } 1542 } else {
1546 else
1547 {
1548 /* Adapter is open; evaluate command queue: try to execute 1543 /* Adapter is open; evaluate command queue: try to execute
1549 * outstanding commands (depending on priority!) CLOSE 1544 * outstanding commands (depending on priority!) CLOSE
1550 * command queued 1545 * command queued
1551 */ 1546 */
1552 if(tp->CMDqueue & OC_CLOSE) 1547 if (tp->CMDqueue & OC_CLOSE) {
1553 {
1554 tp->CMDqueue ^= OC_CLOSE; 1548 tp->CMDqueue ^= OC_CLOSE;
1555 tp->AdapterOpenFlag = 0; 1549 tp->AdapterOpenFlag = 0;
1556 tp->scb.Parm[0] = 0; /* Parm[0], Parm[1] are ignored */ 1550 tp->scb.Parm[0] = 0; /* Parm[0], Parm[1] are ignored */
@@ -1560,109 +1554,70 @@ static void tms380tr_chk_outstanding_cmds(struct net_device *dev)
1560 tp->CMDqueue |= OC_OPEN; /* re-open adapter */ 1554 tp->CMDqueue |= OC_OPEN; /* re-open adapter */
1561 else 1555 else
1562 tp->CMDqueue = 0; /* no more commands */ 1556 tp->CMDqueue = 0; /* no more commands */
1563 } 1557 } else if (tp->CMDqueue & OC_RECEIVE) {
1564 else 1558 tp->CMDqueue ^= OC_RECEIVE;
1565 { 1559 Addr = htonl(((char *)tp->RplHead - (char *)tp) + tp->dmabuffer);
1566 if(tp->CMDqueue & OC_RECEIVE) 1560 tp->scb.Parm[0] = LOWORD(Addr);
1567 { 1561 tp->scb.Parm[1] = HIWORD(Addr);
1568 tp->CMDqueue ^= OC_RECEIVE; 1562 tp->scb.CMD = RECEIVE;
1569 Addr = htonl(((char *)tp->RplHead - (char *)tp) + tp->dmabuffer); 1563 } else if (tp->CMDqueue & OC_TRANSMIT_HALT) {
1570 tp->scb.Parm[0] = LOWORD(Addr); 1564 /* NOTE: TRANSMIT.HALT must be checked
1571 tp->scb.Parm[1] = HIWORD(Addr); 1565 * before TRANSMIT.
1572 tp->scb.CMD = RECEIVE; 1566 */
1573 } 1567 tp->CMDqueue ^= OC_TRANSMIT_HALT;
1574 else 1568 tp->scb.CMD = TRANSMIT_HALT;
1575 { 1569
1576 if(tp->CMDqueue & OC_TRANSMIT_HALT) 1570 /* Parm[0] and Parm[1] are ignored
1577 { 1571 * but should be set to zero!
1578 /* NOTE: TRANSMIT.HALT must be checked 1572 */
1579 * before TRANSMIT. 1573 tp->scb.Parm[0] = 0;
1580 */ 1574 tp->scb.Parm[1] = 0;
1581 tp->CMDqueue ^= OC_TRANSMIT_HALT; 1575 } else if (tp->CMDqueue & OC_TRANSMIT) {
1582 tp->scb.CMD = TRANSMIT_HALT; 1576 /* NOTE: TRANSMIT must be
1583 1577 * checked after TRANSMIT.HALT
1584 /* Parm[0] and Parm[1] are ignored 1578 */
1585 * but should be set to zero! 1579 if (tp->TransmitCommandActive) {
1586 */ 1580 if (!tp->TransmitHaltScheduled) {
1587 tp->scb.Parm[0] = 0; 1581 tp->TransmitHaltScheduled = 1;
1588 tp->scb.Parm[1] = 0; 1582 tms380tr_exec_cmd(dev, OC_TRANSMIT_HALT);
1589 }
1590 else
1591 {
1592 if(tp->CMDqueue & OC_TRANSMIT)
1593 {
1594 /* NOTE: TRANSMIT must be
1595 * checked after TRANSMIT.HALT
1596 */
1597 if(tp->TransmitCommandActive)
1598 {
1599 if(!tp->TransmitHaltScheduled)
1600 {
1601 tp->TransmitHaltScheduled = 1;
1602 tms380tr_exec_cmd(dev, OC_TRANSMIT_HALT) ;
1603 }
1604 tp->TransmitCommandActive = 0;
1605 return;
1606 }
1607
1608 tp->CMDqueue ^= OC_TRANSMIT;
1609 tms380tr_cancel_tx_queue(tp);
1610 Addr = htonl(((char *)tp->TplBusy - (char *)tp) + tp->dmabuffer);
1611 tp->scb.Parm[0] = LOWORD(Addr);
1612 tp->scb.Parm[1] = HIWORD(Addr);
1613 tp->scb.CMD = TRANSMIT;
1614 tp->TransmitCommandActive = 1;
1615 }
1616 else
1617 {
1618 if(tp->CMDqueue & OC_MODIFY_OPEN_PARMS)
1619 {
1620 tp->CMDqueue ^= OC_MODIFY_OPEN_PARMS;
1621 tp->scb.Parm[0] = tp->ocpl.OPENOptions; /* new OPEN options*/
1622 tp->scb.Parm[0] |= ENABLE_FULL_DUPLEX_SELECTION;
1623 tp->scb.Parm[1] = 0; /* is ignored but should be zero */
1624 tp->scb.CMD = MODIFY_OPEN_PARMS;
1625 }
1626 else
1627 {
1628 if(tp->CMDqueue & OC_SET_FUNCT_ADDR)
1629 {
1630 tp->CMDqueue ^= OC_SET_FUNCT_ADDR;
1631 tp->scb.Parm[0] = LOWORD(tp->ocpl.FunctAddr);
1632 tp->scb.Parm[1] = HIWORD(tp->ocpl.FunctAddr);
1633 tp->scb.CMD = SET_FUNCT_ADDR;
1634 }
1635 else
1636 {
1637 if(tp->CMDqueue & OC_SET_GROUP_ADDR)
1638 {
1639 tp->CMDqueue ^= OC_SET_GROUP_ADDR;
1640 tp->scb.Parm[0] = LOWORD(tp->ocpl.GroupAddr);
1641 tp->scb.Parm[1] = HIWORD(tp->ocpl.GroupAddr);
1642 tp->scb.CMD = SET_GROUP_ADDR;
1643 }
1644 else
1645 {
1646 if(tp->CMDqueue & OC_READ_ERROR_LOG)
1647 {
1648 tp->CMDqueue ^= OC_READ_ERROR_LOG;
1649 Addr = htonl(((char *)&tp->errorlogtable - (char *)tp) + tp->dmabuffer);
1650 tp->scb.Parm[0] = LOWORD(Addr);
1651 tp->scb.Parm[1] = HIWORD(Addr);
1652 tp->scb.CMD = READ_ERROR_LOG;
1653 }
1654 else
1655 {
1656 printk(KERN_WARNING "CheckForOutstandingCommand: unknown Command\n");
1657 tp->CMDqueue = 0;
1658 return;
1659 }
1660 }
1661 }
1662 }
1663 }
1664 } 1583 }
1584 tp->TransmitCommandActive = 0;
1585 return;
1665 } 1586 }
1587
1588 tp->CMDqueue ^= OC_TRANSMIT;
1589 tms380tr_cancel_tx_queue(tp);
1590 Addr = htonl(((char *)tp->TplBusy - (char *)tp) + tp->dmabuffer);
1591 tp->scb.Parm[0] = LOWORD(Addr);
1592 tp->scb.Parm[1] = HIWORD(Addr);
1593 tp->scb.CMD = TRANSMIT;
1594 tp->TransmitCommandActive = 1;
1595 } else if (tp->CMDqueue & OC_MODIFY_OPEN_PARMS) {
1596 tp->CMDqueue ^= OC_MODIFY_OPEN_PARMS;
1597 tp->scb.Parm[0] = tp->ocpl.OPENOptions; /* new OPEN options*/
1598 tp->scb.Parm[0] |= ENABLE_FULL_DUPLEX_SELECTION;
1599 tp->scb.Parm[1] = 0; /* is ignored but should be zero */
1600 tp->scb.CMD = MODIFY_OPEN_PARMS;
1601 } else if (tp->CMDqueue & OC_SET_FUNCT_ADDR) {
1602 tp->CMDqueue ^= OC_SET_FUNCT_ADDR;
1603 tp->scb.Parm[0] = LOWORD(tp->ocpl.FunctAddr);
1604 tp->scb.Parm[1] = HIWORD(tp->ocpl.FunctAddr);
1605 tp->scb.CMD = SET_FUNCT_ADDR;
1606 } else if (tp->CMDqueue & OC_SET_GROUP_ADDR) {
1607 tp->CMDqueue ^= OC_SET_GROUP_ADDR;
1608 tp->scb.Parm[0] = LOWORD(tp->ocpl.GroupAddr);
1609 tp->scb.Parm[1] = HIWORD(tp->ocpl.GroupAddr);
1610 tp->scb.CMD = SET_GROUP_ADDR;
1611 } else if (tp->CMDqueue & OC_READ_ERROR_LOG) {
1612 tp->CMDqueue ^= OC_READ_ERROR_LOG;
1613 Addr = htonl(((char *)&tp->errorlogtable - (char *)tp) + tp->dmabuffer);
1614 tp->scb.Parm[0] = LOWORD(Addr);
1615 tp->scb.Parm[1] = HIWORD(Addr);
1616 tp->scb.CMD = READ_ERROR_LOG;
1617 } else {
1618 printk(KERN_WARNING "CheckForOutstandingCommand: unknown Command\n");
1619 tp->CMDqueue = 0;
1620 return;
1666 } 1621 }
1667 } 1622 }
1668 1623