Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp143738ybk; Fri, 8 May 2020 16:25:52 -0700 (PDT) X-Google-Smtp-Source: APiQypLQy1BpSRUyDK2FNEl+ajIdek3GWo7WLul8yJASDsZGRULXsar2SJIIPnHj5gWWGOWYPYeM X-Received: by 2002:a05:6402:1b0e:: with SMTP id by14mr751953edb.329.1588980352248; Fri, 08 May 2020 16:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588980352; cv=none; d=google.com; s=arc-20160816; b=NlE0cX1FisgHLg4DrRgtM6Mc7pXBvAROevLp2YlLaSPNIdJtF/V36ttHefGjqLadv5 hEow7qKJ9xfPqWKdh/VkmspoP6FzrUrNlhqZgWZUcndezm6iJRcExwDetJ5LC/ov067w /4zHknyZ7okLC3kmteDQddukLgyyEirf0nrtcmmxEw4089IadrnL9O5nRAd6oAS532g4 zdxDdUO8ymAHUrcRcV8o3jBjOGsX7IyDLD/2DtoQ6aV1fMOXjtCNPazHXAPRS8mdFbsY PO/j/q7pgf/FIDVO9pRfcwVT0JPJ/B7RTr6nJjCIhXYVUwrdkFU1vJDdJi0Ws8AS2IUl 32vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=9u6IFJrJ45U1UgBw4HLw/7ZyyOXSKETRJT2y/r/1a9w=; b=Xa4PCjn2Ms477S1JfLqIn1LFLn7L7dBimMrxnlQKjfHhlNFaBaymZlB0bJ2BsaBMjC vXU8TbViBh7DtV2WwjXDmplSxJJru7SboMa3oUABZEvOZMLES1ua3adfG3A1qNADdSus Rm7CYcm6lupWPXU9ZUKtgP0MATwNu4yiLv4STiAM2q0KXs50h3QxvlY1Xay4zp0RQ2pK srizO9Wq74bxHhR1mlUGAgDib+yUggViACyZQ6lQoFymc96u+VhyD5cj86ijt+ZQ90mN bpetKLjxL0PSlBh0yt/X3JM0CLNvZSAwWZllnsg+/eC5AIsJoDfbvowG7Gbt3eWtvMHB vvtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si1826498edt.576.2020.05.08.16.25.29; Fri, 08 May 2020 16:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728299AbgEHXVu (ORCPT + 99 others); Fri, 8 May 2020 19:21:50 -0400 Received: from smtprelay0143.hostedemail.com ([216.40.44.143]:55446 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727110AbgEHXVu (ORCPT ); Fri, 8 May 2020 19:21:50 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id D341B181D3025; Fri, 8 May 2020 23:21:48 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:4321:5007:7576:7903:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12048:12297:12438:12555:12740:12760:12895:13069:13160:13229:13311:13357:13439:14096:14097:14181:14659:14721:21080:21627:21990:30012:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: coil31_fa79d30e4a30 X-Filterd-Recvd-Size: 2587 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf19.hostedemail.com (Postfix) with ESMTPA; Fri, 8 May 2020 23:21:47 +0000 (UTC) Message-ID: <1890306fc8c9306abe11186d419d84f784ee6144.camel@perches.com> Subject: Re: [PATCH] net: tg3: tidy up loop, remove need to compute off with a multiply From: Joe Perches To: Colin King , Siva Reddy Kallam , Prashant Sreedharan , Michael Chan , "David S . Miller" , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 08 May 2020 16:21:46 -0700 In-Reply-To: <20200508225301.484094-1-colin.king@canonical.com> References: <20200508225301.484094-1-colin.king@canonical.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-05-08 at 23:53 +0100, Colin King wrote: > From: Colin Ian King > > Currently the value for 'off' is computed using a multiplication and > a couple of statements later off is being incremented by len and > this value is never read. Clean up the code by removing the > multiplication and just increment off by len on each iteration. Also > use len instead of TG3_OCIR_LEN. I think this is a lot harder to read. > diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c [] > @@ -10798,16 +10798,14 @@ static int tg3_init_hw(struct tg3 *tp, bool reset_phy) > static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir) > { > int i; > + u32 off, len = TG3_OCIR_LEN; > > - for (i = 0; i < TG3_SD_NUM_RECS; i++, ocir++) { > - u32 off = i * TG3_OCIR_LEN, len = TG3_OCIR_LEN; > - > + for (i = 0, off = 0; i < TG3_SD_NUM_RECS; i++, ocir++, off += len) { > tg3_ape_scratchpad_read(tp, (u32 *) ocir, off, len); > - off += len; > > if (ocir->signature != TG3_OCIR_SIG_MAGIC || > !(ocir->version_flags & TG3_OCIR_FLAG_ACTIVE)) > - memset(ocir, 0, TG3_OCIR_LEN); > + memset(ocir, 0, len); > } > } My preference would be for { int i; u32 off = 0; for (i = 0; i < TG3_SD_NUM_RECS; i++) { tg3_ape_scratchpad_read(tp, (u32 *)ocir, off, TC3_OCIR_LEN); if (ocir->signature != TG3_OCIR_SIG_MAGIC || !(ocir->version_flags & TG3_OCIR_FLAG_ACTIVE)) memset(ocir, 0, TG3_OCIR_LEN); off += TG3_OCIR_LEN; ocir++; }