Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1364203lqh; Mon, 6 May 2024 05:50:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdq5/mx+5kADFbZXCr1DcUnS+D5BGpk42UYjSLv32rOSv1Hel/Znbld8bVZquCK9CziRbjWYzi2jYVY6JahaencNeuWy7YYp2wEW9PUw== X-Google-Smtp-Source: AGHT+IHxDkuYm0XwDehedcpPI1HIG3xDijcpujYMIIzQQIgVQNPYRuUDGeBCR3kTKXm6CbGvofKB X-Received: by 2002:a05:620a:1372:b0:792:92ab:4e70 with SMTP id d18-20020a05620a137200b0079292ab4e70mr5541668qkl.66.1714999829321; Mon, 06 May 2024 05:50:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714999829; cv=pass; d=google.com; s=arc-20160816; b=yxarINm6x3CMbKb1hRckbTI5Sa3PaMBkK6Qvcbo6ze8YAweijYyzRmyE7M/OrhDS1q IIf1GeEdSGJqZ1DreNPIgqzbzA8U4or84F7w83oRyHW4P45Ytle0lSxZchMrARdd7TLD WFmkhk6zS6DKXzlrIzoI2xmVB8guLvmub6Z7xO8095TLDxpV7PVCVMW+bgILdyUDrsv2 aY/bqTKkBQ2FkZdgmD7wT3KqiUTMef47IQNaRkP8jav2ot69SVhNItSioHE/Gcd4jMGw RMfiGbdnFwO5kXORsS9zznOSsoOpc/veVMNFmJzxgev/uR3DT30MUqCoUzKLOdWyrVEA RiXA== 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=fwUBUQsWRNjKVU9cZc71GGmr5twKK8Thmaq3+RulcLA=; fh=ULxNTxaaQIEX8Y9ih2rqqI9Lxn2bbvdaV8tkS1+QGD8=; b=tsAHzuXjAsR2L4jiIVZrhnflxt5cb0yCO0Z2ToJ2ZaJBfTm9tmfpOpmsIOrw+UYbOT 9N+jF8P2i7SCL2ik0CDQTeIy2GFKDjtmJV10UO18V+gXVIAToO+3F3v5Fzpwd0RFRwVM xnzDUEuAe7lMBoT2nFVbs9IO9p+6CLQmfJE7JlE/rhLh+BtW8SVwVz+EXUI4m40EAWjr bgFJcNew7VUO+te5uuNZgRFjGlOMsV3XGNrDRaK1KBjt9h67BsNH9MBwTajTByyTzYcl yhf8dS+HaZqLewrrSESV3rzFxjUHKhpvN+oZuGqxtPqPWga+COVud6yHyCyGOQ2pA8Hh 8Lmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7CaRqUK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169840-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 dc54-20020a05620a523600b00790f5c79c4dsi8905833qkb.410.2024.05.06.05.50.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 05:50:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169840-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=q7CaRqUK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169840-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169840-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 027A61C2388C for ; Mon, 6 May 2024 12:50:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AD9E54645; Mon, 6 May 2024 12:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q7CaRqUK" 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 7ED2835280; Mon, 6 May 2024 12:50:22 +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=1714999822; cv=none; b=K1xZ4mP5EzOTqmwH3sK2GkHq+MhYMuMVQ7ViWmkqENODSYO2jxsBNUNkL45qt4zp/XW4YnL7re7NMrA5/g5ncRxJqj/bGZDTp+AVQJgxyCT/lrrtN5+D8HTM9Dhqk0H5d9c3+Bwu+/RyJ6u2YWvJkF5tgnqz1q8gKDe9xZHBlfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714999822; c=relaxed/simple; bh=gH5EX8v31IKKWG02ARJDY+jbpfB5szxfgpICF1R0z5Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LjvotH9ZGLoYgcvMtxw1tcxG2z/bcCaNU5iQIZTy27RgCyBw6LLAsSQoTOI6uzCUnLahxzFSKhlAEuerbtL6GAmmL2V78uItoTsdwVdNjKwE+BhA50xs9RRvQZGoN1QVFVRT+rPwKOSuUBjdeSw16ZHsi7ffgyG09hAHFXV2ihc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q7CaRqUK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99A7AC116B1; Mon, 6 May 2024 12:50:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714999822; bh=gH5EX8v31IKKWG02ARJDY+jbpfB5szxfgpICF1R0z5Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=q7CaRqUKBWaHOY4aLBhLpE6y/nk6SLYueNsm6kBkRo2p6qCYnMN7dCgv//NERYNuD uB530fyyCqHx4j/yrSiIyp1R+DLpxQxCULrhGPJExIfNDoxDqo9tgEOIdREq/Tu03W gc+Ha5mt3z6PYmM1gA3PIktMa6pPhv/2xi0WRY+fzZjO2QQxnyY3jY2oohkrBEuiil dX3SQrEo9u03XKyFbWeGP//DbbrQ+TxNC8fDvqcm1hTkjLnPPGzwTuo1ii2IygeUPm OjCkSvOV2HA/EqFe8CVUQVQYA5T+dWa2nxNEtsM2sSAs9uID7IK692D/L8BYvKuR2L s1bS/Ti0li9Bg== Date: Mon, 6 May 2024 13:50:10 +0100 From: Jonathan Cameron To: Vasileios Amoiridis Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com, ang.iglesiasg@gmail.com, mazziesaccount@gmail.com, ak@it-klinger.de, petre.rodan@subdimension.ro, phil@raspberrypi.com, 579lpy@gmail.com, linus.walleij@linaro.org, semen.protsenko@linaro.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 10/10] iio: pressure: bmp280: Add triggered buffer support Message-ID: <20240506135010.5f7de250@jic23-huawei> In-Reply-To: <20240505235755.GC17986@vamoiridPC> References: <20240429190046.24252-1-vassilisamir@gmail.com> <20240429190046.24252-11-vassilisamir@gmail.com> <20240505203456.0c4c0c90@jic23-huawei> <20240505235755.GC17986@vamoiridPC> 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 On Mon, 6 May 2024 01:57:55 +0200 Vasileios Amoiridis wrote: > On Sun, May 05, 2024 at 08:34:56PM +0100, Jonathan Cameron wrote: > > On Mon, 29 Apr 2024 21:00:46 +0200 > > Vasileios Amoiridis wrote: > > > > > BMP2xx, BME280, BMP3xx, and BMP5xx use continuous buffers for their > > > temperature, pressure and humidity readings. This facilitates the > > > use of burst/bulk reads in order to acquire data faster. The > > > approach is different from the one used in oneshot captures. > > > > > > BMP085 & BMP1xx devices use a completely different measurement > > > process that is well defined and is used in their buffer_handler(). > > > > > > Suggested-by: Angel Iglesias > > > Signed-off-by: Vasileios Amoiridis > > Hi Vasileois, > > > > Just one question on this inline. (patches 8 and 9 look good to me) > > > > For v6, only need to send the patches that I haven't already applied. > > > > Thanks, > > > > Jonathan > > > > > > > > +static irqreturn_t bmp180_buffer_handler(int irq, void *p) > > > +{ > > > + struct iio_poll_func *pf = p; > > > + struct iio_dev *indio_dev = pf->indio_dev; > > > + struct bmp280_data *data = iio_priv(indio_dev); > > > + int ret, chan_value; > > > + > > > + guard(mutex)(&data->lock); > > > + > > > + ret = bmp180_read_temp(data, &chan_value); > > > + if (ret < 0) > > > + return IRQ_HANDLED; > > > + > > > + data->sensor_data[1] = chan_value; > > > + > > > + ret = bmp180_read_press(data, &chan_value); > > > > So I 'think' that after all the refactoring you end up reading the temperature > > twice. To avoid that you need to pull the read_temp() and read_press() > > function implementations here and only do the (currently duplicated) steps once. > > > > You seem to have done this for the other case, but missed the bmp180? > > Maybe I'm missing some reason it doesn't work for this one! > > > > Hi Jonathan! > > So, I didn't miss it. This is an old sensor and in order to get data out, the > procedure is much more constrained. As you can see in the datasheet [1] in page > 11 there is a well defined process on how to read the data out. It's not > possible to make a burst read here. Hence, the strange bmp180_measure() function > in order to wait for an EOC before reading the values. Indeed I am reading the > temperature 2 times which is not optimal but in order to read both of them I > would have to: > > a) either get the temperature out of the bmp180_read_press() function > (which would ruin a bit consistency with the other bmpxxx_read_press() functions) > > b) make a bmp180_get_sensor_data() which would look like bmp180_get_press() but > also gives temperature (which won't look that good). > > That's why I didn't touch it. If you think it makes more sense to do it, I can > follow one of the 2 approaches, whichever you think would make more sense. Ok. As you say, old sensor so fine to not optimize it. If anyone else cares they can do it ;) Jonathan > > Cheers, > Vasilis > > [1]: https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf > > > > + if (ret < 0) > > > + return IRQ_HANDLED; > > > + > > > + data->sensor_data[0] = chan_value; > > > + > > > + iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, > > > + iio_get_time_ns(indio_dev)); > > > + > > > + iio_trigger_notify_done(indio_dev->trig); > > > + > > > + return IRQ_HANDLED; > > > +}