Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1248590imm; Fri, 27 Jul 2018 13:51:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeDZSmXBAnNN0qos8nJ5jAg3EuXIXMW7EYAw/1uiJuXtqwwl/JCEqfxbc1OToLPbWT16VKt X-Received: by 2002:a17:902:8308:: with SMTP id bd8-v6mr7404224plb.329.1532724672924; Fri, 27 Jul 2018 13:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532724672; cv=none; d=google.com; s=arc-20160816; b=vXlIhxvpSw8CgdNgpcgedbBdmSeaCOERnnbSmsUjiOnuKVAnEZzmOnj7gSgUKCkKjN nFOo83IEId+5SRcubJBk0hhcT/qn3XDwkadmny6RaPbWjyHiazVSlmNpYSSOBMjQIC2R bejYawuO2uS9k6TWhNWLl8OETHFB2IJ26TMRpEmSxuvFhPP3G2aUGuK6H7XVOXKXt9SE D73sgk5bypjeyNsPVryD0v1wT3wMqDU9L1ccw6/HgpVxXGFw9VPvxjbf/4tO3odWwFDZ sohm0mYZ3SZ1yfDTbjdAV/Bi3TY6BluV2vmavXzCBEv2JGIka76GbgY2tz5wIHjVzbXG TPJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=NAl3yy/7hIcejXSfbK5GMYeiMaRlfOfS3qnBt7Q+wUY=; b=b7ZhfM4Wn5ArQa5wOJosemqrIV63WcYw067Ctkm8A6qQXOmADaukR6YC0aivRpd/ge +D/pMxIJBSfqrilP3OioJx2xi09KyK+8T4Cdq8QaYP5uBoPGyYBh6YKM/JEmnOPSiXEu LlkyOqPwZUhqc716uWUu6f01a8oBiU7y1s0McxkYNTPc195TXcwKhidO/51ZBNsep3LP bt9mvl+ZZGT/ZFNptyudwt3iMVcSvuBxeIx94jMpPrKMhgcmsbWSd1aplK7DdXEZ3akX k/DS+pTqaWwm6xPflvKi1yR04ryWQNMXI5OKG3MiCUFhf2PdkSU8VAZ3vqowT/10yya/ lbRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WpBLoTmF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28-v6si4803260pgk.111.2018.07.27.13.50.58; Fri, 27 Jul 2018 13:51:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WpBLoTmF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389705AbeG0WNk (ORCPT + 99 others); Fri, 27 Jul 2018 18:13:40 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36142 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389434AbeG0WNj (ORCPT ); Fri, 27 Jul 2018 18:13:39 -0400 Received: by mail-lj1-f195.google.com with SMTP id u7-v6so5521945lji.3 for ; Fri, 27 Jul 2018 13:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=NAl3yy/7hIcejXSfbK5GMYeiMaRlfOfS3qnBt7Q+wUY=; b=WpBLoTmFiXfnCpnFEmeFUPy/vbP3B/9MBcXBjycAmGKdehuxQ4WLrRWDh6YOK/t/wh pLcOxmJdRW8V5CCKzxbSAzPF6IwjVUSpB9XHOSjQ7zznXhDGHLi8wJG9/JCIyP8q9ffB jSf1hXU8Qf6616opv0CNhUaw6w5+FAcy03S8g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=NAl3yy/7hIcejXSfbK5GMYeiMaRlfOfS3qnBt7Q+wUY=; b=FA8IivV/R1p0HrhcL22ZxKFfxD5VbnN4QDvd3122QyLV9aN7EwAw1mP6IVrSdSzYN8 xIM/jzARuJL1xQbZBhixC/2J8Wh1Y370KUKkALbbO8zmobZNiWmLU2wuowCoX+Xk9vBT 5w/M9qRmhSPORqcr083g/z94dalHk4wRjSYJKTY86oW+4oAmsO5n/UDFIu5JGbGkqX5I erLC4qouVAg9tmcycQgpGTpVPGustgAmmgg+LWN6NsbeH8Xhv7e0gVvFDz8bkIKByBer OOUNUzAqyqnhaAFchBoG09CZbC6jEwlfuS6OwD1uO32DJtlIQ8j9uZn83fJ3RS7Ddxcu awDA== X-Gm-Message-State: AOUpUlFhyJV92RHsMH7ul+6gQYSkavHgMF95OEdjxu6kG0tnEI2n5vu2 pESLYvgHxH1cTAISon7RgWOdPQ== X-Received: by 2002:a2e:429c:: with SMTP id h28-v6mr5940082ljf.67.1532724602350; Fri, 27 Jul 2018 13:50:02 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 14-v6sm812947ljc.74.2018.07.27.13.50.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 13:50:01 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: andrew@lunn.ch, joe@perches.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH v2 net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Date: Fri, 27 Jul 2018 23:49:58 +0300 Message-Id: <20180727204958.23658-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace ugly macroses on functions. v2..v1: - removed inline for cpsw_src_port_detect() Reviewed-by: Grygorii Strashko Signed-off-by: Ivan Khoronzhuk --- Based on net-next/master drivers/net/ethernet/ti/cpsw.c | 63 +++++++++++++++++----------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1b54c26c2bec..9cacfe4ad065 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -565,40 +565,40 @@ static const struct cpsw_stats cpsw_gstrings_ch_stats[] = { (func)(slave++, ##arg); \ } while (0) -#define cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb) \ - do { \ - if (!cpsw->data.dual_emac) \ - break; \ - if (CPDMA_RX_SOURCE_PORT(status) == 1) { \ - ndev = cpsw->slaves[0].ndev; \ - skb->dev = ndev; \ - } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \ - ndev = cpsw->slaves[1].ndev; \ - skb->dev = ndev; \ - } \ - } while (0) -#define cpsw_add_mcast(cpsw, priv, addr) \ - do { \ - if (cpsw->data.dual_emac) { \ - struct cpsw_slave *slave = cpsw->slaves + \ - priv->emac_port; \ - int slave_port = cpsw_get_slave_port( \ - slave->slave_num); \ - cpsw_ale_add_mcast(cpsw->ale, addr, \ - 1 << slave_port | ALE_PORT_HOST, \ - ALE_VLAN, slave->port_vlan, 0); \ - } else { \ - cpsw_ale_add_mcast(cpsw->ale, addr, \ - ALE_ALL_PORTS, \ - 0, 0, 0); \ - } \ - } while (0) - static inline int cpsw_get_slave_port(u32 slave_num) { return slave_num + 1; } +static void cpsw_src_port_detect(struct cpsw_common *cpsw, int status, + struct sk_buff *skb) +{ + if (!cpsw->data.dual_emac) + return; + + if (CPDMA_RX_SOURCE_PORT(status) == 1) + skb->dev = cpsw->slaves[0].ndev; + else if (CPDMA_RX_SOURCE_PORT(status) == 2) + skb->dev = cpsw->slaves[1].ndev; +} + +static void cpsw_add_mcast(struct cpsw_priv *priv, u8 *addr) +{ + struct cpsw_common *cpsw = priv->cpsw; + + if (cpsw->data.dual_emac) { + struct cpsw_slave *slave = cpsw->slaves + priv->emac_port; + int slave_port = cpsw_get_slave_port(slave->slave_num); + + cpsw_ale_add_mcast(cpsw->ale, addr, + 1 << slave_port | ALE_PORT_HOST, + ALE_VLAN, slave->port_vlan, 0); + return; + } + + cpsw_ale_add_mcast(cpsw->ale, addr, ALE_ALL_PORTS, 0, 0, 0); +} + static void cpsw_set_promiscious(struct net_device *ndev, bool enable) { struct cpsw_common *cpsw = ndev_to_cpsw(ndev); @@ -706,7 +706,7 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev) /* program multicast address list into ALE register */ netdev_for_each_mc_addr(ha, ndev) { - cpsw_add_mcast(cpsw, priv, (u8 *)ha->addr); + cpsw_add_mcast(priv, (u8 *)ha->addr); } } } @@ -801,7 +801,8 @@ static void cpsw_rx_handler(void *token, int len, int status) int ret = 0; struct cpsw_common *cpsw = ndev_to_cpsw(ndev); - cpsw_dual_emac_src_port_detect(cpsw, status, ndev, skb); + cpsw_src_port_detect(cpsw, status, skb); + ndev = skb->dev; if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { /* In dual emac mode check for all interfaces */ -- 2.17.1