From nobody Thu Nov 28 18:27:51 2024 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B238F169397; Sun, 29 Sep 2024 11:25:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727609122; cv=none; b=PrR8Tgnms9Qk6e72v+FgU08tulM52nZrCWU5u1vEwBTBw+dVbdeW/pUpkp+D8Ez7Jpo5ObXzqiHyzcMLbMzqaJh09yLgbIfRZqAAfE9F3ysq9b6+KNx5asOy+VGEYZ857hCg0KTENnNlY+ZzjQu2S6fmn9R0p/O8BY+nfxai6Nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727609122; c=relaxed/simple; bh=gxxA7ivFjr7HRIAjjFplPqLBO2UpR0l/wOIidePeYAw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U1Z1S/U8MyVTfHIsKZnp0oN9F0UHFiV/Z+3IijiVBwEbZpzBRqRZhZPu7lAPODHsHYUTQbUPkuqnqbTdIG8SCxZDPEn53bzFCk8eYANaSdScJFmVx60L6DPm+hVZfriWpbIaep7tjAKfZvhAYr9t4TonUGiRDHOkHqkzPMArkcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gRUz+ety; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gRUz+ety" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42cbe624c59so27890985e9.3; Sun, 29 Sep 2024 04:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727609119; x=1728213919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a4S0wSFiMXvjsH1D6RegaYvTzs4XY/u0KzJSxFKGOBg=; b=gRUz+etyRlvYgTtunEyQ5fsg+Ze8JLOFrG5ei2PqZqRIhy3AKTiv7dOlF61kGVcJT3 7zA+BdgJ0lTUdS728b+XIH8U6+cYOsLVKhGsMrTxnDTnsTPn41Qe6drFdbhCR8tQYN1x 17TiRf7o1IFzGM0gL/dYCyDnSzrJuVUguW6wIm0QGnnJfys0/1N9a3WoAef5iFc5kGpo +XF6+Cii+UAYWGx4qYuc9wbroBvjt1wx9qcBRCwuvDkK3RMKz9V7BdL7Bar+VH8dvnQH vrjA8tuAfl7Gzoor/PKtJ6bUWkLNyC/GSBRKvlKMl0GT6YRLFjEODqNNFDbBWm4xAlc4 lGkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727609119; x=1728213919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a4S0wSFiMXvjsH1D6RegaYvTzs4XY/u0KzJSxFKGOBg=; b=PtT3rnjbqx6U+22tLxB6HvTk/oogcABbFfDS9+huIljgdtwG3CPcrzn2wGTo9v0olb IZrjokgz8QxL9NNJBCWDi9y9FDL80YyTDoIzLq4bPCnDjUmzixoGXowAroUEhKA2BwVm EOqkpN/DPXUPBwpytXFnxbYPeItVyFS8LLOc0rmjAyOOIiBi83Dbw//808WC/i4JCU8/ IYVBXWS4zX7jRojK/tCItf8ucTtmTZOqM9uOJoezPNSWHyKv5kcsdJ7WTgGczP+rOmFb lG1SDMegv5ZOujbS0E8wkM0fD73BeOZH9UXruOtmIaVASOOIOfAu/txG/L889c3fxEGx imwA== X-Forwarded-Encrypted: i=1; AJvYcCUjs11HJGIRBm8VfCGaV/v5ol0CN61XieQZif41vOz6KLEqrP0wTQuV8AwJGP7PqyHWlL4kd4fi7uHNs7kW@vger.kernel.org, AJvYcCXHg+3vpQHCcB68AdjHUalu/Ln+YUtn+XT+uMEUPyY4Z73lcu6AIiOYNLpjN8msIMmOFFliXjXg4NE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6v3y+KkdzhTM+WqpVuvo6RH4VRXIGH0jsmbovHqs966QKCK58 aiqxG1o2ZvFnVAyPqnZUqDaZlmnTK1hrGMBJ9bZSTXVPfKUMXG+f X-Google-Smtp-Source: AGHT+IFPeppOHhODTxr3htPy4n0zQokuoKB5riVLiHmZoDcNVKgvc3++7qVL7a9F4ApNFr3qxT/3pA== X-Received: by 2002:a05:600c:510d:b0:42c:c08e:c315 with SMTP id 5b1f17b1804b1-42f584481b5mr68498465e9.16.1727609118771; Sun, 29 Sep 2024 04:25:18 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:82:7577:df60:d786:cd5:d3c1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f57de1192sm74717325e9.14.2024.09.29.04.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2024 04:25:17 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org Cc: dan.carpenter@linaro.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Vasileios Amoiridis Subject: [PATCH v2 1/2] iio: pressure: bmp280: Fix type for raw values Date: Sun, 29 Sep 2024 13:25:10 +0200 Message-Id: <20240929112511.100292-2-vassilisamir@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240929112511.100292-1-vassilisamir@gmail.com> References: <20240929112511.100292-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The adc values coming directly from the sensor in the BM{E,P}{2,3}xx sensors are unsigned values so treat them as such. Fixes: 80cd23f43ddc ("iio: pressure: bmp280: Add triggered buffer support") Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp2= 80-core.c index 6c2606f34ec4..472a6696303b 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1023,7 +1023,8 @@ static irqreturn_t bmp280_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - s32 adc_temp, adc_press, t_fine; + u32 adc_temp, adc_press; + s32 t_fine; int ret; =20 guard(mutex)(&data->lock); @@ -1137,7 +1138,8 @@ static irqreturn_t bme280_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - s32 adc_temp, adc_press, adc_humidity, t_fine; + u32 adc_temp, adc_press, adc_humidity; + s32 t_fine; int ret; =20 guard(mutex)(&data->lock); @@ -1616,7 +1618,8 @@ static irqreturn_t bmp380_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - s32 adc_temp, adc_press, t_fine; + u32 adc_temp, adc_press; + s32 t_fine; int ret; =20 guard(mutex)(&data->lock); --=20 2.25.1 From nobody Thu Nov 28 18:27:51 2024 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF4B2175D32; Sun, 29 Sep 2024 11:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727609124; cv=none; b=akePM1ha7vAhb6xQn7SDJBjzgWipLrihKQYWHSxy5F/yLVR8cMunyp/OkodT15LSjSfqidmNQs1eWMEeAskkJZGgurM1m4glHBPxhO6N9YVhRnxGivwKzpaUoY/S/v8xs6CD9v3+t66Q/YpECyBo94Tnzqx9IU5p5oIc+TLs2Kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727609124; c=relaxed/simple; bh=X7fORzgExfQA0C69v6mdx3BvSNCqFSI75V/IXIa61q4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tuo7qsr1Hf5y8DqxOQKASOvMCbfWcu4wulNsggaXVmkO9a41oizbeS1KnEYnXS1f0Vc0VSDsetHC499LhB2UrxR082zPXTTcqwJHLRJP61IJQQk+8o6tv1vzvcuN+iS85dFZmv724x3MoL9KSHnHsOi6BVTT+ei4yz2ThB7QP8Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jb9i1rlB; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jb9i1rlB" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42cbe624c59so27891085e9.3; Sun, 29 Sep 2024 04:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727609121; x=1728213921; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dyzHFaozNPNRfwrQWOh+rrvCgTOHdjJlFF8sSYQJj8g=; b=jb9i1rlBHNZxMKTqwA6RZ1aN642VunS7W40ZCe1v+8qw7ekEThrDJXEIUyVR/VbVks yhlnyrACPJtdnwP2YdFvd0rlBbgReJK/bScvIGjXqjFw1uFeWJU3TbO9IboenXcdQUCn nuELQ/HVIgcM3jf/xqAc7IBNP69pLU4kRWYNA3bFrUzdQzW4DbfNWMZjSDbx1amsq7Xs JVzNd3dud9ib0hYLUM/lu8yvEvcKwPDSNVmy3vVALRQJg4FHmXjaMXVFO6Tmg4rgSKKI XfnKs7zDJmPaVNLW95qgIEHVMMnO/j7rmuptN/FYifIoUavr8dIuDmIA6o8xLAOOvWko Pn7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727609121; x=1728213921; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dyzHFaozNPNRfwrQWOh+rrvCgTOHdjJlFF8sSYQJj8g=; b=aS1t4TthvNdt7i1n0CTNSqagBHz5/JUxvECN6Vo03qBrbemClx/8eaXwgrMvZ4GPug pTedmNGvrzeG/uZ78b69pDpvKSvSUq0xtpo5TiqmYm/S/AFCuTRWUh8taMcT4AenoHhf n1fFCp+pMV8Suw6RTbcKPgTqSGDUqa5mPzD8wcXUjeUEV7GhT/xPGhVOMLhHkkYuXUKm jmE5Ew4PcIKaOEd5CiqeyjeAsYSymgMLG/v1U7J4EolPZoBMj3gmpIDrdDWwUAjXuyba Twh3Ipr81IydtAja3S0rGWm/oi0Q1vnRflzik3UCXBlaVk+D4GWuP9r7yr3MQ3V19bHA atrw== X-Forwarded-Encrypted: i=1; AJvYcCUhRVJO1IjEcHQlA8aCqO1QCYIO+NpSvzkUoZaCI9D/1+zMtV+wFT+ZL8izmUJSJy0a2xWHCv9VDXS/ZtRu@vger.kernel.org, AJvYcCUmtb69ma1FLAh+XKtQnXtwVaPeJiy+nZRHk7esg91HQN18AzDjGOT2LKjW4UG+iCNqMrVoj1hL29M=@vger.kernel.org X-Gm-Message-State: AOJu0YzBRn/wc8QIaUQT/NbgjtPve6qnf3m3XFQ9IIitqCyTD5ulehNQ eeb6WmH6B0nvMyw7o4E70LvbwW4TQ0TRQA4ByJdnjiXf0LGFqv/iDZKN1+Pn X-Google-Smtp-Source: AGHT+IEDQCu4uBTkegCrLYqMLI0mYo1OyKgpWYgmrRPbWa/wTPJLtH6LGCaMFbitQU3amAhRaaxskg== X-Received: by 2002:a05:600c:3b93:b0:426:689b:65b7 with SMTP id 5b1f17b1804b1-42f58485cc1mr63667835e9.25.1727609120938; Sun, 29 Sep 2024 04:25:20 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:82:7577:df60:d786:cd5:d3c1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42f57de1192sm74717325e9.14.2024.09.29.04.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2024 04:25:19 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org Cc: dan.carpenter@linaro.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Vasileios Amoiridis Subject: [PATCH v2 2/2] iio: pressure: bmp280: Use char instead of s32 for data buffer Date: Sun, 29 Sep 2024 13:25:11 +0200 Message-Id: <20240929112511.100292-3-vassilisamir@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240929112511.100292-1-vassilisamir@gmail.com> References: <20240929112511.100292-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As it was reported and discussed here [1], storing the sensor data in an endian aware s32 buffer is not optimal. Advertising the timestamp as an addition of 2 s32 variables which is also implied is again not the best practice. For that reason, change the s32 sensor_data buffer to a char buffer with an extra value for the timestamp (as it is common practice). [1]: https://lore.kernel.org/linux-iio/73d13cc0-afb9-4306-b498-5d821728c3ba= @stanley.mountain/ Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 78 ++++++++++++++++++------------ drivers/iio/pressure/bmp280.h | 5 +- 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp2= 80-core.c index 472a6696303b..2c62490a40c6 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1023,9 +1023,9 @@ static irqreturn_t bmp280_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - u32 adc_temp, adc_press; - s32 t_fine; - int ret; + u32 adc_temp, adc_press, comp_press; + s32 t_fine, comp_temp; + int ret, offset; =20 guard(mutex)(&data->lock); =20 @@ -1044,7 +1044,7 @@ static irqreturn_t bmp280_trigger_handler(int irq, vo= id *p) goto out; } =20 - data->sensor_data[1] =3D bmp280_compensate_temp(data, adc_temp); + comp_temp =3D bmp280_compensate_temp(data, adc_temp); =20 /* Pressure calculations */ adc_press =3D FIELD_GET(BMP280_MEAS_TRIM_MASK, get_unaligned_be24(&data->= buf[0])); @@ -1054,10 +1054,13 @@ static irqreturn_t bmp280_trigger_handler(int irq, = void *p) } =20 t_fine =3D bmp280_calc_t_fine(data, adc_temp); + comp_press =3D bmp280_compensate_press(data, adc_press, t_fine); =20 - data->sensor_data[0] =3D bmp280_compensate_press(data, adc_press, t_fine); + memcpy(&data->buffer.buf[offset], &comp_press, sizeof(s32)); + offset +=3D sizeof(s32); + memcpy(&data->buffer.buf[offset], &comp_temp, sizeof(s32)); =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, iio_get_time_ns(indio_dev)); =20 out: @@ -1138,9 +1141,9 @@ static irqreturn_t bme280_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - u32 adc_temp, adc_press, adc_humidity; - s32 t_fine; - int ret; + u32 adc_temp, adc_press, adc_humidity, comp_press, comp_humidity; + s32 t_fine, comp_temp; + int ret, offset; =20 guard(mutex)(&data->lock); =20 @@ -1159,7 +1162,7 @@ static irqreturn_t bme280_trigger_handler(int irq, vo= id *p) goto out; } =20 - data->sensor_data[1] =3D bmp280_compensate_temp(data, adc_temp); + comp_temp =3D bmp280_compensate_temp(data, adc_temp); =20 /* Pressure calculations */ adc_press =3D FIELD_GET(BMP280_MEAS_TRIM_MASK, get_unaligned_be24(&data->= buf[0])); @@ -1169,8 +1172,7 @@ static irqreturn_t bme280_trigger_handler(int irq, vo= id *p) } =20 t_fine =3D bmp280_calc_t_fine(data, adc_temp); - - data->sensor_data[0] =3D bmp280_compensate_press(data, adc_press, t_fine); + comp_press =3D bmp280_compensate_press(data, adc_press, t_fine); =20 /* Humidity calculations */ adc_humidity =3D get_unaligned_be16(&data->buf[6]); @@ -1179,9 +1181,16 @@ static irqreturn_t bme280_trigger_handler(int irq, v= oid *p) dev_err(data->dev, "reading humidity skipped\n"); goto out; } - data->sensor_data[2] =3D bme280_compensate_humidity(data, adc_humidity, t= _fine); =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + comp_humidity =3D bme280_compensate_humidity(data, adc_humidity, t_fine); + + memcpy(&data->buffer.buf[offset], &comp_press, sizeof(s32)); + offset +=3D sizeof(s32); + memcpy(&data->buffer.buf[offset], &comp_temp, sizeof(s32)); + offset +=3D sizeof(s32); + memcpy(&data->buffer.buf[offset], &comp_humidity, sizeof(s32)); + + iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, iio_get_time_ns(indio_dev)); =20 out: @@ -1618,9 +1627,9 @@ static irqreturn_t bmp380_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - u32 adc_temp, adc_press; - s32 t_fine; - int ret; + u32 adc_temp, adc_press, comp_press; + s32 t_fine, comp_temp; + int ret, offset; =20 guard(mutex)(&data->lock); =20 @@ -1639,7 +1648,7 @@ static irqreturn_t bmp380_trigger_handler(int irq, vo= id *p) goto out; } =20 - data->sensor_data[1] =3D bmp380_compensate_temp(data, adc_temp); + comp_temp =3D bmp380_compensate_temp(data, adc_temp); =20 /* Pressure calculations */ adc_press =3D get_unaligned_le24(&data->buf[0]); @@ -1649,10 +1658,13 @@ static irqreturn_t bmp380_trigger_handler(int irq, = void *p) } =20 t_fine =3D bmp380_calc_t_fine(data, adc_temp); + comp_press =3D bmp380_compensate_press(data, adc_press, t_fine); =20 - data->sensor_data[0] =3D bmp380_compensate_press(data, adc_press, t_fine); + memcpy(&data->buffer.buf[offset], &comp_press, sizeof(s32)); + offset +=3D sizeof(s32); + memcpy(&data->buffer.buf[offset], &comp_temp, sizeof(s32)); =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, iio_get_time_ns(indio_dev)); =20 out: @@ -2199,7 +2211,7 @@ static irqreturn_t bmp580_trigger_handler(int irq, vo= id *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - int ret; + int ret, offset; =20 guard(mutex)(&data->lock); =20 @@ -2211,13 +2223,16 @@ static irqreturn_t bmp580_trigger_handler(int irq, = void *p) goto out; } =20 + /* Pressure calculations */ + memcpy(&data->buffer.buf[offset], &data->buf[3], 3); + + offset +=3D sizeof(s32); + /* Temperature calculations */ - memcpy(&data->sensor_data[1], &data->buf[0], 3); + memcpy(&data->buffer.buf[offset], &data->buf[0], 3); =20 - /* Pressure calculations */ - memcpy(&data->sensor_data[0], &data->buf[3], 3); =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, iio_get_time_ns(indio_dev)); =20 out: @@ -2523,23 +2538,24 @@ static irqreturn_t bmp180_trigger_handler(int irq, = void *p) struct iio_poll_func *pf =3D p; struct iio_dev *indio_dev =3D pf->indio_dev; struct bmp280_data *data =3D iio_priv(indio_dev); - int ret, chan_value; + int ret, comp_temp, comp_press, offset; =20 guard(mutex)(&data->lock); =20 - ret =3D bmp180_read_temp(data, &chan_value); + ret =3D bmp180_read_temp(data, &comp_temp); if (ret) goto out; =20 - data->sensor_data[1] =3D chan_value; =20 - ret =3D bmp180_read_press(data, &chan_value); + ret =3D bmp180_read_press(data, &comp_press); if (ret) goto out; =20 - data->sensor_data[0] =3D chan_value; + memcpy(&data->buffer.buf[offset], &comp_press, sizeof(s32)); + offset +=3D sizeof(s32); + memcpy(&data->buffer.buf[offset], &comp_temp, sizeof(s32)); =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, iio_get_time_ns(indio_dev)); =20 out: diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index a9f220c1f77a..b0c26f55c6af 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -419,7 +419,10 @@ struct bmp280_data { * Data to push to userspace triggered buffer. Up to 3 channels and * s64 timestamp, aligned. */ - s32 sensor_data[6] __aligned(8); + struct { + u8 buf[12]; + aligned_s64 ts; + } buffer; =20 /* * DMA (thus cache coherency maintenance) may require the --=20 2.25.1