From patchwork Sun Jan 14 17:47:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 860492 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=cogentembedded-com.20150623.gappssmtp.com header.i=@cogentembedded-com.20150623.gappssmtp.com header.b="Ed6G44A+"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zKPFb33xDz9sPk for ; Mon, 15 Jan 2018 04:52:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752000AbeANRwN (ORCPT ); Sun, 14 Jan 2018 12:52:13 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:44114 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751918AbeANRwH (ORCPT ); Sun, 14 Jan 2018 12:52:07 -0500 Received: by mail-lf0-f67.google.com with SMTP id w23so10832833lfd.11 for ; Sun, 14 Jan 2018 09:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:user-agent:date:to:cc:subject:mime-version :content-disposition; bh=FE398uAtsQaHm/ttLPgYNbfYab6yxKNLBS/CsoD+S8A=; b=Ed6G44A+yiBVmYgIyBSKIvh5kMLcFp1q8BR4Qn/ab7SwnEl2toukLoNfqbq9c94s89 W6E3zTd04Paj7fu0ZO12yAGIH1YVWqAINy+o7M3LmhrWrb3qBpedCaCXD7zfvGuAwwjp kh6W/8zmUqhAogKUTypbJZisAOYQZ6roOuQUxqNnQzSeDTuzdEh0XXH4MPjmGpGt75Dg rP4KKTQ5V3o7C3mjmedES5VyHt/1XgfsdVKqH42fM8YOZJjxPYAeoYwCeilIe0uoSOf7 5YL+4wBBGi/vNmNToc0qFmpcfxSwoL8aX0JcyKdyBtoAsYsOJ900zjRbOc1ZAI9n4HlA 93yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:user-agent:date:to:cc:subject :mime-version:content-disposition; bh=FE398uAtsQaHm/ttLPgYNbfYab6yxKNLBS/CsoD+S8A=; b=DqdIcsppVsoFpUWlxKfWjD6tSqnKRQW1i3tP+e0O1uvO+1ARy7YKYi2eEJ8Bxslj8m mkAzmCcUQFjfZ4HtCqGqXsDW1dmqMLuTHhWQH/eQqRdFJ6+fptcQllh50spbTLFoWybi KqcloxNKV1+UjEQgKlZ3s7hFNGKklA82lu1UBbQ3FtS/0tW3rC4jT9AJLIysX0yV2Wfh 24igp82B9hFK+cemqxtclILBfR9Prz2pv1W4aobXy5qivLfdk25dPGuUdIPNso67SWie NQFGrdnM+yNg5gJxLUOrAofexEBC9NMIYhfu5NuTwUg8C+U7/+N2NM8kJqClKl47hCxS /w1A== X-Gm-Message-State: AKwxytdqjj+x0IRTXiEfklNR6FO1372oXF0klmtVXRyib3A6voouCYKZ F3/wZyOWbV0B5oJUF1pyb5nx0O9QeDA= X-Google-Smtp-Source: ACJfBos1rwHu5qA5MFXNvBTodZusFb3W1sSmfcmgWfLDDZYn56sNVzNzlkYJv0F5Ytw/kb0RfvwDxw== X-Received: by 10.25.145.94 with SMTP id y30mr3789665lfj.1.1515952325989; Sun, 14 Jan 2018 09:52:05 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.87.9]) by smtp.gmail.com with ESMTPSA id i18sm4993774ljc.86.2018.01.14.09.52.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Jan 2018 09:52:05 -0800 (PST) From: Sergei Shtylyov X-Google-Original-From: "Sergei Shtylyov" Received: by wasted.cogentembedded.com (sSMTP sendmail emulation); Sun, 14 Jan 2018 20:52:03 +0300 Message-Id: <20180114175203.191929089@cogentembedded.com> User-Agent: quilt/0.64 Date: Sun, 14 Jan 2018 20:47:44 +0300 To: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: linux-sh@vger.kernel.org, Sergei Shtylyov Subject: [PATCH 2/2] sh_eth: get Ether port # only when needed MIME-Version: 1.0 Content-Disposition: inline; filename=sh_eth-get-Ether-port-#-only-when-needed.patch Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The dual-port Ether configurations always have a shared TSU to e.g. pass the packets between those ports. With the TSU init. code gathered under the single *if*, we now can only get the port # from 'platform_device::id' only when we actually need it (and not recalculate it each time)... Signed-off-by: Sergei Shtylyov Reviewed-by: Geert Uytterhoeven --- drivers/net/ethernet/renesas/sh_eth.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c @@ -3125,7 +3125,7 @@ static int sh_eth_drv_probe(struct platf const struct platform_device_id *id = platform_get_device_id(pdev); struct sh_eth_private *mdp; struct net_device *ndev; - int ret, devno; + int ret; /* get base addr */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platf pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); - devno = pdev->id; - if (devno < 0) - devno = 0; - ret = platform_get_irq(pdev, 0); if (ret < 0) goto out_release; @@ -3223,6 +3219,7 @@ static int sh_eth_drv_probe(struct platf } if (mdp->cd->tsu) { + int port = pdev->id < 0 ? 0 : pdev->id % 2; struct resource *rtsu; rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); @@ -3234,7 +3231,7 @@ static int sh_eth_drv_probe(struct platf /* We can only request the TSU region for the first port * of the two sharing this TSU for the probe to succeed... */ - if (devno % 2 == 0 && + if (port == 0 && !devm_request_mem_region(&pdev->dev, rtsu->start, resource_size(rtsu), dev_name(&pdev->dev))) { @@ -3250,11 +3247,11 @@ static int sh_eth_drv_probe(struct platf ret = -ENOMEM; goto out_release; } - mdp->port = devno % 2; + mdp->port = port; ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER; /* Need to init only the first port of the two sharing a TSU */ - if (devno % 2 == 0) { + if (port == 0) { if (mdp->cd->chip_reset) mdp->cd->chip_reset(ndev);