Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp132749ybk; Fri, 8 May 2020 16:06:55 -0700 (PDT) X-Google-Smtp-Source: APiQypL8AssV2beqC3WNvTGNDJuEPbhlJa/7EWQvB9deXImA81bz7ikcBto3k5mVGzHBQEOVcp3S X-Received: by 2002:aa7:d7d8:: with SMTP id e24mr4428990eds.215.1588979214936; Fri, 08 May 2020 16:06:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588979214; cv=none; d=google.com; s=arc-20160816; b=q1SWHbbttR5xWxbVCjCqQnRXPImCAVP/15gCWtFWEK9glD/6P8OJz1VL6O0elfneEk ekXVbylMlLE9smDhPxzAhij/zT4BiEtMHJuKrh3RyHWIPHykWSsX8i51BOWFVEtp8zQm e8UrhCRroZBuJQa2KdbG2I2tvHZFemMomz2JxvEi0bOenK11JuahPftR1JvD5u4e2+y3 zxELVxl7iC1dUf5RNgSIHCEd6d3wn17aR9rEmvWKWyWqLGJpGR15TulzApyv5Vc4ZR9t B/K4eRsberjNENFi63f1gJv5segbGbspHFGRsb6BluCivzZjGTr7CwMiZ0judQcTKF2c +1FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PiUVa5mVO89jeXQmai25H32mWUhzjICjk7pOMJIJk4M=; b=ZMVQG40wfrCPXFPxhWDT8dym1THF42aU8Kaf6ieeurp7d6l5vm6PiIL4QJuX4aOxnM aewOFYtcQpzHr+m2iaiEJqQJWAkY1FkxX6Cnvh6pPelH1xI5LcGoHIxDfawfet1YDfep 6kI+gfxbnfx61eBkcl7ryKVUGrX9k1sexXjDCSGwdhu69nNKWBZkVoMGAN1AQk21/zsR 3lJFNlFyu6f3Sdy2fD0vmMFQb2EezxAlWXMWlnA51r79jQrOgK90Mrjd5PXS+08zFMEo MnHPJcM1gURK1zKRzGDsR993FsCPUN5kxIKdZ0Rh01vpgnxg2nCVuNalUXf5eNct41JU Ysug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=aeIWvzPX; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u26si1844586edb.4.2020.05.08.16.06.30; Fri, 08 May 2020 16:06:54 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=aeIWvzPX; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728303AbgEHXFE (ORCPT + 99 others); Fri, 8 May 2020 19:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbgEHXFD (ORCPT ); Fri, 8 May 2020 19:05:03 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E141C05BD09 for ; Fri, 8 May 2020 16:05:03 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id q7so3577585qkf.3 for ; Fri, 08 May 2020 16:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PiUVa5mVO89jeXQmai25H32mWUhzjICjk7pOMJIJk4M=; b=aeIWvzPXDXfpoIWJD4RSKGQirPc8lgF0hCA7z+WnsTXlqRhUtPwt4ABFjTPGSQ4MmW co9aA/P0GUUUWqi2b2tLG/UGKjI5T4MsFL7wOEefM5SJJFRdXctIb9yoofcvfMBAhpvX J/QuNRxp4qHlOOtTwNwjrBQweLSXxjbnyo68o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PiUVa5mVO89jeXQmai25H32mWUhzjICjk7pOMJIJk4M=; b=NGPf986hnNGEv+ZcbIO5QlrEGRbqqu8hMr1nftftpHt58hJhfpH9HzFqWw9oVwcbjw J1rr9g+U2rUqHUxYE+s4DwI7/vkAasLjEa7tDniW/DRJMK59m251TKDD/YmcunVf1lFr rmS+pd4ndA5NSkx3WT4K0lLHP6J9Q5aGeuOHQoFOwn6Q3v+GncgkP+0uP7rHCkJr7TWm 7QKbr+bPjNPVzRCkhupVBxq8p+BxUAc+WL7NARNSX8NWdC7w/vkqJMVhm4F0iBPzj/4+ SHWYLVyPp1DnfrtfVI6uYp7JU3BKcLigfO+d8UkMaoWB4v5G55qcZx3Xb60Icw+EKOxP ao4A== X-Gm-Message-State: AGi0Puaat2xYvKTG0MwdOYS4meVbHkpQkHvp2PL86VAwYQCzZpe8DeH6 U+B1UW0q2CSAosvU40SHMh10hcJUK0DrD1TdufIwmQ== X-Received: by 2002:a05:620a:4f0:: with SMTP id b16mr5114221qkh.165.1588979101996; Fri, 08 May 2020 16:05:01 -0700 (PDT) MIME-Version: 1.0 References: <20200508225301.484094-1-colin.king@canonical.com> In-Reply-To: <20200508225301.484094-1-colin.king@canonical.com> From: Michael Chan Date: Fri, 8 May 2020 16:04:50 -0700 Message-ID: Subject: Re: [PATCH] net: tg3: tidy up loop, remove need to compute off with a multiply To: Colin King Cc: Siva Reddy Kallam , Prashant Sreedharan , Michael Chan , "David S . Miller" , Netdev , kernel-janitors@vger.kernel.org, open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 8, 2020 at 3:53 PM 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. > > Addresses-Coverity: ("Unused value") > Signed-off-by: Colin Ian King > --- > drivers/net/ethernet/broadcom/tg3.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c > index ff98a82b7bc4..9dd9bd506bcc 100644 > --- 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; Please use reverse X-mas tree style variable declarations. Other than that, it looks good. Thanks. > > - 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); > } > } > > -- > 2.25.1 >