From patchwork Fri Dec 4 21:58:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 7772221 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 224F39F39B for ; Fri, 4 Dec 2015 21:58:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4420420623 for ; Fri, 4 Dec 2015 21:58:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E42620620 for ; Fri, 4 Dec 2015 21:58:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756680AbbLDV6N (ORCPT ); Fri, 4 Dec 2015 16:58:13 -0500 Received: from mail-lf0-f46.google.com ([209.85.215.46]:34320 "EHLO mail-lf0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756661AbbLDV6L (ORCPT ); Fri, 4 Dec 2015 16:58:11 -0500 Received: by lffu14 with SMTP id u14so120924672lff.1 for ; Fri, 04 Dec 2015 13:58:10 -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=+LFSpVdvtYSR1HMEHJKjViTB5v2wf7saTpTgKnIBfvQ=; b=H2hn/qgQhOKUfCbLGaLO6XipphGSNxG0x6oSzwqqd+TF07XdFkl9KCzfz3zdn+RufP 8KonjbLitL7guplX8IOo0iF7jTmXKOPCgVK5T0/Pzq+6sk0Virg1b2WTZ2Ko7MRzfga/ MIA9l6d7D+rQITMIMn1Wn/R9rfiU7N/4SDc2AYA8d63dvdcONaT2hBfIWl2C/2g0X53O 4ZZcwZh1W0edwBKDt+AK1dG9cUH+oG65QKWjBflArVwgUjQO9owoeP/YPOQTa8EBhMg2 XIkm/nqtHWo0Clql2r/yvZ2ooDhTfuj4dfksJt+Sfv/aGG5UNxxciWdgfV2fAYJ0DbCf HhQw== 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=+LFSpVdvtYSR1HMEHJKjViTB5v2wf7saTpTgKnIBfvQ=; b=GwaROkNR9pUToTKPjz/LT2Rx+kQOW+q/ghuCnaZjoQniEMT62o0WxvI+zx0JfGGlJF anp2AWviGwcXkwvP8W0dORckde+HL4mbcj30uJh9hrattoJ042wEuYyYIUmnT5bSn+7D Om7foFCaS/tf4cXDtqgPECMdpfMvF8XtFIrUVPV74DYw2K+5+lTaP075hr8E0+e98dUI FWZIJcPr/OX0SYk5f7xboJBKz30zJ95zTDBfQpZNqagCZobWmjHKZA2Nl9kyZ/SJ6/ax woGhoe2fhbP4huCy2C3QMKsjsgy4OqVuNRO1RVvk2ADlv0NCnaAyrQr/sWMW+UmHDFQi M6Gw== X-Gm-Message-State: ALoCoQkkvqqZkdUa1XbKPVAinnOCcbTOOLRzkMOEkPO4NBqBcoOtdc7CI0WmYBX2HWhHmJ/+9eqB X-Received: by 10.25.218.196 with SMTP id r187mr9354429lfg.59.1449266290159; Fri, 04 Dec 2015 13:58:10 -0800 (PST) Received: from wasted.cogentembedded.com ([195.16.110.195]) by smtp.gmail.com with ESMTPSA id 42sm2710260lfv.29.2015.12.04.13.58.09 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Dec 2015 13:58:09 -0800 (PST) From: Sergei Shtylyov To: netdev@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH 1/2] ravb: read MAC address registers only once Date: Sat, 05 Dec 2015 00:58:07 +0300 Message-ID: <6904286.WCKWH7i1NK@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 ravb_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/ravb_main.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/ravb_main.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/ravb_main.c +++ net-next/drivers/net/ethernet/renesas/ravb_main.c @@ -115,12 +115,15 @@ static void ravb_read_mac_address(struct if (mac) { ether_addr_copy(ndev->dev_addr, mac); } else { - ndev->dev_addr[0] = (ravb_read(ndev, MAHR) >> 24); - ndev->dev_addr[1] = (ravb_read(ndev, MAHR) >> 16) & 0xFF; - ndev->dev_addr[2] = (ravb_read(ndev, MAHR) >> 8) & 0xFF; - ndev->dev_addr[3] = (ravb_read(ndev, MAHR) >> 0) & 0xFF; - ndev->dev_addr[4] = (ravb_read(ndev, MALR) >> 8) & 0xFF; - ndev->dev_addr[5] = (ravb_read(ndev, MALR) >> 0) & 0xFF; + u32 mahr = ravb_read(ndev, MAHR); + u32 malr = ravb_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; } }