Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1619673rdg; Sat, 14 Oct 2023 09:17:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTxuVGrSu9alBDmDRx6AcBGEB08lG08C0RCCVRSArSgKKCjYCf5VPlTRO4sY642WIyx4vX X-Received: by 2002:a05:6a00:b4b:b0:6b5:ec98:4289 with SMTP id p11-20020a056a000b4b00b006b5ec984289mr4090895pfo.14.1697300278475; Sat, 14 Oct 2023 09:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697300278; cv=none; d=google.com; s=arc-20160816; b=irv4wmieQ87bjD37GBWL0nbR6G98wwJJDBhNIxQaNlWNO+X4glw6sBiwUP9UywUkPB JmvSi/vljptKtBK6mrenZodod/9NGakn/+hWc8wlxUGRRjn3MD1h6nWZ+xRQjgayEYRH zqLC4gWL1cdf+Mcejai4ku9uWkKbbYmFtUDRECR3AhEOQA1dAeTb+pqVXy58eNjl4WvB M0XoZ6CYj2D7CwT23BtAZ/WDlKlArxj7LYcvoo0tzy9jE6HUkQmtsa8+nyEXuLv5aB62 I/fTDF2JkhbTGtE87+HZroU2ciul7v7pRRleXpdBRBxoC3doXWkPb9E+H8w+3NPvxK9Q 52dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=v6+4muI7hBTrn9IMpPC5C1oKuwDvh5aWNmSc6RosruI=; fh=bm7LTCfNjhVXYCJQYzwNgoWJ61x9nQGAEDwqdMm2+Xs=; b=UzUrB/FyZ3Mx1sJjeAClbur8aZaKXlUlFKIdND7CQqANN9bqI0O2oBcfaM3PIBV2Gy Bk66e12C1aPz+T9ISmyK4zg70BXomqYrIuaKGjumWn64fRjAAkMk5BemK1v1wefYPiRB ewDIDTGftjcSMEU5s0mVtZKmBCA9bvbSitHcvFC46ovM8WNjLrBpoDOtPe/ssgPHKr1Y 7F34RJWMm8mDOPNQ2r40IRZMmE5xIGmoyjH+bWill9Mkx6FDuYhzrnPzVMkofViYXoIV OWafbE/mJCEy+RLtXnRm/+U6yx2BhMvVwcBDAV1OaU1uqrnvzzQ9mgtfLH2GSrWCIJwK 6llA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=At2Q3ivB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b00584b6af3b9fsi2416461pgd.524.2023.10.14.09.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 09:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=At2Q3ivB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A4C1680401D7; Sat, 14 Oct 2023 09:17:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233208AbjJNQRj (ORCPT + 99 others); Sat, 14 Oct 2023 12:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230211AbjJNQRi (ORCPT ); Sat, 14 Oct 2023 12:17:38 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54733A2; Sat, 14 Oct 2023 09:17:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF41CC433C7; Sat, 14 Oct 2023 16:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697300257; bh=xHY0aHf0uD11zRpqxPLjkEWTV0MfIpfqhqDSbGx/3+Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=At2Q3ivBEO+OXY8uC47sAGzBJemm3FZ4BfSamI6PiCXBAQElgcbtZ3hBnhPSDf3GP cdMt3u+vLbROMtypOnZW1rG8B9MQfI3P6phPTRiIvyCP/hSF485e91/vJzyaODEz2j PsjKMD5zNqFbhHhWtc1KNxRSH21OvL+Ql4rNPMqKBuPEqhIQid/TOjpY7J20/OIXKD LZV94XdL9C4Gz7HAGTdecNnSZQTLSjxWhTq/wEThigCQtM4uPeZrGbo4ibeIvyyCHd JJe6DAflemxalqZNdKtgHcGR9sS/n7nEtEXxSjk9ZVzRTVzALSAtUTHP11aqjNh5CH dhaPORddHjLFA== Date: Sat, 14 Oct 2023 17:17:52 +0100 From: Jonathan Cameron To: Cc: , , , , Subject: Re: [PATCH v2] iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero. Message-ID: <20231014171752.5c4d7a86@jic23-huawei> In-Reply-To: <20231013132333.10582-1-marius.cristea@microchip.com> References: <20231013132333.10582-1-marius.cristea@microchip.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sat, 14 Oct 2023 09:17:56 -0700 (PDT) On Fri, 13 Oct 2023 16:23:33 +0300 wrote: > From: Marius Cristea > > The patch 33ec3e5fc1ea: "iio: adc: adding support for MCP3564 ADC" > leads to the following Smatch static checker warning: > > smatch warnings: > drivers/iio/adc/mcp3564.c:1105 mcp3564_fill_scale_tbls() warn: unsigned '__x' is never less than zero. > > vim +/__x +1105 drivers/iio/adc/mcp3564.c > > 1094 > 1095 static void mcp3564_fill_scale_tbls(struct mcp3564_state *adc) > 1096 { > ..... > 1103 for (i = 0; i < MCP3564_MAX_PGA; i++) { > 1104 ref = adc->vref_mv; > > 1105 tmp1 = shift_right((u64)ref * NANO, pow); > 1106 div_u64_rem(tmp1, NANO, &tmp0); > 1107 > ..... > 1113 } > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202309280738.NWjVfVt4-lkp@intel.com/ > Fixes: 33ec3e5fc1ea (iio: adc: adding support for MCP3564 ADC) > Signed-off-by: Marius Cristea Applied to the togreg branch of iio.git and pushed out as testing briefly for 0-day to take a look. Thanks, Jonathan > --- > drivers/iio/adc/mcp3564.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c > index 9ede1a5d5d7b..e3f1de5fcc5a 100644 > --- a/drivers/iio/adc/mcp3564.c > +++ b/drivers/iio/adc/mcp3564.c > @@ -1102,7 +1102,7 @@ static void mcp3564_fill_scale_tbls(struct mcp3564_state *adc) > > for (i = 0; i < MCP3564_MAX_PGA; i++) { > ref = adc->vref_mv; > - tmp1 = shift_right((u64)ref * NANO, pow); > + tmp1 = ((u64)ref * NANO) >> pow; > div_u64_rem(tmp1, NANO, &tmp0); > > tmp1 = tmp1 * mcp3564_hwgain_frac[(2 * i) + 1]; > > base-commit: 5e99f692d4e32e3250ab18d511894ca797407aec