aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorTomoya <tomoya-linux@dsn.okisemi.com>2010-12-12 15:24:24 -0500
committerDavid S. Miller <davem@davemloft.net>2010-12-13 15:24:27 -0500
commitfea9294c5f2902c45613681ad995ca27899d2016 (patch)
tree65ebb001d62c964b704365c9efc6a0659b619215 /drivers/net/can
parent3332bc5446e034566e8a56bf7a7cd479ca35bd6d (diff)
pch_can: Optimize "if" condition in rx/tx processing
For reduce "if" condition, easy to read/understand the code, optimize "if" condition in rx/tx processing. Signed-off-by: Tomoya MORINAGA <tomoya-linux@dsn.okisemi.com> Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/pch_can.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 8efbe359ba2a..dcd8f0032fd1 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -746,19 +746,16 @@ static int pch_can_poll(struct napi_struct *napi, int quota)
746 746
747 if (int_stat == PCH_STATUS_INT) { 747 if (int_stat == PCH_STATUS_INT) {
748 reg_stat = ioread32(&priv->regs->stat); 748 reg_stat = ioread32(&priv->regs->stat);
749 if (reg_stat & (PCH_BUS_OFF | PCH_LEC_ALL)) {
750 if (reg_stat & PCH_BUS_OFF ||
751 (reg_stat & PCH_LEC_ALL) != PCH_LEC_ALL) {
752 pch_can_error(ndev, reg_stat);
753 quota--;
754 }
755 }
756 749
757 if (reg_stat & PCH_TX_OK) 750 if ((reg_stat & (PCH_BUS_OFF | PCH_LEC_ALL)) &&
758 pch_can_bit_clear(&priv->regs->stat, PCH_TX_OK); 751 ((reg_stat & PCH_LEC_ALL) != PCH_LEC_ALL)) {
752 pch_can_error(ndev, reg_stat);
753 quota--;
754 }
759 755
760 if (reg_stat & PCH_RX_OK) 756 if (reg_stat & (PCH_TX_OK | PCH_RX_OK))
761 pch_can_bit_clear(&priv->regs->stat, PCH_RX_OK); 757 pch_can_bit_clear(&priv->regs->stat,
758 reg_stat & (PCH_TX_OK | PCH_RX_OK));
762 759
763 int_stat = pch_can_int_pending(priv); 760 int_stat = pch_can_int_pending(priv);
764 } 761 }
@@ -900,14 +897,13 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
900 if (can_dropped_invalid_skb(ndev, skb)) 897 if (can_dropped_invalid_skb(ndev, skb))
901 return NETDEV_TX_OK; 898 return NETDEV_TX_OK;
902 899
900 tx_obj_no = priv->tx_obj;
903 if (priv->tx_obj == PCH_TX_OBJ_END) { 901 if (priv->tx_obj == PCH_TX_OBJ_END) {
904 if (ioread32(&priv->regs->treq2) & PCH_TREQ2_TX_MASK) 902 if (ioread32(&priv->regs->treq2) & PCH_TREQ2_TX_MASK)
905 netif_stop_queue(ndev); 903 netif_stop_queue(ndev);
906 904
907 tx_obj_no = priv->tx_obj;
908 priv->tx_obj = PCH_TX_OBJ_START; 905 priv->tx_obj = PCH_TX_OBJ_START;
909 } else { 906 } else {
910 tx_obj_no = priv->tx_obj;
911 priv->tx_obj++; 907 priv->tx_obj++;
912 } 908 }
913 909
@@ -926,9 +922,7 @@ static netdev_tx_t pch_xmit(struct sk_buff *skb, struct net_device *ndev)
926 id2 |= PCH_ID_MSGVAL; 922 id2 |= PCH_ID_MSGVAL;
927 923
928 /* If remote frame has to be transmitted.. */ 924 /* If remote frame has to be transmitted.. */
929 if (cf->can_id & CAN_RTR_FLAG) 925 if (!(cf->can_id & CAN_RTR_FLAG))
930 id2 &= ~PCH_ID2_DIR;
931 else
932 id2 |= PCH_ID2_DIR; 926 id2 |= PCH_ID2_DIR;
933 927
934 iowrite32(id2, &priv->regs->ifregs[1].id2); 928 iowrite32(id2, &priv->regs->ifregs[1].id2);