Skip to content

Commit fea49f6

Browse files
ikhorndavem330
authored andcommitted
net: ethernet: ti: cpsw: replace unnecessarily macroses on functions
Replace ugly macroses on functions. Reviewed-by: Grygorii Strashko <[email protected]> Signed-off-by: Ivan Khoronzhuk <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e6476c2 commit fea49f6

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

drivers/net/ethernet/ti/cpsw.c

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -565,40 +565,28 @@ static const struct cpsw_stats cpsw_gstrings_ch_stats[] = {
565565
(func)(slave++, ##arg); \
566566
} while (0)
567567

568-
#define cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb) \
569-
do { \
570-
if (!cpsw->data.dual_emac) \
571-
break; \
572-
if (CPDMA_RX_SOURCE_PORT(status) == 1) { \
573-
ndev = cpsw->slaves[0].ndev; \
574-
skb->dev = ndev; \
575-
} else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \
576-
ndev = cpsw->slaves[1].ndev; \
577-
skb->dev = ndev; \
578-
} \
579-
} while (0)
580-
#define cpsw_add_mcast(cpsw, priv, addr) \
581-
do { \
582-
if (cpsw->data.dual_emac) { \
583-
struct cpsw_slave *slave = cpsw->slaves + \
584-
priv->emac_port; \
585-
int slave_port = cpsw_get_slave_port( \
586-
slave->slave_num); \
587-
cpsw_ale_add_mcast(cpsw->ale, addr, \
588-
1 << slave_port | ALE_PORT_HOST, \
589-
ALE_VLAN, slave->port_vlan, 0); \
590-
} else { \
591-
cpsw_ale_add_mcast(cpsw->ale, addr, \
592-
ALE_ALL_PORTS, \
593-
0, 0, 0); \
594-
} \
595-
} while (0)
596-
597568
static inline int cpsw_get_slave_port(u32 slave_num)
598569
{
599570
return slave_num + 1;
600571
}
601572

573+
static void cpsw_add_mcast(struct cpsw_priv *priv, u8 *addr)
574+
{
575+
struct cpsw_common *cpsw = priv->cpsw;
576+
577+
if (cpsw->data.dual_emac) {
578+
struct cpsw_slave *slave = cpsw->slaves + priv->emac_port;
579+
int slave_port = cpsw_get_slave_port(slave->slave_num);
580+
581+
cpsw_ale_add_mcast(cpsw->ale, addr,
582+
1 << slave_port | ALE_PORT_HOST,
583+
ALE_VLAN, slave->port_vlan, 0);
584+
return;
585+
}
586+
587+
cpsw_ale_add_mcast(cpsw->ale, addr, ALE_ALL_PORTS, 0, 0, 0);
588+
}
589+
602590
static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
603591
{
604592
struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
@@ -706,7 +694,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
706694

707695
/* program multicast address list into ALE register */
708696
netdev_for_each_mc_addr(ha, ndev) {
709-
cpsw_add_mcast(cpsw, priv, (u8 *)ha->addr);
697+
cpsw_add_mcast(priv, ha->addr);
710698
}
711699
}
712700
}
@@ -798,10 +786,16 @@ static void cpsw_rx_handler(void *token, int len, int status)
798786
struct sk_buff *skb = token;
799787
struct sk_buff *new_skb;
800788
struct net_device *ndev = skb->dev;
801-
int ret = 0;
789+
int ret = 0, port;
802790
struct cpsw_common *cpsw = ndev_to_cpsw(ndev);
803791

804-
cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb);
792+
if (cpsw->data.dual_emac) {
793+
port = CPDMA_RX_SOURCE_PORT(status);
794+
if (port) {
795+
ndev = cpsw->slaves[--port].ndev;
796+
skb->dev = ndev;
797+
}
798+
}
805799

806800
if (unlikely(status < 0) || unlikely(!netif_running(ndev))) {
807801
/* In dual emac mode check for all interfaces */

0 commit comments

Comments
 (0)