From patchwork Tue Aug 9 23:22:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 73580 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp127715qga; Tue, 9 Aug 2016 16:24:00 -0700 (PDT) X-Received: by 10.66.165.67 with SMTP id yw3mr1668503pab.8.1470785038403; Tue, 09 Aug 2016 16:23:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si23283297pas.31.2016.08.09.16.23.58; Tue, 09 Aug 2016 16:23:58 -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; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932789AbcHIXXg (ORCPT + 27 others); Tue, 9 Aug 2016 19:23:36 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37936 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932718AbcHIXXa (ORCPT ); Tue, 9 Aug 2016 19:23:30 -0400 Received: by mail-wm0-f45.google.com with SMTP id o80so66907602wme.1 for ; Tue, 09 Aug 2016 16:23:29 -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:in-reply-to:references; bh=aoNZ/lL1hX2vIaskFQvl+4uyBRaf/qDjlTBOzdKb5BE=; b=E6QV89YdxpI5h4h06kSz2NYXCL8meX0nCnb0ZaLl+P6uTVTW0OnVNmA1qy724ObxXN G/lJrTODGSg2k9mNYnHO7GjfSifDS6gSgnjRCX+LZmYRKAO1xaNAmxvbGjXBkx++cVa6 Cjt2Na/OL+0jzj+sok53nEt+9ZTvvxKNAEo4Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aoNZ/lL1hX2vIaskFQvl+4uyBRaf/qDjlTBOzdKb5BE=; b=FrPXDWWre9qUAY7/e9aI9HpOwhVd3XRn9Fodm3Q93qO+SSTld4bFgoRnMY76XmajUZ RyVSppPI9xIkrLNgGKr8P9Mt+TFWSgcjlxuhAxjHne72cPALWOoOK+DR986fnBYGk+t0 hDFjxfWhvL0zPP4YPqtt+enHt7VsprO8DaUoYbmQdoDL+XV24qOSGMFIf5aIjYBe5HBJ kRQZ+JHrnztoEst/tk8Drao3Oke/yjnDdoFnswz7b5CcJZl1cX4oUEeEPDhon4Y/x8di R/GClw0UBZGMClGRq8EaXd7PnVMuG+AqvujUerzoudb6uFrFwEb5YQ+zFf9hxkSMU3Eh lMmg== X-Gm-Message-State: AEkoouu8hfMz6H6j7TDBfmaSqAXiGE1n6OwK1tzMqbYxo7JVS9HN4+IZtybinymb1qP2oLXJ X-Received: by 10.25.1.133 with SMTP id 127mr150927lfb.54.1470785008892; Tue, 09 Aug 2016 16:23:28 -0700 (PDT) Received: from localhost.localdomain (88-203-94-178.pool.ukrtel.net. [178.94.203.88]) by smtp.gmail.com with ESMTPSA id s2sm904627lja.35.2016.08.09.16.23.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 16:23:28 -0700 (PDT) From: Ivan Khoronzhuk To: netdev@vger.kernel.org, mugunthanvnm@ti.com, grygorii.strashko@ti.com Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, dlide@ti.com, Ivan Khoronzhuk Subject: [PATCH v3 05/13] net: ethernet: ti: cpsw: don't check slave num in runtime Date: Wed, 10 Aug 2016 02:22:36 +0300 Message-Id: <1470784964-26440-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470784964-26440-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1470784964-26440-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No need to check const slave num in runtime for every packet, and ndev for slaves w/o ndev is anyway NULL. So remove redundant check and macro. Reviewed-by: Mugunthan V N Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 1.9.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 0b6958d..cfbb1f2 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -497,9 +497,6 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = { n; n--) \ (func)(slave++, ##arg); \ } while (0) -#define cpsw_get_slave_ndev(priv, __slave_no__) \ - ((__slave_no__ < priv->data.slaves) ? \ - priv->slaves[__slave_no__].ndev : NULL) #define cpsw_get_slave_priv(priv, __slave_no__) \ (((__slave_no__ < priv->data.slaves) && \ (priv->slaves[__slave_no__].ndev)) ? \ @@ -510,11 +507,11 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = { if (!priv->data.dual_emac) \ break; \ if (CPDMA_RX_SOURCE_PORT(status) == 1) { \ - ndev = cpsw_get_slave_ndev(priv, 0); \ + ndev = priv->slaves[0].ndev; \ priv = netdev_priv(ndev); \ skb->dev = ndev; \ } else if (CPDMA_RX_SOURCE_PORT(status) == 2) { \ - ndev = cpsw_get_slave_ndev(priv, 1); \ + ndev = priv->slaves[1].ndev; \ priv = netdev_priv(ndev); \ skb->dev = ndev; \ } \ @@ -2561,7 +2558,7 @@ static int cpsw_remove(struct platform_device *pdev) } if (priv->data.dual_emac) - unregister_netdev(cpsw_get_slave_ndev(priv, 1)); + unregister_netdev(priv->slaves[1].ndev); unregister_netdev(ndev); cpsw_ale_destroy(priv->ale); @@ -2570,7 +2567,7 @@ static int cpsw_remove(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); if (priv->data.dual_emac) - free_netdev(cpsw_get_slave_ndev(priv, 1)); + free_netdev(priv->slaves[1].ndev); free_netdev(ndev); return 0; }