Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1980001lqo; Sun, 19 May 2024 07:35:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnQ8j1Twyju+DSIK0He+7pkevvRSSFUhtBmIMwcf9HuXrklt/m7zO5uk0+K9Y2Hfd7PiDOVN5k1X9TSj/f0WSOTcsRs7zDMnolNQoFug== X-Google-Smtp-Source: AGHT+IHW5VoKDr2Tr+QxaHSgvHVsWbcUv5CaXtxcIqLwHqE329fURtQXY12eIHOZIlfcJFfhU6nU X-Received: by 2002:a05:6512:3c9e:b0:523:9493:4e63 with SMTP id 2adb3069b0e04-5239493505emr10672127e87.60.1716129324411; Sun, 19 May 2024 07:35:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716129324; cv=pass; d=google.com; s=arc-20160816; b=IxfBh3CVb08FmaaT9nH9aQrJk4bWuhh0uu2u3yCB0PSaJTNnhkO9CqdTuz3DViZLK+ 9iPavpyPqOgecox+Q26AftEba34he3ENhu0KFpR8d4EmX/pAmDIs5kOueJ2nViKYUHLd q6QldZzeH28e57KZvFIMI0mTDvaY3TlN0ekIlFN32lCawh0PxEHqGg7d1WkXXIuprq1C XbK9bq9HaJcRYKyFv/BMEauGykQNMQRJMU4rHqArpd6Sz/g9FrTrkW2Qh/yg1TImamtq XN3+pfo94nT7GOPiEz5VdQ5/EzUx+crSzeJeTrwQ19AyWMmRLEZDtNwrRSebgmk7QsiM 4YPw== 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=ZKoq49qeNBygLNFlMLrhgqvYSscI3lB/YWEdJB+rnkA=; fh=ULxNTxaaQIEX8Y9ih2rqqI9Lxn2bbvdaV8tkS1+QGD8=; b=lrySP5oOnb15w9b+MT/HuOq1prEYNjihG1zjC/c3L8zLnzfEKl36QcoGxEefTK8m0Q 1v8EDoPRpZ6KZFE9ROP6IYccmvJZrh/HZm8yeVOTtce+GlF5HhdBIITqSU+UO13Jfl7k GGzHWRsnS+doABL35ZG+w3mmgayuL9AnzvF/ZrwbSxxwl7NCALcXsXHsqzio+SgYtGJT 6vmVfxOumrV4iDmFWo1wtm5pn3CGNRuuW3UUsQ+BJMA3TBScdknWS7QqCM5qYQ9jrOuQ ixsm8w2sGvu3ofgZjcdedVphx9PGne+XG50jsZqUuyrEVCWbR9moQpru2wYjeT/VVDuE UIWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IWeoyJJR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183130-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a8a6efd1fsi616158566b.738.2024.05.19.07.35.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 07:35:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IWeoyJJR; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183130-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183130-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 256761F211F4 for ; Sun, 19 May 2024 14:35:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8B334CB28; Sun, 19 May 2024 14:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IWeoyJJR" 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 E7E161A2C10; Sun, 19 May 2024 14:35:15 +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=1716129316; cv=none; b=ueqSU3GBDQ1kbRe2ottjdxm7BXB08PasRILAMYyrfSskqT31bfCATM5kBcP9jr2VqncOZNQGnzQ/a6fUTPxbJQarnc8LosFXYaQTEyW6ZTgVI7RrjF8UASrzOYOd3ePFABGYJ2ieFStGm9hvjkP99SRp6UO3YBOmLeN0bqGyqb4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716129316; c=relaxed/simple; bh=acJzPp/ACsuFShBqZ1EROr8tF6WzxfJcERezBmSDdeg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IF5wTAzE4fxKkO1XYBfWQIkzVu0+ZsTxQDlwRCPK06ad8yrfjSVSm8Rj9jUiyJoL+2MErCLRkr5z2v0uN8BXQ8Og5dKlugtcQFjf8qzeIuB5t5ftcFsjbubeolMvyZTW0rRZqUE5TQSSly67uDkAS/7l4PJMsqFc7y7aolAWzI0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IWeoyJJR; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85103C32781; Sun, 19 May 2024 14:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716129315; bh=acJzPp/ACsuFShBqZ1EROr8tF6WzxfJcERezBmSDdeg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IWeoyJJReFBVFtjfYEBtVUANNaqB2bXQKXLty9T9e9UFAjUOBilkldiVUYd72OSWC 90yzqhX6AE0S1AeJZ4NMdjNa9gPGnxW9/VnF1DreWLEj8zCdmV/d/8stOuvkJwPxg2 YC6+QPR2O0pjtgfvU+QDbf3mU2lUDTLZ71fckUnKA3i3Uw0JOEExo8Cy5lvNTps6ev hEM2b+V7bJd3EqGHwkVhFfBqAddGmdLrFE12Bebp511nckX3iBYPuDvFQdVUKgfR+g LtqRjY4ruA5zRzEaLeuKPskbhOauPyTWSe9B+19A9g6PcQOPyuSRoTaaNbMy3DoQzE 8RLury6rbToKA== Date: Sun, 19 May 2024 15:35:01 +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 v7 5/5] iio: pressure: bmp280: Add triggered buffer support Message-ID: <20240519153501.7d30c7c2@jic23-huawei> In-Reply-To: <20240512230524.53990-6-vassilisamir@gmail.com> References: <20240512230524.53990-1-vassilisamir@gmail.com> <20240512230524.53990-6-vassilisamir@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; 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, 13 May 2024 01:05:24 +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 > > +static irqreturn_t bmp280_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); > + s32 adc_temp, adc_press, adc_humidity, t_fine; > + u8 sizeof_burst_read; > + int ret; > + > + guard(mutex)(&data->lock); > + > + /* > + * If humidity channel is enabled it means that we are called for the > + * BME280 humidity sensor. > + */ > + if (test_bit(BME280_HUMID, indio_dev->active_scan_mask)) The only thing I though a bit about on this review was whether this combined function really makes sense, or should we just move to two separate handlers. It's marginal, but given you had it done this way let us stick with this. Definitely something to keep in mind for future changes though that may make this more complex still. For now it's fine. Applied to the togreg branch of iio.git but given timing that is for now only pushed out as testing and I'll rebase it on rc1 once available. Thanks, Jonathan > + sizeof_burst_read = BME280_BURST_READ_BYTES; > + else > + sizeof_burst_read = BMP280_BURST_READ_BYTES; > + > + /* Burst read data registers */ > + ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, > + data->buf, sizeof_burst_read); > + if (ret) { > + dev_err(data->dev, "failed to burst read sensor data\n"); > + goto out; > + } > + > + /* Temperature calculations */ > + adc_temp = FIELD_GET(BMP280_MEAS_TRIM_MASK, get_unaligned_be24(&data->buf[3])); > + if (adc_temp == BMP280_TEMP_SKIPPED) { > + dev_err(data->dev, "reading temperature skipped\n"); > + goto out; > + } > + > + data->sensor_data[1] = bmp280_compensate_temp(data, adc_temp); > + > + /* Pressure calculations */ > + adc_press = FIELD_GET(BMP280_MEAS_TRIM_MASK, get_unaligned_be24(&data->buf[0])); > + if (adc_press == BMP280_PRESS_SKIPPED) { > + dev_err(data->dev, "reading pressure skipped\n"); > + goto out; > + } > + > + t_fine = bmp280_calc_t_fine(data, adc_temp); > + > + data->sensor_data[0] = bmp280_compensate_press(data, adc_press, t_fine); > + > + /* Humidity calculations */ > + if (test_bit(BME280_HUMID, indio_dev->active_scan_mask)) { > + adc_humidity = get_unaligned_be16(&data->buf[6]); > + > + if (adc_humidity == BMP280_HUMIDITY_SKIPPED) { > + dev_err(data->dev, "reading humidity skipped\n"); > + goto out; > + } > + data->sensor_data[2] = bme280_compensate_humidity(data, adc_humidity, t_fine); > + } > + > + iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, > + iio_get_time_ns(indio_dev)); > + > +out: > + iio_trigger_notify_done(indio_dev->trig); > + > + return IRQ_HANDLED; > +} > + >