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: 10162713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D052660245 for ; Sun, 14 Jan 2018 17:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0B52289F0 for ; Sun, 14 Jan 2018 17:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B53F728A6C; Sun, 14 Jan 2018 17:52:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB53128A55 for ; Sun, 14 Jan 2018 17:52:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751889AbeANRwO (ORCPT ); Sun, 14 Jan 2018 12:52:14 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33461 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916AbeANRwH (ORCPT ); Sun, 14 Jan 2018 12:52:07 -0500 Received: by mail-lf0-f66.google.com with SMTP id j143so10875365lfg.0 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=m6pytC7/mOQvsigD4km8gsZMzUWjTbd2g+8+IgUj4ka7UWrhPip9E2X/qZFf//T8Si hMazMi55oVwvIB6pcMfW8VJFO+wPmuisFCFBD9CbNHnQ/R7LeOzumjXcWxNcrih84ua1 ssNvsIFrtZYQImImJ/1YngROz7shwMw7XP2Tvqidwf7CFsJgzpS+rkSkw7W3iUymicjv i+Bbu9+JIT4uqrsUaY6fOYbhkKv8JJYibSDfiV4hx8vwEfpyx62vCRe1A2LqrgXbBCjL KcgsxDaYgt4dqSZqNsGRRCZo4jvBGRXcEeQh1O2KsB6iv2Ol7iG8aqi9+30oZ5cyI8xO B8yQ== X-Gm-Message-State: AKwxytdRYr1IHKrF+m0WiEGaCudVGY8Gx3LXa1LocHTQhTALuaQ96zqa mxRkFldtd0H9KqsM9SviGzag6lthwck= 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: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);