Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp12207rdg; Tue, 10 Oct 2023 02:46:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoC7oT+higmOwGwwLuOcCTE0++fsPldIVEfQO9G9W16+Gf1HzjKOjHPv/8HEgl0hdwdi/u X-Received: by 2002:a05:6871:297:b0:1d6:481f:5717 with SMTP id i23-20020a056871029700b001d6481f5717mr20658259oae.42.1696931162390; Tue, 10 Oct 2023 02:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696931162; cv=none; d=google.com; s=arc-20160816; b=tpDyauDi1u7qEADR8I3G9vzjjDfgbVX+Vgbx2wW0Ye67nZUU3mkD0oEMNick4SECYW Ab8MFLZ1+1DXTOJEH1kzI2IN249AssSdYeswGNccUzyOz638izfkB9QF1rqs5K6/ZI4C ZQju1e7dS/Uso5RJPNBTPUR1caEgV05l6wfroAfFW+tDlOn9Tb3NUBqevuXahfWRnS3G mNlykcEcl6MjHS9MATZ4iZXeIe6Xj34fXfthLosTYJEkuSfjFvRQ0lq6Nb4s109Pb0ne qgQIHk2vzB7ZZAUpaZ/vIgOaBVbEhMBbaZpcbbctdP9kObdbBbvNbrgvhRdPSgOuQTy+ OCRw== 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=oLCLGlzhdCkSJCpYvREIcGNgNS3NFYBXJWBifrVrMeY=; fh=bm7LTCfNjhVXYCJQYzwNgoWJ61x9nQGAEDwqdMm2+Xs=; b=DHlOoURTGWZHEgmKhLLhxgdfSCD1Bdm9pqC30qG2725hCPg4bBPMLBCOptUL0GcT75 SnpSaZ3va3RzMLglsvg6Wl04ezbtVWQJYHlXMRWzTxZLfr2oNjfoRcDj7jMv2RMUmQrj pMY2X2jKdgbc1lMbW4BN+gUep6gRZws7kuuctXg+/M+LGEDNx51hz7b58NAjlN2yR0Rm /E4xEpYGWyF56Izrre1E1ObALqCjiEnul3Lodeh1BL4WQLN4R6u/aWcMyfOjXhO9IvCe ed89CrFbPJ9i3T91vv2zCt2MG/RfW9pw2K/ZTgttZE8MxctzkhXk0lpPZjqkzW/c2Kea uWMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tieprnbQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id g7-20020a056a0023c700b0068e2f6feab4si9685559pfc.374.2023.10.10.02.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 02:46:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tieprnbQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id D9B0180557D5; Tue, 10 Oct 2023 02:45:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230512AbjJJJpA (ORCPT + 99 others); Tue, 10 Oct 2023 05:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231218AbjJJJor (ORCPT ); Tue, 10 Oct 2023 05:44:47 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61D65FB; Tue, 10 Oct 2023 02:44:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9031EC433C7; Tue, 10 Oct 2023 09:44:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696931073; bh=7YEHaqsLTuRNgAsuwQ/rOKY1wHlB6nQFsPl4GdRnH0Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tieprnbQcR/MA380yekPeBfVtwJBUs424sGj2ujDysOPpJtzqQDlXntLWViz881BP eoOlfMh61dkXBsH2VxxYEkkY/xrXfM1xwCDoqu1dhT4jN4XwA/xvDP8YXlBojEJLqm yvQbhd0/fr0SBOgr/5LiZHa0mBgfSSY3EJqwWSeIxH7UL0Db402/c3OZ4PbYVYVGfe 5P3aSlYuN9/RRtaQMys7x2M/RyIym5xemK5Fa4kXF9byINBPGb7UPFU+tetxivzjfQ IgdwAlHibR7/7ZIuEVBoR2QvauL5laVKDDO5GhyOM9dwqaJA6sEsnBnwlSUOzClw5A lBlz0gm4np6Cg== Date: Tue, 10 Oct 2023 10:44:44 +0100 From: Jonathan Cameron To: Cc: , , , , Subject: Re: [PATCH v1] iio: adc: MCP3564: fix warn: unsigned '__x' is never less than zero. Message-ID: <20231010104444.12e61984@jic23-huawei> In-Reply-To: <20231002161618.36373-1-marius.cristea@microchip.com> References: <20231002161618.36373-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=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 02:45:10 -0700 (PDT) X-Spam-Level: ** On Mon, 2 Oct 2023 19:16:18 +0300 wrote: > From: Marius Cristea > > The patch efea15e3c65d: "iio: adc: MCP3564: fix the static checker warning" > 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: efea15e3c65d (iio: adc: MCP3564: fix the static checker warning) This fix is fine but can you talk me through how the static checker warning fix in question has anything to do with this one? Was it just a case of fixing that issue allowing the static checker to get further before giving up? In which case the description needs modifying. Or am I missing something in the following fix? diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c index 64145f4ae55c..9ede1a5d5d7b 100644 --- a/drivers/iio/adc/mcp3564.c +++ b/drivers/iio/adc/mcp3564.c @@ -1422,11 +1422,8 @@ static int mcp3564_probe(struct spi_device *spi) struct mcp3564_state *adc; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); - if (!indio_dev) { - dev_err_probe(&indio_dev->dev, PTR_ERR(indio_dev), - "Can't allocate iio device\n"); + if (!indio_dev) return -ENOMEM; - } as that's all I'm seeing in that commit. > Signed-off-by: Marius Cristea > --- > 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