Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp460292lqe; Sat, 6 Apr 2024 08:11:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2gZzJcPVGONFBqKEO5fTOWg4Thh0DHm/3vjeiBxQ20dAtYWKTfBVxfSj3OeFL5eJZDGxB/1nUlKYfDnLKunW5Q1WTnLUhRaecpKdzSw== X-Google-Smtp-Source: AGHT+IFKuufS9EPtNGgWW/76FqYymFvzs8rx9hsTSozG882VsysmWKq1cWgSbwpJ33Ml5+zqec4d X-Received: by 2002:a05:6e02:1a89:b0:368:efa4:bdf8 with SMTP id k9-20020a056e021a8900b00368efa4bdf8mr5087462ilv.21.1712416261092; Sat, 06 Apr 2024 08:11:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712416261; cv=pass; d=google.com; s=arc-20160816; b=D2fIBKO/BtZCgyyaa1/lfGiKpJxPYp3B3BsXj60qqcomEW1WbCCoPwdPLPiCTY9a+H qfybacvhI24kPtsPNReDMzVc6/F4We6hjSsYlcPXWiPOVASbNYkQJ701da1YZc6/3bCE 7SSPpWX/qsUPVK9GkBTN+TmrhuK/F0uhM2F7WrtGMek5oxUDf64R4ujeJxTUQSWP+p/4 eEhCJqfk1GFYWCX7PGuPIZuF3bKgr8nlBJyRMj4yEjOl7m1e1Q2PBtlIcgRpBWAmFnIH 23lOL0mi3k8ANpVsZgBciRTaBG1zzu7FgGITRPYB7ozWx13X+i1A+w+svB6CVPQWP2VI L7Ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=UePjnvyhD6vcBLRHzos1MO1eMEL5b01X2vNO3u5J7zQ=; fh=r8DStJVKv59m+YtzwcITnUlQYYpga7VouMyxFcrY/eY=; b=fbgp9MHwaHBsZ+TaGOwnzaEi9sQrwa2f/8gKosCievBhY1s5JQxIvOoZgmRpn4oFi+ rIB9TCRmqsrphYj8WQjHykgKrHSL92jYnPq6zEiR2P56v9wfiquD0uiQUF1XTJ8EMyNQ Gp4WvJQG/5SZpLuxVOV7cmUoQ/3LbSvfnyDi+fw9y7b5yrzqGILBw1MORbby2bxnz0f3 nm+v0fnRyu+1UKL42M74JpT2YrER3pCZjh+kXnLHpVdz8p3zv/AmOlmd5r7iVj6ArFfC 3wPh6z6KEQC6OOY+rx6b/GS6pNs84KCx0V3CJd4P8vB18GneAp+X2uC9XXXI8X7cda/k sEsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TCifKKj+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 202-20020a6302d3000000b005e438e96c48si3225720pgc.164.2024.04.06.08.11.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 08:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TCifKKj+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133965-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133965-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 680B1B216AA for ; Sat, 6 Apr 2024 15:10:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB4C439FE5; Sat, 6 Apr 2024 15:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TCifKKj+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E299536AF2; Sat, 6 Apr 2024 15:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712416248; cv=none; b=ZIUz/KBBRB2DYOKCsRIKNiEGFHpJWR9bbYUXS1fbKS+jv8Eg7ahfooDvn7IJR7+jBMRrO6MH0Hw/yFwmAACk7jU/76bNRMWFYulmCnAvX/Vz7IQFnDyFJwx3qUs7YS2RS59hvVrNR3/Sh2VuHyZEQZuMB0ZODa1ClC1szh+mzgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712416248; c=relaxed/simple; bh=5emgxAYuL3Uh/wVc4IUoxs/1/ddCC16VTMbHABngszQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=trxo4XN4dHbWvwLp6ZBbYkAz+toT7So1C3tBl1O/C3UY2+KdHpuhk+EBHfSUgB3nZ0UcqxGMVijwwOmaakEFdw+UzZtoSqnl40N2xv2bXgKGtfH0Y0YJahqpdcKUWJ94Tt9JGwnXga89Uh3zuOHIEXRe+wslEAnmW/wQIee7mgM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TCifKKj+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BBE9C43390; Sat, 6 Apr 2024 15:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712416247; bh=5emgxAYuL3Uh/wVc4IUoxs/1/ddCC16VTMbHABngszQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=TCifKKj+aKJ/MmDeAFtT+mOorB2XyOAVUn3j7bmZgBiRjc+OluvfcmM2CPVYab28Y 0A6M7Y3Lc706CoI93wm6BtfNySz4nejDYPvbhBXly7vLzVpNyUwIH4WxoFgNX8uqAf T/ahL9OyoFiEeDz1CApD9ckc/RpZiZvsfI6a9LYSOvdZXD0SBPyEQMVCJQDQyDKqAc e5CECFuOdpy2SIOToJ31Mni/rFJ6RtPJMAc+6Rlkuebz0kM3ag0tyGo+riVVfJePes n23jwl3ZOZwHvskRk4PDUvtV+wc5CNmHQ/CSbVPhbO7npmeKx1ELquCCTaobvm5q5f Ly/OlQEwYm3/g== Date: Sat, 6 Apr 2024 16:10:31 +0100 From: Jonathan Cameron To: David Lechner Cc: "Ceclan, Dumitru" , dumitru.ceclan@analog.com, Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/6] iio: adc: ad7173: Add support for AD411x devices Message-ID: <20240406161031.6192f4f4@jic23-huawei> In-Reply-To: References: <20240401-ad4111-v1-0-34618a9cc502@analog.com> <20240401-ad4111-v1-6-34618a9cc502@analog.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > > > > >> + case IIO_CURRENT: > > >> + *val = ad7173_get_ref_voltage_milli(st, ch->cfg.ref_sel); > > >> + *val /= AD4111_SHUNT_RESISTOR_OHM; > > >> + *val2 = chan->scan_type.realbits - !!(ch->cfg.bipolar); > > > > > > Static analysis tools like to complain about using bool as int. > > > Probably more clear to write it as (ch->cfg.bipolar ? 1 : 0) anyway. > > > > > Maybe it does not apply here, but i followed this advice: > > > > Andy Shevchenko V1 of AD7173 (named initially ad717x) > > " > > > + return (bool)(value & mask); > > > > This is weird. You have int which you get from bool, wouldn't be better > > to use > > !!(...) as other GPIO drivers do? > > As long as the build bots don't complain, there isn't a reason to > change it. It is just a matter of personal preference at that point. > > I got a sparse warning for something like this recently [1], but maybe > that case was just because it was inside of a FIELD_PREP() using it as > bit logic instead of addition and we won't get any warnings here. > > [1]: https://lore.kernel.org/linux-iio/20240129195611.701611-3-dlechner@baylibre.com/ It was common to use !! for a number of years, but then it got a comment from Linus Torvalds making reasonable point that it isn't easy to read, so slight preference these days is for a ternary.