From patchwork Fri Dec 4 21:58:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 7772231 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 86ACCBEEE1 for ; Fri, 4 Dec 2015 21:59:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B009120623 for ; Fri, 4 Dec 2015 21:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CA81D20620 for ; Fri, 4 Dec 2015 21:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756472AbbLDV7B (ORCPT ); Fri, 4 Dec 2015 16:59:01 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:33589 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755224AbbLDV7A (ORCPT ); Fri, 4 Dec 2015 16:59:00 -0500 Received: by lfaz4 with SMTP id z4so121069144lfa.0 for ; Fri, 04 Dec 2015 13:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :in-reply-to:references:mime-version:content-transfer-encoding :content-type; bh=B/oRrY3Ypx1JRka5K7r3NMt+s3mIHNTqfAiLm3zG51w=; b=DbsQwJfwI7+Hsv2cOEMRl7qAN2EOzDF5lTjt1dFikit5bqSR0seejpim0T+VaRbEe6 6hbAN1coygptTyDRO+O4sB1BsIUlZojhaCmTus9WD7G3OITxulQTYpoe6/dqB1XO9l68 tjpLDnIw5zFLIA4MOLqRc+8WsrsnypxfgAShF++4F3gR5fleuFTZsNaafDHlvsgwxO4W ZUkFV1+aY1m5n8nFksz24SazgeIFqWVuVXGZq86qAvl4proDFC0/vuQl9hRhCBjpCqmQ UrkfrhrQkTNzcGY9xMhyraScA//b509JGB9HKQaNGGY2glZ4Ovb1OHiVeaXiAJjEKoso 4h0w== 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:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=B/oRrY3Ypx1JRka5K7r3NMt+s3mIHNTqfAiLm3zG51w=; b=bvkiVrwoP/zeMuiMaLmVrIoq575vRhbGr2VQ2puoemttL7ExllaUDf5VYilKlWoc2f 5pSsVFCjIqbPrVvXbRld/+igDwheDn/0+cE7lv3uwYmX+NbXmQ5lYkfzpZlLHMrye6ID cgrUL0cW+PvTykb19r7W+K2xUrxpQiKsgkw7bDnAZMmWl+ZSUiO1WsuPBVDxkQMCfar8 o/dg2zwYR1Mtt1SdTYP8b2zeoUdOL3WjaO1/PEZfks4rVv5iIrXJG5RRnlhZVWSYp0sy sJWLbk9jAb+Sr+NHueYOFGqarDhAyEpYL9zXBa6s4QBSCBbt+VFh4E9Wux7pak2zrh9Z mW6Q== X-Gm-Message-State: ALoCoQmdPOfaqYdKEQyzv6UsHJIXgFbR53gBlQE+zAtv6EWbMfwvvf0yJoOXOtbDG5dThOmhWw6R X-Received: by 10.25.170.149 with SMTP id t143mr9094664lfe.162.1449266338942; Fri, 04 Dec 2015 13:58:58 -0800 (PST) Received: from wasted.cogentembedded.com ([195.16.110.195]) by smtp.gmail.com with ESMTPSA id us1sm2605317lbc.25.2015.12.04.13.58.58 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Dec 2015 13:58:58 -0800 (PST) From: Sergei Shtylyov To: netdev@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH 2/2] sh_eth: read MAC address registers only once Date: Sat, 05 Dec 2015 00:58:57 +0300 Message-ID: <2035649.FBvo9Og81d@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.14.10 (Linux/4.2.6-201.fc22.x86_64; KDE/4.14.14; x86_64; ; ) In-Reply-To: <10429393.qU4CxZ5nlj@wasted.cogentembedded.com> References: <10429393.qU4CxZ5nlj@wasted.cogentembedded.com> MIME-Version: 1.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The code reading the MAHR/MALR registers in read_mac_address() is terribly ineffective -- it reads MAHR 4 times and MALR 2 times, while it's enough to read each register only once. Use the local variables to achieve that, somewhat beautifying the code while at it... Signed-off-by: Sergei Shtylyov --- drivers/net/ethernet/renesas/sh_eth.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 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 @@ -989,12 +989,15 @@ static void read_mac_address(struct net_ if (mac[0] || mac[1] || mac[2] || mac[3] || mac[4] || mac[5]) { memcpy(ndev->dev_addr, mac, ETH_ALEN); } else { - ndev->dev_addr[0] = (sh_eth_read(ndev, MAHR) >> 24); - ndev->dev_addr[1] = (sh_eth_read(ndev, MAHR) >> 16) & 0xFF; - ndev->dev_addr[2] = (sh_eth_read(ndev, MAHR) >> 8) & 0xFF; - ndev->dev_addr[3] = (sh_eth_read(ndev, MAHR) & 0xFF); - ndev->dev_addr[4] = (sh_eth_read(ndev, MALR) >> 8) & 0xFF; - ndev->dev_addr[5] = (sh_eth_read(ndev, MALR) & 0xFF); + u32 mahr = sh_eth_read(ndev, MAHR); + u32 malr = sh_eth_read(ndev, MALR); + + ndev->dev_addr[0] = (mahr >> 24) & 0xFF; + ndev->dev_addr[1] = (mahr >> 16) & 0xFF; + ndev->dev_addr[2] = (mahr >> 8) & 0xFF; + ndev->dev_addr[3] = (mahr >> 0) & 0xFF; + ndev->dev_addr[4] = (malr >> 8) & 0xFF; + ndev->dev_addr[5] = (malr >> 0) & 0xFF; } }