Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp251370pxb; Mon, 25 Oct 2021 07:38:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2bZiMd1w7tC93qJMuYBiI3RtJn9KihtOBlH46lvHBS6v1+sOcC37Jsubhl8IUExf3HoUq X-Received: by 2002:a63:7f1c:: with SMTP id a28mr8764810pgd.364.1635172718415; Mon, 25 Oct 2021 07:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635172718; cv=none; d=google.com; s=arc-20160816; b=urSxM6caipwwH5cuTpf+6Lg6GzUcFGRCRXMT6A+0r/BtFCbzTRLKqIgYzrZ2d6jCHh 10dEqmZU0AcW2Ra54Yh883DrZtwSJGtvrEBbDqE0843dV6RtjlQSadD7D3Nu9KDe2vcN GZxoib00pUiUntl4FRXOAzSdnw63F/jon3hVX4t4MCY56tpYV0SjQT5adAFbHAAQy2f4 BC3St4jk+RZ0PKLkb1gtMA/dyO6lmNAlaWLUMKgO//v7v2RlB6NBbhMou4U3E+lY9Dao h8QrSc5Mxo09230aCBC6rxqqHflAyWQP2U122UzZcVT3u524CwIvsf7eRABp7fbJT+Hy P/NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=o/jFTeLEC5TlHldGcUWgNUgMvYvev6OCExAwTepYg90=; b=wQEBE2bLwdpkr/NjQC0OxM6Y9KmUwH31VMgUhIOHqlQgeNjKMxH+3Y1Q77t1kf2pJs VBHK5+aZXEtpZONyyxwmakE/NOXJgcURwbrLlo/Oq6cuSrdVNAmL/pURTI5lWExOKXr4 R5bAJOFAAP3rmjDAQKVykXCBAaVAyREy8Oj+CizSSXS6ySqPakZsFu4oPBaRf3JaaW4g 4txpvN9HuR3BElVEJq/+quiOOsnGFACxhtD9X6cDYTDDpQwtZgnRmwiqrnPhsoO0O2LW XI3uP2B3hcZ7bm0/J0iXzepQQsaFKOcS2Upaq+uC5IW2OlCp4thecfpFeh2TuJMSH0qU J/qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iSUqk+0Y; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si40249pgm.466.2021.10.25.07.38.25; Mon, 25 Oct 2021 07:38:38 -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=@kernel.org header.s=k20201202 header.b=iSUqk+0Y; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231335AbhJYOgz (ORCPT + 99 others); Mon, 25 Oct 2021 10:36:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbhJYOgz (ORCPT ); Mon, 25 Oct 2021 10:36:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6595A60720; Mon, 25 Oct 2021 14:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635172472; bh=BWCI0zBBdH4Ik+znRZ7aJYJUjSobDgePF66QuPV4y90=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iSUqk+0YiY3c1g212989NV4QAIxMDM+tPLHJPt+SLcyBHL+o6+9sVm4v7zSac7xjJ J/+MlDFwIW8osmbHYphW6pgggplcV05cpzLouG2KgS6CPPFySbkemjoLoac8TtQZag l4EMJ6YhRG4bxnzT3SrX9YbH86hyWd/DJbDBFGhOWjx4dSuDVFIfh6Wk+2snKT+FyI d22Fn8YtiUzeseiWU/0bGSl5LuSTMNESCAmnFXkTYRsqELKHpZza1OLB6rJ/eglTbj 7Gul2+Hx3gTna8TZL7CNIAqltTzJi40sMvjEaR4fdeSkjOoD0GAoOVBus1/OmVng3q AjqzLtYFQOo9A== Date: Mon, 25 Oct 2021 07:34:28 -0700 From: Nathan Chancellor To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Thierry Reding , Jonathan Hunter , Nick Desaulniers , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] soc/tegra: fuse: Fix bitwise vs. logical OR warning Message-ID: References: <20211021214500.2388146-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michał, On Thu, Oct 21, 2021 at 11:55:34PM +0200, Michał Mirosław wrote: > On Thu, Oct 21, 2021 at 02:45:00PM -0700, Nathan Chancellor wrote: > [...] > > --- a/drivers/soc/tegra/fuse/speedo-tegra20.c > > +++ b/drivers/soc/tegra/fuse/speedo-tegra20.c > > @@ -69,7 +69,7 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info) > > > > val = 0; > > for (i = CPU_SPEEDO_MSBIT; i >= CPU_SPEEDO_LSBIT; i--) { > > - reg = tegra_fuse_read_spare(i) | > > + reg = tegra_fuse_read_spare(i) || > > tegra_fuse_read_spare(i + CPU_SPEEDO_REDUND_OFFS); > > val = (val << 1) | (reg & 0x1); > > } > > @@ -84,7 +84,7 @@ void __init tegra20_init_speedo_data(struct tegra_sku_info *sku_info) > > > > val = 0; > > for (i = SOC_SPEEDO_MSBIT; i >= SOC_SPEEDO_LSBIT; i--) { > > - reg = tegra_fuse_read_spare(i) | > > + reg = tegra_fuse_read_spare(i) || > > tegra_fuse_read_spare(i + SOC_SPEEDO_REDUND_OFFS); > > val = (val << 1) | (reg & 0x1); > > } > > It does seem correct, but nevertheless the code looks suspicious. reg is > already masked with 0x1 as far as I can tell, and there are other places > which depend on this (like speedo-tegra210.c). Guessing from the use of > tegra_fuse_read_spare() I would recommend changing its return type as it > is returing a bit value, not necessarily semantically a boolean. Yes, I did notice that, as well as the use of tegra_fuse_read_spare() with boolean operators in tegra-apbmisc.c. I could change it to int if that is what the maintainers prefer, which would also solve the warning. Cheers, Nathan