Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1164784imm; Fri, 27 Jul 2018 12:14:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeVgRpVtAXPYfv9zaMIKVCleW+zY1pATJzCLsHwbZVyEBmxWjZR3LmOrMZTgwli5kO6wRtl X-Received: by 2002:a17:902:8b8b:: with SMTP id ay11-v6mr6955532plb.1.1532718875196; Fri, 27 Jul 2018 12:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532718875; cv=none; d=google.com; s=arc-20160816; b=IGHXoCv41aSPCv5KttKZvLNeGWeCVbOpXl08+Vqe4VKGEHyrgEqzO5Mehk/QRbQOtf h2GTA0UvG4UoL1CAhYd6hrvdk6vMNDt4L4LbQjSaaq7PUDXYRtdgybP+jitkxjPZFzoN gggTEaZM6Jy4gzT2yfsobtR9p65eN3YaixoD6zW2G518DIiKhRm9DzVH84lRnzvFxYnm B7WHaekXwnAUmQw5k2XvCIeuYoBbcWdIe7xb47mPpsO5De8V6FSPKPZHuzs83fxvO+tT kzwWKJqQFvQX/UzN9SEztZDm1VrK0uOZwKa5HIVUtSVJai4PnKxBNSJ1OBZdi1ckVTzN Zqug== 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=vEPWKyHQ98lAKCw3xpYUTv1vSr+cHqHxHD2ia9o9nFE=; b=x91k+cGayQTh4WiNReuRRRijurt+Xts9zUkU7imCrLDMPXMkEJ9TfRmKSrF14C2FQO ksbpND5dtJy9sNzoBjrnbXnzaUA1l1nWI5GphI0JdC/QV541ctwatpENw/QPF2KVsxlc R8/5PG07QNI4B+OD0yE9WN14n9mBIXeCmT9u77zN4Y7cGfwump1Zej0TZVehckeWOXI0 TL1G25iL5b9cjAr26LTsCtgXu0TOX7sArnO/cMy75VFMVKvMwc8zaqNv9UMfz4u3UeEj R25BqC6r7AyHKx0wmWQdqBTgRsgPXHHsCOpOU/hjRzSA1vus7CLjh8rmCZOnt4hDmCAN 8YrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=anWEh31u; 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 y18-v6si4143838pll.82.2018.07.27.12.14.19; Fri, 27 Jul 2018 12:14:35 -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=anWEh31u; 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 S2389212AbeG0Ugi (ORCPT + 99 others); Fri, 27 Jul 2018 16:36:38 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38155 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389130AbeG0Ugi (ORCPT ); Fri, 27 Jul 2018 16:36:38 -0400 Received: by mail-lf1-f65.google.com with SMTP id a4-v6so4223829lff.5 for ; Fri, 27 Jul 2018 12:13:23 -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=vEPWKyHQ98lAKCw3xpYUTv1vSr+cHqHxHD2ia9o9nFE=; b=anWEh31uMo+xVMSm5VCxlsZtOM/CEU4w+MBHE67MZ90JYh55YIUszCy7bEXwrmVIN1 GnFLRVdBuvJ043SzMmjf+LF3YLFO/G5SUFgo1sjMlgC0WPvNyDauNrQzM35fyWFJRDJw dPq6XDzRr2aVHt19x7MNr1qowZgzaCvzoNOM0= 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=vEPWKyHQ98lAKCw3xpYUTv1vSr+cHqHxHD2ia9o9nFE=; b=trN0m8cLQ/MmBsXS415vv7e1BREHZUzcqw9IoWooBLp6TUWBockZQofycjR+bDzC/K 3mmOUX2/gbtYqpDlZCHIPw/LpqrnS7t0Vglw3ipwzxIi/R4hTngJoqwkQzmoVaM8U9Cl uWq8mBYw/kDdjQ2BAltcQuTmlQUtpqkIsHJUIzOlYczanJyUwwahzBpR+tlifxbtL9Xv PMgjtHUN4OWGjrC3ZlSVgMUyQ+VkRxS+Xn3s6Fqc3Gr7Uvii+ZLylBd5FSIzxXLsoynv LhffPqVxiyiMUkzANSzWLJo48dkdUmcFB9iNAEsXHXYn+GjcuT4C4rJ2uDCJD3nPb9mz vWUA== X-Gm-Message-State: AOUpUlF5x6o+SORaQvTroKs/tRyQT+CVvDTaAKvnztGA1rMbUIuFVXBX TyKjTBdx/ZSvYaKNhclR8OvOEg== X-Received: by 2002:a19:5d54:: with SMTP id p20-v6mr4633267lfj.143.1532718802274; Fri, 27 Jul 2018 12:13:22 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id 73-v6sm635586lfs.44.2018.07.27.12.13.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jul 2018 12:13:21 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions Date: Fri, 27 Jul 2018 22:13:18 +0300 Message-Id: <20180727191318.18698-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. 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..62326a98945b 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 inline 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