Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp996241lqh; Sun, 5 May 2024 10:58:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4VuwoJtD0SV3V5koWkJSHpBJ5v5r3mMwVBNurjj3nguMiAomJApPkcpuyAUqyWHEy8qVHwibWhND27V49+M4ZBhbodiLQUNj3gAzm6g== X-Google-Smtp-Source: AGHT+IET+1SzGQgZtAhRSi5CGhNg/enpQVpGL1Xrb42LuQyG3ATZYzNjuFmji8UphI1+tKVw9M+X X-Received: by 2002:a05:6214:4015:b0:6a0:a4db:b297 with SMTP id kd21-20020a056214401500b006a0a4dbb297mr14726359qvb.23.1714931910862; Sun, 05 May 2024 10:58:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714931910; cv=pass; d=google.com; s=arc-20160816; b=NckmehNYh++g8yex9jbVFLNJNYKoQ2DgG79hi0LJPkb3ev/ROievEAev21bn8sD15L mZlSrQAmZE85GSgnLDnoIWmsfBcdKlSjdFU3D1emQ4+O/twC0usnjl1Nk4I+feU8p8rJ ftlFopOduf5d0vEj7ZG5NzBDGhP3O0vgjgwqvV+zvM6BNLB7tEb+E0UR1Xd3bvPkBFAQ rfkpkPBZ+fHLHctZi9gbHUrE2GBnex7T5l03vc6cX5UxV+ghkMUYfZfXsQzWjWl4LY1/ 3jljo3ngsVMtcxk/Sv5iuFCNPpjKCC165/RnZ97upwIC0cmw2ZIU6QjC65bw8BUJkvic i0Bg== 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=hAnzmjN6UVVrCAOQ8I0oicN2qCXecbXJL7DgAdfpOwk=; fh=2ysLBdGZADXcu+SFVX0yy0UQ0ef9U8TAtfUKT/xlWDY=; b=u/c+FB3s/6GfcfyBKz4lbUd9DVIkEZNkPXMInpHf6HR2KSBwbL6J+1O1hQlz2UW5AZ ecXboSVglDqUUWD/KVPk4oQ3IzoyhkX/6dUokp6prqV6AT3Cw2y0Whh9CfrCcXKyNC7X t9LGuA2pGeTDyifKV1GjPm0MCta70DZoY2210SpYXCLs7g5Rp0D8BDF7TtthhgyH6TxB Zmy+aVmnylt4poiBmnr92j7gNkeyQ1+AQUcWz/XmVEbFyBd/zwYhNTCyQxmN3p9iVQPn noddZcGdhCKqEgmniI1YYR0rCxERdRO3HZa0BmR6S+tfZ0Q5+Je878OYylBV6wQYofDU 9CLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ItLeR4cH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169087-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169087-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gs4-20020a056214226400b006a0d4c2371esi7613493qvb.222.2024.05.05.10.58.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 10:58:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169087-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ItLeR4cH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169087-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169087-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 961FA1C20CAD for ; Sun, 5 May 2024 17:58:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 763FD6A355; Sun, 5 May 2024 17:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ItLeR4cH" 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 9119879D2; Sun, 5 May 2024 17:58:21 +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=1714931901; cv=none; b=mvqQWlfFff0+K1tT4SSO6Q8UHoDmkLKaznBGltY0PYcZQ7jsfsMJ/rDn0ev4ofZyXKVFYDjvU4aRSZIli+iHwIONbMwFsNEgB39oz1cMjyMAW57UIoW+GDBsV8bRn9N8t/RMXihumRpogm+BIt6qHyCuOYI2ACUdav5nIKbvuvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714931901; c=relaxed/simple; bh=3GEudGU7ASMXSyyGWnReK03kwpORCk7RJpxQt9efhqY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rDiIdUkTwGtkpyC6NBUJxf6h94CtYGHGo/qvv6oS1gxtiZxZHcibJ9eGF8MX20EgzUNM1bkZj4qhJJNz11TgZnjf3lA4cBxhHpIwp2a7LpJpxlumNtrpk/QKLziOm+8GZtdmw3qSPBw9dfYUAsB/kZnz6mvup0rjbA4o8vzFQFw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ItLeR4cH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0984C113CC; Sun, 5 May 2024 17:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714931901; bh=3GEudGU7ASMXSyyGWnReK03kwpORCk7RJpxQt9efhqY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ItLeR4cHWW45OS5rq+aGVndOX8kBINwEtq378D2RjWQiosFtPGJt8kSc7E2r5G4NZ Rx2Et9IL8XfJlCIC080wi9oq3bR14KyLpG5dsy149Y7VRR+HcjOwvH2xRbXgxSejRy 2+OdkDptJ7Jwl7b/h0q7L5Oo8ZJR+aNFtdWuIe9cL3L6Hs+S/w0AsF4Br5crppyKqg AZwJkc0eaCmtH/egcnmrO3ARkP/bcg1JlaCSEwRJXnPXCq3gcUsDXpdv1Wqh8vzCt4 KAGZ/K4JkMTy/Y7LstcKHvi9H/CM4h7QwEJspeBgDlpIrNbV6d+h9NbxUn6xtQHeXw w5tivJtdI4oSA== Date: Sun, 5 May 2024 18:58:09 +0100 From: Jonathan Cameron To: Petar Stoykov Cc: Jonathan Cameron , linux-iio@vger.kernel.org, Lars-Peter Clausen , Rob Herring , Andy Shevchenko , Angel Iglesias , Krzysztof Kozlowski , Conor Dooley , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH 2/3] iio: pressure: Add driver for Sensirion SDP500 Message-ID: <20240505185809.7636403e@jic23-huawei> In-Reply-To: References: <20240116170337.00003a02@Huawei.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 > > > +} > > > + > > > +static const struct iio_chan_spec sdp500_channels[] = { > > > + { > > > + .type = IIO_PRESSURE, > > > + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), > > > > Looks like a simple linear scale. Would be better to make scaling > > a userspace / consumer problem and provide IIO_CHAN_INFO_RAW > > and IIO_CHAN_INFO_SCALE. > > I prefer returning the pressure directly because there is no other calculation > that the user of this driver can do. If they make the calculation differently > then their pressure value would be wrong. Ah. I missed this and just made the same comment on v2. Let me give some more info than in the original review. The documentation on how to apply scale is simple and this scaling is pretty hard to get wrong. There are a couple of reasons we prefer to make it a userspace problem to do linear scaling and keep the actual channel value raw (if possible). 1) Logging applications typically store the scale once, and each data point is then much cheaper to store as a u16 than as a floating point number. 2) If you ever add buffered support, we do not support floating point values in the buffer. That basically means we have to have both _PROCESSED and _RAW provided so that _SCALE makes sense for the buffer. Horribly messy ABI is the result. Hence, push the scaling to userspace. Note that we can't always do this as some conversion functions are non linear and very hard to describe. In those cases _PROCESSED makes sense. That's not true here. Jonathan