From nobody Thu Nov 28 15:33:59 2024 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 1A0A519922D; Mon, 30 Sep 2024 20:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727727848; cv=none; b=TvDgaOM0gmHiwKZ52O/E4v750NI2XaaKIoT6jkaDSI7G4c75BuNAooSFpEpiaCgIpPTaMIu4T59gGkUJzV3hWu6wemcLZLU6fRXZ6xnFpbhN4vLR7RO/JYZ9d8LXeboBFuWSs6lo/kIv8jpfjDkqhluoM0JsOEcriVw7RIEOQeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727727848; c=relaxed/simple; bh=2dn2X/NNMtx/iHtMaH61vP7bvPFO7xJZhLbe0Ph4rFw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q+avuVBuqBGrpS9rmMr4+pzROGymNp1QxE+O0UAD+a7dosh3gqmnDLRwjzl4fBKM5bFfW/Efc/qU8lozBK+N+3sNctMc0GHdRqSVQezJTQgMjLn81W4Pa2nW99IMlG1sQoDKxLRUspV549zZkcqZvJkzRriX/kvURnzW6zQONBk= 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=BYj+weW8; arc=none smtp.client-ip=209.85.128.52 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="BYj+weW8" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42cb57f8b41so59307715e9.0; Mon, 30 Sep 2024 13:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727727845; x=1728332645; 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=g3ANjQP1ppTlWluml2iZxIJPKl4y/kaQbfY+Kx5CtqE=; b=BYj+weW8nLThCNb/pRFemX8NJAeSwUDt5Ft2tQYNfzKBeEMA7iJy0VrDZZddZeAi9z eXIZ1WBAQONnBg02BuOpOzectKxNHiezo1uc+NkQ39Dl7M2NRJq8povHjG2/RFRuW4mN cfD/UaSDb07ddqyJtl9+e1CP8BdKhivP6ayDECRZ5qc2syHbrHF4pJGJY0rdavXgqS3c pmgbJf2q/JA64SUPlrxOGGYFIERazMdP3hhlxJO0B1cP8chi3OM9EGfuU5mhwbAzbv6J vrU0YB0Nma4t5tSbF1TRi9lxc4MTEou7rxvO8c5g8k3Bl0fqcpiPXemL+cBMjNgDK+X8 TFew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727727845; x=1728332645; 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=g3ANjQP1ppTlWluml2iZxIJPKl4y/kaQbfY+Kx5CtqE=; b=XVUXct/nlG0AbhAry9EvL5KpoIkHN4IcjgeaDkc9yqCMNZ2vg6YIE4p22tyZdB/g53 5WJWX5nhevQrRvlZqC7sl2/LF/RZnWRQhP1vIN6tVA4kqD0Qovz5k7dq0SJb7Ys1N5Xw 2Kw23FstEMOuDHcubz5FSUu2FVgKrZVfGQqVMbsNS/5sTrAwaOsztSbOi7A7+bRirxgT 6/Q49C8NZrfRePx+0NQ+mSUOO/eatztz3u3k3m+e7AK5D8oBqbSeimWMFbLb0cLy9FTK kTh5qWJ+nR5oj6WBFwKECaUombQy5nyrmU6Ji2I8f0cI1TTcDsB0csjr7xJ7UYJpP9OS 8ttA== X-Forwarded-Encrypted: i=1; AJvYcCV4No1HdcQkKK77WH8tgIE7SZwZz/y//caUak6FWfled/OjhEaYVt0L8Wsty+gkk4shGBFf8W4HtJA=@vger.kernel.org, AJvYcCWZOuBm3LTxDXaTFl3SDAQzCPOV9tpJlmBgEA+vWbyBx7R27oTe6gcuMAI+rAesdHAVOkskwB+a+9Rjs+oX@vger.kernel.org X-Gm-Message-State: AOJu0YyMTHZb9HwRo14E19Pj5M0wox+dU8G3CkFF7jjhyxSvSVqtVbmh pGvDD+XzhhKe4Grvaij+hpR+dYgkvF2B/UQgcVNrbugEjVe3pTtH X-Google-Smtp-Source: AGHT+IF1R4BLZJtEdwNFYI+Jdz10jlUCKpwoFqhh3mjZ32Xw8C7tPgJdvgHlA70QQHgMRpWyy2bE0w== X-Received: by 2002:a05:6000:45:b0:37c:d1c6:7e45 with SMTP id ffacd0b85a97d-37cd5b04439mr11414558f8f.40.1727727845078; Mon, 30 Sep 2024 13:24:05 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:82:7577:89eb:9ac0:8a4a:319b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e65e4sm10064052f8f.61.2024.09.30.13.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 13:24:04 -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 v3 1/2] iio: pressure: bmp280: Use unsigned type for raw values Date: Mon, 30 Sep 2024 22:23:52 +0200 Message-Id: <20240930202353.38203-2-vassilisamir@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930202353.38203-1-vassilisamir@gmail.com> References: <20240930202353.38203-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. 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 15:33:59 2024 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 2350A1A2541; Mon, 30 Sep 2024 20:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727727850; cv=none; b=amP2N6T0xBN44s0Z9wQ31NRe10cXJyn8+1+/a3X4DVNJtLCJQQGV8PX2qYBHVFO0kMirzpPPLKkhYhwHssjFIqCwf/cPLgUrZdb5lHxMsRcCg9RD3X8TZ+Lks5y+PY97liJZpVeT4VQN3l0VJaHpVmklfzYmttAIl/dXq8/HqGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727727850; c=relaxed/simple; bh=RmxdUFHsaBXNARBCNZrRTzRIQzLkbNfV3Q0LYAtokpc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J1oiE75sTMZW20v1yHVCmt0ZjFMXAzDKd2taNZOVCflOOggwtBhlyWh3SibReBTlEHqeuIPFeM61SQ0PhSmA8ybhtuKk8or8KFR0xqb3siDyor8lM5eG18aBPKkkVEpKj+PFB0PbtYfLXQjEYPYZf2jYsfPc7tqCKoVbBRLV+3k= 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=M5o9eUDW; arc=none smtp.client-ip=209.85.221.43 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="M5o9eUDW" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-37cc4e718ecso3218004f8f.0; Mon, 30 Sep 2024 13:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727727846; x=1728332646; 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=N0sgKCiAcApFBFQ0JAwvmnGBkpAWLyGLAUEGVVDFn48=; b=M5o9eUDWEtCoiFWdA9Cwh2TTlXb0rj/BLjVySaBkE30iomBog48N+HWUq9yH7mADcY lETSinQLnJfe5p0wkFLDO95fd3qh7F/Ei6Np+4QbwEBPJH5Uetdw+FCPdPqaDOREVogC Fyr52iEHkIg+X7LU9wqMgz5llSYiWk9yFCl2+Dw4T5DoF3GKxsj5lHit+jDfmxlgeZQq G/PzUzm0hIY1B+pQBwA7fh8vkJE5/pn0F5ebLr/rWSbGNWJHj3ocsuf+Rb23ie4n0KwC QHv9hE6bOsrNH3/dj+JTSyuwG7gO0VhHfHp1vRYTzEkEKnFMHYmEaFC86s5R10EqlzRm nDwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727727846; x=1728332646; 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=N0sgKCiAcApFBFQ0JAwvmnGBkpAWLyGLAUEGVVDFn48=; b=NnuD27H4opWGToQ0iwpAINJdVbg1SL7hbZVgiYPdv7ozJoXGWnuyaer/5uo8bGmSoz OvtusDU3pMVbssZ5zgVpHEMgv7fO8v5fLLYwb9g5KPJjZxhXzIcjnZcXR/EUoxflWiF4 AhuoKKVsKLvXCHfCAuPCnPdRoDQh7Ie9PzeADgxl0E+YpFULOTozV99umGefVk2aDUlM bZ9NcSh3Zd7FZwwU70GJ7CI/fD3qS1kVnyVjdkzZlS/XWBnKTaves48CXlJ4kNMP2vqE dApMzxTMTvG4R+k11h7KOLbIx7bl+YobydkixoK+EqMNrY0s5PHBLWaRERMmTvMO8Rw7 qwXQ== X-Forwarded-Encrypted: i=1; AJvYcCU4uC9ZuoSNnXLvILYPWQSnZ2dHh7pyzAyia65mluvldB+SIXPBYiSq8ovJhG0Yyx4Ia503gyhbNL7jwsXZ@vger.kernel.org, AJvYcCVnoJGODSJua3eGfOwIhG5ikoCtbrB+aTsZUDfqSdRo07GEsS0ern1xENRiWVyrz8vYPlpGHNtiG9M=@vger.kernel.org X-Gm-Message-State: AOJu0YwxLyMVM65ygRWVuWbaJRroSMYURMi8Q47cgx0B/TfdQwJf5NwK LwHUUItQ648PFLFKSRlYbtv/T4cZrwaTJ4e5RoiV7jdookdBIpf3iaOYpE8e X-Google-Smtp-Source: AGHT+IFM/qKitDakAcvI3c2AKDR4xLVteAVdc+UtkF55o0TEuemuZqhAhPluXUZSwbbGfmniXeV/Ag== X-Received: by 2002:a5d:5145:0:b0:37c:ccc1:17d2 with SMTP id ffacd0b85a97d-37cd5a9d0b6mr7138250f8f.34.1727727846103; Mon, 30 Sep 2024 13:24:06 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:82:7577:89eb:9ac0:8a4a:319b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd56e65e4sm10064052f8f.61.2024.09.30.13.24.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 13:24:05 -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 v3 2/2] iio: pressure: bmp280: Use char instead of s32 for data buffer Date: Mon, 30 Sep 2024 22:23:53 +0200 Message-Id: <20240930202353.38203-3-vassilisamir@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930202353.38203-1-vassilisamir@gmail.com> References: <20240930202353.38203-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 u8 buffer and align it properly. [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 | 72 ++++++++++++++++++------------ drivers/iio/pressure/bmp280.h | 4 +- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp2= 80-core.c index 472a6696303b..6811619c6f11 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1023,8 +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; + u32 adc_temp, adc_press, comp_press; + s32 t_fine, comp_temp; + s32 *chans =3D (s32 *)data->sensor_data; int ret; =20 guard(mutex)(&data->lock); @@ -1044,7 +1045,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 +1055,12 @@ 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); + chans[0] =3D comp_press; + chans[1] =3D comp_temp; =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, iio_get_time_ns(indio_dev)); =20 out: @@ -1138,8 +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; + u32 adc_temp, adc_press, adc_humidity, comp_press, comp_humidity; + s32 t_fine, comp_temp; + s32 *chans =3D (s32 *)data->sensor_data; int ret; =20 guard(mutex)(&data->lock); @@ -1159,7 +1163,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 +1173,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 +1182,14 @@ 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); + + chans[0] =3D comp_press; + chans[1] =3D comp_temp; + chans[2] =3D comp_humidity; + + iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, iio_get_time_ns(indio_dev)); =20 out: @@ -1618,8 +1626,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; + u32 adc_temp, adc_press, comp_press; + s32 t_fine, comp_temp; + s32 *chans =3D (s32 *)data->sensor_data; int ret; =20 guard(mutex)(&data->lock); @@ -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,12 @@ 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); + chans[0] =3D comp_press; + chans[1] =3D comp_temp; =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, iio_get_time_ns(indio_dev)); =20 out: @@ -2199,7 +2210,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 +2222,15 @@ static irqreturn_t bmp580_trigger_handler(int irq, = void *p) goto out; } =20 - /* Temperature calculations */ - memcpy(&data->sensor_data[1], &data->buf[0], 3); - /* Pressure calculations */ - memcpy(&data->sensor_data[0], &data->buf[3], 3); + memcpy(&data->sensor_data[offset], &data->buf[3], 3); + + offset +=3D sizeof(s32); + + /* Temperature calculations */ + memcpy(&data->sensor_data[offset], &data->buf[0], 3); =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, iio_get_time_ns(indio_dev)); =20 out: @@ -2523,23 +2536,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; + s32 *chans =3D (s32 *)data->sensor_data; =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; + chans[0] =3D comp_press; + chans[1] =3D comp_temp; =20 - iio_push_to_buffers_with_timestamp(indio_dev, &data->sensor_data, + iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, iio_get_time_ns(indio_dev)); =20 out: diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index a9f220c1f77a..dc1bf04cb0b5 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -322,6 +322,7 @@ BMP280_NUM_TEMP_BYTES + \ BME280_NUM_HUMIDITY_BYTES) =20 +#define BME280_NUM_MAX_CHANNELS 3 /* Core exported structs */ =20 static const char *const bmp280_supply_names[] =3D { @@ -419,7 +420,8 @@ struct bmp280_data { * Data to push to userspace triggered buffer. Up to 3 channels and * s64 timestamp, aligned. */ - s32 sensor_data[6] __aligned(8); + u8 sensor_data[ALIGN(sizeof(s32) * BME280_NUM_MAX_CHANNELS, sizeof(s64)) + + sizeof(s64)] __aligned(sizeof(s64)); =20 /* * DMA (thus cache coherency maintenance) may require the --=20 2.25.1