Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1171976imm; Fri, 27 Jul 2018 12:22:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfxTrBPiE2E5hz4DT6kXt5PR6DYiothvWklkBmbjsDOdtSvz73a3u7RXXRKgxBiyjPU/YjT X-Received: by 2002:a63:a011:: with SMTP id r17-v6mr7049544pge.90.1532719363054; Fri, 27 Jul 2018 12:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532719363; cv=none; d=google.com; s=arc-20160816; b=i2fV/4lPvcUsgx6eEBMghoFSEsShj+1fPeylcN5esiUWvqv0BuTzIgRee6mt518Uf8 ARt1cAY0VkUFvZhBBopQjsYu6k2xemgxpJE0xT43BEF7zRlinSw96znsIUC0DuKixo7X 8VPTe5K2f2fGADIaK3+wRnMEdlAvsuYW9/Xa6DWN3Dm8HrQ4Irm+Xv+PN6IhvADfL92g iDQUPH7/CoJkW8hand6gzmIMy8/2l7vb5Yna6ZrGwnKIsGrkIFiJK9NcZHpnE5IbTVZ+ JzNI+fNR6zOR1+qL2tcO4XJx4aCvS3vpoXXfx5Aof3/XB9lT1UV7ELtwmnH2xcQd20Ug ZTYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=NaageNx6ZQyhNqYFcAfLikNg/escXNyLUINBXGSQSTw=; b=QaDcIal/f2ju4K9UZoVkP59xumGCFa5Wr4ms+JLmiTr/gFblu7ntigTfJlAwV5ICFb PVmQp3ZFuYM++qO4fBE9IOnXhfLKxwWp1u5G5gjXl59dzvLa5JZfIcshpU9mz44UGT60 3YnnYPky87jZWy1r3STrcmeQR2TKxj8nAyypHZY3cTcg20LVPfBy+8PAHKiC8r283i7m AhOze0s1J2lFZrCJDyJbiaUE7/zc+ksliQ047zRm3s9KPWCklRRFNQjZpxVOda7g4Tg6 K/NyaRjmOhlERrDlQojJBs/BhnH6wcWMuBu3yUU+fLqIViERbXIoPemRst9ilh81VYKx oUEg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si4711895pgm.162.2018.07.27.12.22.28; Fri, 27 Jul 2018 12:22:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389277AbeG0Uo1 (ORCPT + 99 others); Fri, 27 Jul 2018 16:44:27 -0400 Received: from smtprelay0135.hostedemail.com ([216.40.44.135]:56892 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389064AbeG0Uo1 (ORCPT ); Fri, 27 Jul 2018 16:44:27 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 1B46A837F252; Fri, 27 Jul 2018 19:21:10 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3355:3622:3865:3867:3870:3871:4250:4321:5007:6117:9010:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12295:12296:12438:12740:12760:12895:13255:13439:13972:14096:14097:14659:14721:21080:21451:21627:30003:30012:30046:30054:30070:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: debt16_27242af689920 X-Filterd-Recvd-Size: 4183 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA; Fri, 27 Jul 2018 19:21:08 +0000 (UTC) Message-ID: <98a6d1cd4d313512d66ced3fc25f438449b3c310.camel@perches.com> Subject: Re: [PATCH net-next] net: ethernet: ti: cpsw: replace unnecessarily macroses on functions From: Joe Perches To: Ivan Khoronzhuk , grygorii.strashko@ti.com, davem@davemloft.net Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 27 Jul 2018 12:21:07 -0700 In-Reply-To: <20180727191318.18698-1-ivan.khoronzhuk@linaro.org> References: <20180727191318.18698-1-ivan.khoronzhuk@linaro.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-07-27 at 22:13 +0300, Ivan Khoronzhuk wrote: > Replace ugly macroses on functions. Careful, see below. > diff --git 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; > +} perhaps better as a switch/case > + > +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; This is not the same code as the new function is not guaranteed to succeed or set skb->dev. > if (unlikely(status < 0) || unlikely(!netif_running(ndev))) { > /* In dual emac mode check for all interfaces */