Received: by 2002:ab2:6486:0:b0:1ef:eae8:a797 with SMTP id de6csp353981lqb; Sat, 16 Mar 2024 07:00:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1eMcSvcEQ4v0+8m2KQ7IqeWvlgicmRVHH6LQSH1iCKahSh0i50gPUfPho8f7u3Z7Ph6oQ7OH5xFjoVC9JVN7s6dsVvFSZnyb9hTlYLg== X-Google-Smtp-Source: AGHT+IFs761j12EJgej5C+mgFLwuaghprRWIIrUwrn98GW5P2w78aoZ7R/NJuOuSPZ6ny9D/Qwwr X-Received: by 2002:a50:ccc3:0:b0:568:21cb:af7a with SMTP id b3-20020a50ccc3000000b0056821cbaf7amr10199007edj.9.1710597652927; Sat, 16 Mar 2024 07:00:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710597652; cv=pass; d=google.com; s=arc-20160816; b=GbCXoI6TZusbufVU9ASADYBjwcKkzUd+qWQVgpXOJe3j3YUDRnYQxyHaEiJOxtBvTP 51s2V5pUX9tS7eLNGGiCqFFcu9w7lxitcsl46M2c9LHMHPFMsMJaB6Ul0gGcKpbjIFH4 UeYOpycndYWB4KlWEEvyHwapHvgBI2d/3DRpfDlOO3GG2uZ82cEaI0XJVGHEaAg2mUQc frFM+VW4IvhYQ3fFe/E3VH1CvJqkocfUBcPvh7y89/jOd0+JxPuh9yr5WxTtimgSE9el de+i8Kexu/5Qkl2g/ouoPLUMw7UclXEwJ9TeuYg9kHcIQIVbyw3CnnDXLmDOVBiF0ePn zavA== 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=oI9pvLObG4/ALvfcqkrRalsrv+5U8ASdyFcVzhD0FL8=; fh=WzoiHNM/JwOTfwJ2Gx1jFCf/LqdrwHLvcSkQyEZ7HnU=; b=qGQW3rFOj4i85Vodv1A9tiENeZqfIlvH/7715Zphlc8Zj8cGy2IEe1a3f9wnBS67gx FTaj+cehhwRXwRnFcH+AgrApSvf7sFZBI3Ao9rhKwuVi1s4ZeWRzjYTmkZm9VPCrKbpv bnemZsXw2fDPaUI1ajuM9tjdXkBF1N+IdkG2UfzvVziHNS4XH27z+jjNWMIewK1cnWcK OuJlzwIhyMSNLEH6a2MCd2iKEFQ+fLR1x35WyaCBiE3FNyOBq9hqEo/xFWkpInyXVaCo OwQ8Iuc+KswsKmo/nGcuqFS3HTkx4yDUzUuy88VX0OYsa5gDQKXuKGn/6nr+OlY1P3Uc 4awA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CwxaQ75s; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-105192-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105192-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cn21-20020a0564020cb500b00565bb5a945dsi2649889edb.171.2024.03.16.07.00.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Mar 2024 07:00:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105192-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CwxaQ75s; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-105192-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105192-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1291F1F218DB for ; Sat, 16 Mar 2024 14:00:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A030318EAD; Sat, 16 Mar 2024 14:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CwxaQ75s" 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 B6B8F18AED; Sat, 16 Mar 2024 14:00:42 +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=1710597642; cv=none; b=LzXjh0AHnfzJ0PgpAypu5vSOWmZ6c7NUjQJS34FUf36Vnf0U3nR1AW1DdbZe5y23EbSFxQ46kCAiNUSU9LpD1UklQsSr865bHGYqcX+dfv0NBO3cRdDaymHLy4NEUBwE9reYn/VdogzkNwAySx3kZlGpbIq3AJs5OXNzOI0GDZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710597642; c=relaxed/simple; bh=OsANXNq+J2cqDLKb0p8kEa9kLFEZDomwY/SqKXI9w5k=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UugaHSBbHjxn4w6KKarS9Z5rjDAtajVBXxMUn6IIYcYQufiYvjIHTsFtT29QfMLzyVXIbVXSP5xsWPprSUd1NSNyVtvxm8XIMf7+T3bQNoCyc6wO4tMfMNY9JStWaUDOBzF5dEtJ2onViqblwZfj6JDbyHGZI2E9C2UP5xQ4pBE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CwxaQ75s; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2323C433F1; Sat, 16 Mar 2024 14:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710597642; bh=OsANXNq+J2cqDLKb0p8kEa9kLFEZDomwY/SqKXI9w5k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=CwxaQ75sL/MY2rDZYUgNRX8An/nNeL45UcRhFGqDo2TPjK4TfTs6E0HqaTDyEpXFg 4j5JyiOKfnuQDjm1YFEC5CnY4W73JX27Nrvpw4mpsm/Ug2dAgvi5EnGlxcGyqJWwlY /8LM7egri4URcmDyAz9aeI/BaVxMdEKH78ghp+v2xsaD+sQuQwRrvW1LwQdG1pwTfZ zsXRtGzztVSO0MHXQSJNDzQFvtrz8D0edy92hRg8QPbz6T07ofdMOIyoJNVcK8PWy9 HhaJfIho7xRuORWiU4HUrQ8JvRjla+x9jPHaQUB572CjwS4QV1COLmU0FA13p8jPPY UNk2QTxlyGneg== Date: Sat, 16 Mar 2024 14:00:26 +0000 From: Jonathan Cameron To: Angel Iglesias Cc: Vasileios Amoiridis , lars@metafoo.de, andriy.shevchenko@linux.intel.com, mazziesaccount@gmail.com, ak@it-klinger.de, petre.rodan@subdimension.ro, linus.walleij@linaro.org, phil@raspberrypi.com, 579lpy@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/6] iio: pressure: Simplify and make more clear temperature readings Message-ID: <20240316140026.4daa2480@jic23-huawei> In-Reply-To: <63d6a4b0cb2155d5c194b3b65fa60c985a6338ca.camel@gmail.com> References: <20240313174007.1934983-1-vassilisamir@gmail.com> <20240313174007.1934983-5-vassilisamir@gmail.com> <20240314150959.585367b5@jic23-huawei> <20240314201718.GD1964894@vamoiridPC> <46389801aeb20f18affed86d979aff7a62cf36d5.camel@gmail.com> <63d6a4b0cb2155d5c194b3b65fa60c985a6338ca.camel@gmail.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=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 15 Mar 2024 14:28:30 +0100 Angel Iglesias wrote: > On Fri, 2024-03-15 at 10:05 +0100, Vasileios Amoiridis wrote: > > On Fri, Mar 15, 2024 at 12:22:50AM +0100, Angel Iglesias wrote: =20 > > > On Thu, 2024-03-14 at 21:17 +0100, Vasileios Amoiridis wrote: =20 > > > > On Thu, Mar 14, 2024 at 03:09:59PM +0000, Jonathan Cameron wrote: = =20 > > > > > On Wed, 13 Mar 2024 18:40:05 +0100 > > > > > Vasileios Amoiridis wrote: > > > > > =20 > > > > > > The read_press/read_humid functions need the updated t_fine val= ue > > > > > > in order to calculate the current pressure/humidity. Temperature > > > > > > reads should be removed from the read_press/read_humid functions > > > > > > and should be placed in the oneshot captures before the pressure > > > > > > and humidity reads. This makes the code more intuitive. > > > > > >=20 > > > > > > Signed-off-by: Vasileios Amoiridis =20 > > > > >=20 > > > > > To me this makes the use of these calls less obvious than they we= re > > > > > previously.=C2=A0 The calls are made close to where t_fine is use= d and > > > > > don't have to go via the indirection of chip_info. > > > > >=20 > > > > > So I disagree. I think this change makes the code a lot less > > > > > clear. > > > > > =20 > > > >=20 > > > > This was mainly driven by the fact that I wanted to avoid reading > > > > the temperature 3 times in case temp, press and humid are enabled > > > > and there are consecutive buffer readings. But thank you for the > > > > proposal I really appreciate it! > > > > =20 > > >=20 > > > Hi, just a side note reflecting on this. Depending on your sampling > > > frequency > > > and registers data shadowing, to avoid compensating with different sa= mples > > > between readings, we should be doing burst readings to get a bundle o= f the > > > temperature+pressure and/or humidity. > > > On the bmp/bme280 and bmp380 this can be done as registers are contig= uous on > > > the > > > memory. On the bmp580 this is not a problem as the values are already > > > compensated, you`ll get always the latest reading. > > >=20 > > > Kind regard, > > > Angel =20 > >=20 > > Hi Angel, > >=20 > > Thank you for pointing this out! Indeed that's true but I noticed that = this is > > not > > the case for the BMP{085/180} devices. I just feel that some changes mi= ght > > make > > data acquisition/processing faster for a device (like the one you propo= sed) > > but > > it might make the code much more unreadable and unmaintanable. I will t= ry and > > see if something could be done in that sense but I feel that keeping it= simple > > will > > be good for everyone! > >=20 > > Cheers, > > Vasilis =20 >=20 > Yeah, data adquisition on bmp085/180 is already different as they don't s= upport > continuous mode as the newer models and you have to warm-up the sensor an= d do > one-shot readings. There's already a different code path in place for that > models. I guess that is the price to pay to support that wide range of > sensors... > Anyway, this patches are already big and you're doing quite a lot of heav= y- > lifting right now, so don't pay much attention to my ramblings! Regardles= s, > happy to help with tasks polishing and updating this driver :) If burst readings do make sense: We can reasonably assume anyone who is usi= ng this sensor and is using buffered mode probably wants to 'mostly' grab all = the channels, then a specific function that always grabs them all, plus use of available_scan_masks =3D { ALL BITS, 0 }; will let the IIO core deal with a= ny cases where only some channels are requested. This is something we do in drivers where there is some interaction between the channels (like he= re) or where burst reads are much more efficient than single channels (possibly also true here) and complexity is significant for switching between burst and single channels reads. That covers a lot of devices and is part of why we have the core code do channel de-multiplexing rather than leaving it for the drivers. The other reason that drove that complexity was unrelated to this driver (SoC ADCs wi= th some channels used for touchscreens, and others for unrelated purposes). You may just want to reduce how much code you are reusing from the oneshot single channel sysfs reads so that you can just do a single set of readings and use them as needed for compensation etc. Jonathan =20 >=20 > Kind regards, > Angel >=20