From patchwork Sun Apr 13 10:34:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049266 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 017382AD3E for ; Sun, 13 Apr 2025 10:34:58 +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=1744540499; cv=none; b=bSwvWd3orybC5EUXML5ToemHwJjBC7hs4rSNdbjX27954Svdat9PAqe5dFgunOO7L+G6CP6Smb+chGlO9oQtzHlFkvCCWCf+vyIbl7HlasP2Dnvqa2bTNjczqMWuHkE1Ev8xLkk12rKWziB0fGj6moZ/uVOCAjz5hjgdZiLX5y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540499; c=relaxed/simple; bh=svSnJ73O7+2+ZFRUy7Ep2cyvVHFCuDBl/x9QMmlIRco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TlSvS/31873vBmNrAC/isuIwuxV5tgB+fQckLhSffMdNkL8yPBznH2FBxdVa1Clgm8tSUsmEXrIw1CGJ58J1aURq16C3+bvJTcosgme1nic9vn7VAM7zUoBrja/ljAyAUR6Ak72Nku7A9zILQuK3hqb6BjpdzC3FRM4c0BI/b/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cqNGk24u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cqNGk24u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3481EC4CEEA; Sun, 13 Apr 2025 10:34:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540498; bh=svSnJ73O7+2+ZFRUy7Ep2cyvVHFCuDBl/x9QMmlIRco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cqNGk24uXppZGYElbpxu/1/wunclD46zc9HKgARdwI9KQ/4hlpCWoKrgUZXt6rOft l2+dBQCH0xdEDVXqr+IO+BoDD02ACRrzb79F0qn+15nLgdd8X2ih/izGNjFq5zO8+B Lqa5ew4gam7szgj12nW74Em9/DXMVwMzdR3mkZsF1S7xdmZzcKChxjcCpTElZpusP7 YtdL3mOHiljfmh/zHWRDFt0KsEOPJ77ayDH9gzRljEY3GSvwioinPOcbm/0WrKD0qK 3If1MK/zeio+GDRFoYwHDCtv3oC/DNqhTTDkQMX2OZAGFpzRoeJi3RiJV6w0ld8L1o /NDFHi5BDIHhA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 01/20] iio: adc: ad7266: Fix potential timestamp alignment issue. Date: Sun, 13 Apr 2025 11:34:24 +0100 Message-ID: <20250413103443.2420727-2-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron On architectures where an s64 is only 32-bit aligned insufficient padding would be left between the earlier elements and the timestamp. Use aligned_s64 to enforce the correct placement and ensure the storage is large enough. Fixes: 54e018da3141 ("iio:ad7266: Mark transfer buffer as __be16") # aligned_s64 is much newer. Reported-by: David Lechner Reviewed-by: Nuno Sá Signed-off-by: Jonathan Cameron --- v3: Improved commit message (Andy) --- drivers/iio/adc/ad7266.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index 18559757f908..7fef2727f89e 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -45,7 +45,7 @@ struct ad7266_state { */ struct { __be16 sample[2]; - s64 timestamp; + aligned_s64 timestamp; } data __aligned(IIO_DMA_MINALIGN); }; From patchwork Sun Apr 13 10:34:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049267 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 5CFEF2AD3E for ; Sun, 13 Apr 2025 10:35:00 +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=1744540501; cv=none; b=R52fHbjFJRs2eVVZmZm66cPeC7juD2s44u9JwdmPr553+nThjd9bdNWX4OCmPBhInvV2ZaLKeq17qyFSh3FnNAH1a8++SBt2J93EXG6B5nabEB6ekPl5UFhUkMgQg38ub6d3fS8QUWn+yz4/GWpv9x68Q/Cj5z/VcOT+iG2tFKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540501; c=relaxed/simple; bh=m2uSxOCpL7j4XeB9IwdsCSvOtRV0abSUwlbpxi5idwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cr4eCYK5Bjdy72TVjUTsba4F9I5jo2GsJMjKC1VLvFZSJYPtGSHmi2EHWYgNmA721Qh+jfEEuWAF4pUUnAwZykI0rKFq/T6u+8Vh/w2OohztpHqGdLHf6E43TbJ2aBwZPX1UoUM0ODJcRm2C2GEfo1bjkpmdEq5DYNrgHcdJgLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tPRdqdrT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tPRdqdrT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13463C4CEDD; Sun, 13 Apr 2025 10:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540500; bh=m2uSxOCpL7j4XeB9IwdsCSvOtRV0abSUwlbpxi5idwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPRdqdrTNa3cqQat+1tnLxucGuI9UZdlXipZ5incIs6LlqoUhE1/QF0PlOYVii/J/ xLzpDpwZl4/6CvJvleF8/b8ZTqVkAG+h0FBxBjW0Fb0ISPIYCrknvTT/HVi5bgzJyl /JAAvA8B7IfUGdi47HJs+nCzxtrHqKvN9f2VGGGNIqeY0Udgx9T3OcYYTunailqQS3 I0loa+VZbSZtAed6+MwhLNTLPs7mc3GJFNyr+5gOtWkcB6LyO3zgj7JjbLAGiFdNSJ p2b5OTKImI/LtKU+uK/Lr1ig8ld9pDRrSYYnVQorCGWtskf0j4KbIR7rRp7w98Kesr lcOwKgTZan//A== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 02/20] iio: adc: ad7768-1: Fix insufficient alignment of timestamp. Date: Sun, 13 Apr 2025 11:34:25 +0100 Message-ID: <20250413103443.2420727-3-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron On architectures where an s64 is not 64-bit aligned, this may result insufficient alignment of the timestamp and the structure being too small. Use aligned_s64 to force the alignment. Fixes: a1caeebab07e ("iio: adc: ad7768-1: Fix too small buffer passed to iio_push_to_buffers_with_timestamp()") # aligned_s64 newer Reported-by: David Lechner Reviewed-by: Nuno Sá Signed-off-by: Jonathan Cameron --- v3: 64-bit in commit message (Andy) --- drivers/iio/adc/ad7768-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 09e4ab76e2b6..50dee37d4b08 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -172,7 +172,7 @@ struct ad7768_state { union { struct { __be32 chan; - s64 timestamp; + aligned_s64 timestamp; } scan; __be32 d32; u8 d8[2]; From patchwork Sun Apr 13 10:34:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049268 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 DFBD22AD3E for ; Sun, 13 Apr 2025 10:35:02 +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=1744540503; cv=none; b=hOd32RxDaT+oBT2DDXbBwF3YMmEua7kt3By/nU1QvvSSjrFEbrNYP+gWR7A9CT8wLUkqPmXo7i5tRhmtSDGHChuOSzMQR9rn+iFaGkiz6iOmRxFPC9B1+PI1fSEoJJ68JXFAn4qng80qjuGlDPyD7uxL04YLBgR7yGrs/+RdE3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540503; c=relaxed/simple; bh=sAaG4defa1B+hGxK3KsmnOZtHKqZuDffagtj/moxLEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q0NRbtmPHLhNYvH63Krn2AnoBrhq2JjgtK38ekT2r1D9lIo05Oe/09z5pkJqTz3P+ENVX1l5ib2V19JgfEezNLqKTVbahYRijBGfjaV4ZaJAQhtfU1D84+biEv90pA01ooUJVhwoEdfDnu5plM6FS3DyqVKqUg0f0IFOBsvN6Ws= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LeWyWf2a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LeWyWf2a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4395AC4CEEA; Sun, 13 Apr 2025 10:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540502; bh=sAaG4defa1B+hGxK3KsmnOZtHKqZuDffagtj/moxLEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LeWyWf2as5xkeZDiqCzCV9iC+TWQMyJnJG9fmqmBWbzN1Y6afH1g2gnNnVBjs1h08 c3VH1F9u2+i1SQ6P6xG+Y5Wx49GkDm1FgosZLLlV3XbvUASFEhADZMFF5+YzB9nSSv aQ5otkuz0K4HPM38piFaOjOU29DgduM0HQEyfidIh4u5rUNK3T1MxeJ68Af6EUs7CY hZ/eNrsFtiERXpHCPS0sNxCFVWRyOJZE5/C1j31Pv43N04VqnlQ1OJdloG0B3QQNQZ cDUFT7o85ETobC6oGB5GDpWnoSu2cpf/fgTk77LLjYlu1cT0ALrUIVhsHb8U2MCTZN lRqtVivHwfqIA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 03/20] iio: adc: dln2: Use aligned_s64 for timestamp Date: Sun, 13 Apr 2025 11:34:26 +0100 Message-ID: <20250413103443.2420727-4-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Here the lack of marking allows the overall structure to not be sufficiently aligned resulting in misplacement of the timestamp in iio_push_to_buffers_with_timestamp(). Use aligned_s64 to force the alignment on all architectures. Reported-by: David Lechner Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/adc/dln2-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c index a1e48a756a7b..359e26e3f5bc 100644 --- a/drivers/iio/adc/dln2-adc.c +++ b/drivers/iio/adc/dln2-adc.c @@ -466,7 +466,7 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct { __le16 values[DLN2_ADC_MAX_CHANNELS]; - int64_t timestamp_space; + aligned_s64 timestamp_space; } data; struct dln2_adc_get_all_vals dev_data; struct dln2_adc *dln2 = iio_priv(indio_dev); From patchwork Sun Apr 13 10:34:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049269 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 82AFE2AD3E for ; Sun, 13 Apr 2025 10:35:05 +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=1744540505; cv=none; b=DMPqHgNt+tMDWvViE9cWEmbLDMAYP4ftr7ou32Nmz1IkxfZzKmrMMfapQCARdaB2boLyz72OUoC/6ykMczzVJ4lIb/yxrVQCZ8wNMo5kaZlB2dr0T4f+nlP+mffKV0lmbgM+GKZi3DDeawmsQztiwhrk6W939bbiXxRqXxpvhlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540505; c=relaxed/simple; bh=yzWI3D1EHxTcehBtBHTfo4+WqmM2zvl/N/j64Ca+kqQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mCLqW5SyHLiN3jTHHC/lbmUsAUisUTXGyOEsfkvzX5OYE5x1Y+SWYKPIkYiMWj7Mkzz/W91wwPasoCmjsW8bA4tH82TDZnw+yE6V77v7KuGaNMo0lIjpN5aBuzhwKsCbTMuWacuWxiB3u6TVDlXEXyKqSGRvOr7VbOcHwFwg9rQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o0ttk5ci; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o0ttk5ci" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE2A3C4CEDD; Sun, 13 Apr 2025 10:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540505; bh=yzWI3D1EHxTcehBtBHTfo4+WqmM2zvl/N/j64Ca+kqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o0ttk5ciWyYJrFOzzS3wS67rmJ6f0KmDEHTIjjiDedigSgHLKQIukh453icQLvlY+ 0iWxsN0HTDTz84QdKn9TDhRRa1NUZmY9bK+RzqyX2SxjABEHSzq7F1/ofrDsyUbuEQ iJb9/HmCx5yfG+0ibHH+Z8I7nj/UMTkSRBlaTF1LEkAkPSyHjJwbT5egosOaG7PXkc alDyshjyl9zJOwTBXqdYOtNxDjNBZ5vRbAzbzaGGjcOgTKCSQ+k9G6eFhNe4PClDZR l/qjem1fBM8OXvmAVPgRr08iAcvDMzlvOsRtAGddCsbu/fxnaxHvM+pa2YNfT0EVe5 QKuouRgMlAWBg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 04/20] iio: accel: adxl355: Make timestamp 64-bit aligned using aligned_s64 Date: Sun, 13 Apr 2025 11:34:27 +0100 Message-ID: <20250413103443.2420727-5-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron The IIO ABI requires 64-bit aligned timestamps. In this case insufficient padding would have been added on architectures where an s64 is only 32-bit aligned. Use aligned_s64 to enforce the correct alignment. Fixes: 327a0eaf19d5 ("iio: accel: adxl355: Add triggered buffer support") Reported-by: David Lechner Reviewed-by: Nuno Sá Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl355_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/adxl355_core.c b/drivers/iio/accel/adxl355_core.c index e8cd21fa77a6..cbac622ef821 100644 --- a/drivers/iio/accel/adxl355_core.c +++ b/drivers/iio/accel/adxl355_core.c @@ -231,7 +231,7 @@ struct adxl355_data { u8 transf_buf[3]; struct { u8 buf[14]; - s64 ts; + aligned_s64 ts; } buffer; } __aligned(IIO_DMA_MINALIGN); }; From patchwork Sun Apr 13 10:34:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049270 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 748D32AD3E for ; Sun, 13 Apr 2025 10:35:07 +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=1744540507; cv=none; b=PD2THS8Cn9yuQr7W0/uebI/nbVO2lBYTt2UV8wvSM/M16fQthSPaRxcolNXjP7MWN2j+koNj6Lz6gOF9ZpSlzZRuxXK2jpSEy9ZlPJLOiqNygi547W9TAr0EZ2U7aTGbrwuUUPZZ1peabRuhuOdYAtRd0Xk4pRI/PoNjzCu1AUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540507; c=relaxed/simple; bh=a5SVTYnZmk+/a6ZCAwSH/vhLhQo2QYaGNjqSou2BsdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KDw9P2pEZz3o+R8bb6l03OJoFKAYGno9at3/LvhYES3JDH1fLCK6YWmZbFdZWWjZrWJvp5P8rbMlgWvXryPOU2FavFvsviKXSYJHdfX3IfirY6VIJL1QOROnWJ1rylDyEgKql1X+MUWZ18jTm2OroqjOe5ynrYpiMGxehqyjCVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Yt80Nq9G; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Yt80Nq9G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B3D4C4CEEA; Sun, 13 Apr 2025 10:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540507; bh=a5SVTYnZmk+/a6ZCAwSH/vhLhQo2QYaGNjqSou2BsdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yt80Nq9GCKz2alFK9YprUzDavanzJ56+C0rPNTlXFFpU0KcGuRIjm+h+sHiXCY3Kk 2xqlg7vwDe8Q367ONZXrXu3CeZ7L0nPRcQk0OcfJF0jp9gdnEhUMfpzGQ8nokyvi6e IKCGdUWUdL7HwEVwtdlr2M0c3tNbWPxtSXw15Lvc2XwYxa1mU8t5QwwllgLMQ9ocaX H2zhoXdPL1oZP3F1V6ZFt9nSaUtT4ALQn02H/Zgu0gnxlTPJ10359uqACvJiX7VFr2 u6pWXcmnN8IDzU2V+gb7eKL+1qgl8FHOrMpuYQbmKRdId6SRnrvKEKekPRjA4wxda3 QVPjjqKwdHHkA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 05/20] iio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument. Date: Sun, 13 Apr 2025 11:34:28 +0100 Message-ID: <20250413103443.2420727-6-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Check that data_total_len argument against iio_dev->scan_bytes. The size needs to be at least as big as the scan. It can be larger, which is typical if only part of fixed sized storage is used due to a subset of channels being enabled. Reviewed-by: Nuno Sá Signed-off-by: Jonathan Cameron --- v3: - Use an s64 instead of int64_t for the new function (Andy) v2: - Rename size to data_total_len to make it clear that it is about data but also that it isn't simply the length to be used. - Added an unlikely marking. --- include/linux/iio/buffer.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h index 3b8d618bb3df..5c84ec4a9810 100644 --- a/include/linux/iio/buffer.h +++ b/include/linux/iio/buffer.h @@ -45,6 +45,18 @@ static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev, return iio_push_to_buffers(indio_dev, data); } +static inline int iio_push_to_buffers_with_ts(struct iio_dev *indio_dev, + void *data, size_t data_total_len, + s64 timestamp) +{ + if (unlikely(data_total_len < indio_dev->scan_bytes)) { + dev_err(&indio_dev->dev, "Undersized storage pushed to buffer\n"); + return -ENOSPC; + } + + return iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); +} + int iio_push_to_buffers_with_ts_unaligned(struct iio_dev *indio_dev, const void *data, size_t data_sz, int64_t timestamp); From patchwork Sun Apr 13 10:34:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049271 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 8E55D2AD3E for ; Sun, 13 Apr 2025 10:35:10 +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=1744540511; cv=none; b=S/HxqK4nrWATwamFcDktv1EqusC3NZr8pNZZpcP7CRft9fFPohFV0VrrQ9EO0/TokIfICO5OmZ8MffF2hCq9lJPRnnPQX+hryiatysLQOnkQwbacwkGDXzdNJCvuz7q7EnQORVGEO5vULp/N5k5gcrsBde/qQa/MGxsCgfBE9DI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540511; c=relaxed/simple; bh=BG9j6HsC0SVSUTBxX5PF6A6X3155QTT/ZSVHI4PZbZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AuwZWbKTD4EHhG82tq/FJzy+Q82qHjDKNXkH/0rLg6RxFpqzZALsCOaOsdhmFBYh9hOD6NSDRVgShOUxA/skYtn4/CfNeDqZM5Xq7cLWqWz0AG4d6rK3hZuFth5DV3sCL446Sx5ngR/nN5hi6M0srPHiDBnIVNaJCFYmunHy6BM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eA8DbrcW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eA8DbrcW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16E69C4CEEA; Sun, 13 Apr 2025 10:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540510; bh=BG9j6HsC0SVSUTBxX5PF6A6X3155QTT/ZSVHI4PZbZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eA8DbrcWkYv+OsMk4Dznz6fFakn7/1+rVyDKIOzzeDYL2Ryuzlyf10Ay+sSRWnJ+J i4OBvWwchAAcaoAp9KaJ4GYGp8BzRancll9luaswpkMITdc4eZIsvylfl2jMudGfv3 fT0PzzE24FL2pAfod7vscpyVYMsrgXJ6fA8koyGBj4D+F4VufSFe8rLuoGxb0Gp6AW zBYaxGeyRe4d0A9Z7aZ2AgHlYDfwEUh0tEKHllZJouzboXuLDQMKjOgVk83D9TND2P EKhbuIE73+WT8JxmR7d523sAqPh3OYhe5kAD9/3o/Djfini8w5He951iuQNXu4wOeO V5kxvORRaFkjg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 06/20] iio: dummy: Use a fixed structure to build up scan to push to buffers. Date: Sun, 13 Apr 2025 11:34:29 +0100 Message-ID: <20250413103443.2420727-7-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron It has long been discouraged for drivers to make use of iio_dev->scan_bytes directly as that is an implementation detail of the core. As such our example driver should definitely not be doing so. In order to illustrate the more complex case, where a DMA safe buffer is needed, continue to kzalloc() the storage (but with a structure definition to provide an explicit data layout). Also add comments on when a DMA safe buffer is necessary and the two common ways of obtaining one. Whilst we have a mixture of signed and unsigned channels, the unsigned channels have ranges that can be stored in a signed value - hence use signed storage for all channels, simplifying the structure definition. Signed-off-by: Jonathan Cameron --- v3: Go back to kzalloc but with a structure definition. (Andy) v2: Add a comment about stack buffers not being DMA safe. --- drivers/iio/dummy/iio_simple_dummy_buffer.c | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c index 288880346707..d0a7343e1b35 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -31,6 +31,11 @@ static const s16 fakedata[] = { [DUMMY_INDEX_ACCELX] = 344, }; +struct dummy_scan { + s16 data[ARRAY_SIZE(fakedata)]; + aligned_s64 timestamp; +}; + /** * iio_simple_dummy_trigger_h() - the trigger handler function * @irq: the interrupt number @@ -45,11 +50,18 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; + struct dummy_scan *scan; int i = 0, j; - u16 *data; - data = kzalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (!data) + /* + * Note that some buses such as SPI require DMA safe buffers which + * cannot be on the stack. Two easy ways to do this: + * - Local kzalloc (as done here) + * - A buffer at the end of the structure accessed via iio_priv() + * that is marked __aligned(IIO_DMA_MINALIGN). + */ + scan = kzalloc(sizeof(*scan), GFP_KERNEL); + if (!scan) goto done; /* @@ -69,13 +81,12 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) * constant table fakedata. */ iio_for_each_active_channel(indio_dev, j) - data[i++] = fakedata[j]; + scan->data[i++] = fakedata[j]; - iio_push_to_buffers_with_timestamp(indio_dev, data, + iio_push_to_buffers_with_timestamp(indio_dev, scan, iio_get_time_ns(indio_dev)); - kfree(data); - + kfree(scan); done: /* * Tell the core we are done with this trigger and ready for the From patchwork Sun Apr 13 10:34:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049272 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 082AA2AD3E for ; Sun, 13 Apr 2025 10:35:13 +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=1744540513; cv=none; b=DjOdFHeeroJhe6nlO5JJ2kS+XAMBJyK+lqgnmEMmY0zcvmRJm0VzaewnYiX48P46vm9IaAD8PdW+iVc0iQ/+u0G3o4RrXpvBEuTRwe4OWMQ4AeeSrYcAJ/GQB/B+IWAin6ZD955YrWq4HCNthcIrD3ljKwQMjsLi5Cl29v6wLOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540513; c=relaxed/simple; bh=SgZyGUJuQEdf1UndClsPKF0Kjv02T+l2y0oSN6uEi4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pxG5t1eROE776gUZDK5Cl2lM7eZxq5Le7HI2OaGVxbBtjB2O0aOTYIfssMZQcUXHJ3cuPtrFCLNOBti6XAAfQpSY8AWyVsvZDHBqdAvd+U1pX8VA+k6EXjsZ8Jnjl8HZTszTJCyhvGp74X458Vx0Lla5Vg14l8y0nIVZ9SlTerU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SJnUHSOe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SJnUHSOe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B89A2C4CEEB; Sun, 13 Apr 2025 10:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540512; bh=SgZyGUJuQEdf1UndClsPKF0Kjv02T+l2y0oSN6uEi4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SJnUHSOemdMSuHVyDjG0wROniuR9FfU6j0WZO4BKScwiJiwTGKRxSoy0drnMHRzAM /rUaYQtjlpplty3iOFz+89DfbYfik00zLMo+S9pGDjaEIYfNMwbg1zIhj/fzxS5hlt 0Xpa1ztAOkTdNpB20D7zNUDSY5uCI6SMMj6M/inqoZ9zPZCeKCShykGkiqpXpZAKoG zLGOJ847q4m0Rzi4iGnb5yW+kbT+VVPIyK0TIPB9aGO5fkEBwOCLwZoifynmzkEwey /zHdEbbpj65rw8hrydoaBio0f0dk2wKDbeKbWJp+xJ0K2/5rJQkNUO9vi09xpK2AWJ dAwbiHlooA3cA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 07/20] iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage Date: Sun, 13 Apr 2025 11:34:30 +0100 Message-ID: <20250413103443.2420727-8-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Provide the storage size so that the helper can sanity check that it is large enough for the configured channels. Reviewed-by: Nuno Sá Signed-off-by: Jonathan Cameron --- v3: Updates due to change in previous patch. --- drivers/iio/dummy/iio_simple_dummy_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c index d0a7343e1b35..e35e0596cbfb 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -83,8 +83,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) iio_for_each_active_channel(indio_dev, j) scan->data[i++] = fakedata[j]; - iio_push_to_buffers_with_timestamp(indio_dev, scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, scan, sizeof(*scan), + iio_get_time_ns(indio_dev)); kfree(scan); done: From patchwork Sun Apr 13 10:34:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049273 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 A64B82AD3E for ; Sun, 13 Apr 2025 10:35:16 +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=1744540516; cv=none; b=Yom0kkOsoOhSNdetNfEgQztXp1pblOTYdRoq5N6uCR4SaqNZ8siUlYxltsZKhvayPkb3D4qRcwRh/LH9YpdpIwDMEmHqqrx7Y3BtXfJZkN2d+IsjO1acnGKC2GohoanK1nybGwRjl8wgN7VPVT+qu+8ZQTzPh7hycD0oe4UZxYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540516; c=relaxed/simple; bh=rMXZ8ICeBbnBHe4LEzOrD8YzqeEgPdRK27vo0ZwYJnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qo5vSAQO9fHOMLXbBiP34uwd7zYMNesI5LLz1b+TVaew35wrOJ9/B4GfXi5TcfsMG/ANxdidnqg2XEBUJ8QlVGXCZ0BaFT6bef+66Zt9yo8peE9n8UvxkUTcfVIRRmiS5bKCcdAwkT3/lUD01D9oxMMEIRWRLc56mCY2zum+TY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=larASdXc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="larASdXc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFD1BC4CEEA; Sun, 13 Apr 2025 10:35:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540516; bh=rMXZ8ICeBbnBHe4LEzOrD8YzqeEgPdRK27vo0ZwYJnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=larASdXcqQJYBgp0elqhIQNdIyEAij1rpT8zo6tI8YkR7XTsFdQztQ4jpRxEPgA3L J10n4NnZJoXJXMfaMNFQjMB0Ij4emIF9Iu+6rm/qsm/l8smF+SdsnWsf0G3CSmU8Gw UANZrap2LV460iakBgjG5Mu4Vhh9y8hzKHlB7JvKGJhaJai1jSFbvW08BeIx7A3JsW RTZWqcunAe20n9CiDcNmeeJKwafWzj8UrSiiaBTiaITbfLZJV2kVeBVWHHkrCtD8OE UuIo3Jfot8W1IgLZoq1iaSSm+pkk+OPZurMyb6gJD1dcD7Mvy74uTKolpR7O/ajQL0 suP0AH/mpOYdQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 08/20] iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check. Date: Sun, 13 Apr 2025 11:34:31 +0100 Message-ID: <20250413103443.2420727-9-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron By providing the size of the buffer used, runtime checks can be performed to ensure not overrun. Also change the pushed data pointer to be that of the structure that also contains the timestamp. Not an actual bug but semantically incorrect to push the channel data when we want the storage with the timestamp as well. Reviewed-by: David Lechner Signed-off-by: Jonathan Cameron --- v3: Line wrap tweak (Andy) --- drivers/iio/adc/ti-ads131e08.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c index c6096b64664e..085f0d6fb39e 100644 --- a/drivers/iio/adc/ti-ads131e08.c +++ b/drivers/iio/adc/ti-ads131e08.c @@ -664,8 +664,8 @@ static irqreturn_t ads131e08_trigger_handler(int irq, void *private) i++; } - iio_push_to_buffers_with_timestamp(indio_dev, st->tmp_buf.data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &st->tmp_buf, sizeof(st->tmp_buf), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); From patchwork Sun Apr 13 10:34:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049274 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 3608919DF5F for ; Sun, 13 Apr 2025 10:35:19 +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=1744540519; cv=none; b=sgI/H8vNV4aZUIQ7nv7nkIn7V858CL8Ee15O0rVQNiEfJf5fAJ2EcMebz5g+2Dkt03ILCxfv7AZjMMiACEOfo3WugzNAqIrO8SAqIL3+xXYr+Uwvj/nyL/l5LRmY9aSgy1mD3et0/F3MOZ9ElHj58DRbxVPbuMuhiOCllPCdw/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540519; c=relaxed/simple; bh=i6hzosEBfC5ImuMF3CYKLxATS0Pj915p8V+eG95LQT0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nk4rBtWSd738CWUttWceM5QAhM4wMvHL1YGLAUzmw+wpMnN98lAn3k0K+oYVHOy+oFl//A+jsiH8bVbeknCHOW9rcvUD9hqeHlVHSE9lNqzyUbKeYLAKNpA2X6XY2rHbwQK3g4ZL7BxvvM10cYI0aCtJulZ+gH/EpVm24NV7MJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GxeEAb0B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GxeEAb0B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBC43C4CEEA; Sun, 13 Apr 2025 10:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540519; bh=i6hzosEBfC5ImuMF3CYKLxATS0Pj915p8V+eG95LQT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxeEAb0B/ZD38w+lveWNqQzgzF+tVqVAE4U9GYnQ9YcbFJ5lzwa3lD6DRD4LBecsu QTfqWXjoYgbcUFiQHtRqDtKmBtG+tuzw8atoOtbIoTzWn8fa/LZuqVInJrQp9iD0jO UBDfVmwleAS3gjjDVor5dyjvHnFoYgylqgRXyoWurpSa7pugrXARcvoBVQDfpTppEm uWfrumaJDlcdMJqaiSHPKLlsukeRU3prPkq29qwYDXeBI5Uq+XIcnnvfzy4i8HAZjR 9q7gWSK6jPLtKrj3+rJFP6fONVrahFCffn+PXNMwKuA/oRLoTaa3fV+xxLNhoDCPBQ Nr3+X008H+71Q== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 09/20] iio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:32 +0100 Message-ID: <20250413103443.2420727-10-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- v3: - White space tweaks (Andy) v2: - ad4030, use &st->rx_data rather than st->rx_data.raw. Given that is the largest element of the union it isn't a bug, but the available space is more obvious if we use the whole union. --- drivers/iio/adc/ad4000.c | 3 ++- drivers/iio/adc/ad4030.c | 4 ++-- drivers/iio/adc/ad4695.c | 3 ++- drivers/iio/adc/ad7266.c | 7 +++---- drivers/iio/adc/ad7298.c | 4 ++-- drivers/iio/adc/ad7380.c | 4 ++-- drivers/iio/adc/ad7476.c | 4 ++-- drivers/iio/adc/ad7606.c | 4 ++-- drivers/iio/adc/ad7768-1.c | 5 +++-- drivers/iio/adc/ad7779.c | 3 ++- drivers/iio/adc/ad7923.c | 4 ++-- drivers/iio/adc/dln2-adc.c | 4 ++-- drivers/iio/adc/ina2xx-adc.c | 2 +- drivers/iio/adc/max1118.c | 4 ++-- drivers/iio/adc/max11410.c | 4 ++-- drivers/iio/adc/max1363.c | 4 ++-- drivers/iio/adc/mcp3911.c | 4 ++-- drivers/iio/adc/mxs-lradc-adc.c | 3 ++- drivers/iio/adc/pac1921.c | 3 ++- drivers/iio/adc/rockchip_saradc.c | 3 ++- drivers/iio/adc/rtq6056.c | 3 ++- drivers/iio/adc/stm32-adc.c | 4 ++-- drivers/iio/adc/ti-adc081c.c | 4 ++-- drivers/iio/adc/ti-adc0832.c | 4 ++-- drivers/iio/adc/ti-adc084s021.c | 4 ++-- drivers/iio/adc/ti-adc12138.c | 4 ++-- drivers/iio/adc/ti-ads1015.c | 4 ++-- drivers/iio/adc/ti-ads1119.c | 4 ++-- drivers/iio/adc/ti-ads124s08.c | 4 ++-- drivers/iio/adc/ti-ads8688.c | 4 ++-- drivers/iio/adc/ti-lmp92064.c | 4 ++-- drivers/iio/adc/ti-tlc4541.c | 4 ++-- drivers/iio/adc/ti-tsc2046.c | 5 +++-- drivers/iio/adc/vf610_adc.c | 6 +++--- 34 files changed, 71 insertions(+), 63 deletions(-) diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c index e69a9d2a3e8c..93ecaf401f27 100644 --- a/drivers/iio/adc/ad4000.c +++ b/drivers/iio/adc/ad4000.c @@ -793,7 +793,8 @@ static irqreturn_t ad4000_trigger_handler(int irq, void *p) if (ret < 0) goto err_out; - iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan), + pf->timestamp); err_out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c index 636f9f33e66a..5aa26dc3a2ce 100644 --- a/drivers/iio/adc/ad4030.c +++ b/drivers/iio/adc/ad4030.c @@ -707,8 +707,8 @@ static irqreturn_t ad4030_trigger_handler(int irq, void *p) if (ret) goto out; - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_data.raw, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &st->rx_data, sizeof(st->rx_data), + pf->timestamp); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad4695.c b/drivers/iio/adc/ad4695.c index 8222c8ab2940..68c6625db0d7 100644 --- a/drivers/iio/adc/ad4695.c +++ b/drivers/iio/adc/ad4695.c @@ -801,7 +801,8 @@ static irqreturn_t ad4695_trigger_handler(int irq, void *p) if (ret) goto out; - iio_push_to_buffers_with_timestamp(indio_dev, st->buf, pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, st->buf, sizeof(st->buf), + pf->timestamp); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index 7fef2727f89e..3364ac6c4631 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -86,10 +86,9 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p) int ret; ret = spi_read(st->spi, st->data.sample, 4); - if (ret == 0) { - iio_push_to_buffers_with_timestamp(indio_dev, &st->data, - pf->timestamp); - } + if (ret == 0) + iio_push_to_buffers_with_ts(indio_dev, &st->data, sizeof(st->data), + pf->timestamp); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 28b88092b4aa..7c0538ea15c8 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -155,8 +155,8 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p) if (b_sent) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, st->rx_buf, sizeof(st->rx_buf), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c index 190ab411739f..f93e6c67766a 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -1361,8 +1361,8 @@ static irqreturn_t ad7380_trigger_handler(int irq, void *p) if (ret) goto out; - iio_push_to_buffers_with_timestamp(indio_dev, &st->scan_data, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &st->scan_data, sizeof(st->scan_data), + pf->timestamp); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 37b0515cf4fc..ddb607ac1860 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -99,8 +99,8 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p) if (b_sent < 0) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, st->data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, st->data, sizeof(st->data), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index d36b2e212a08..aa96247d6757 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -605,8 +605,8 @@ static irqreturn_t ad7606_trigger_handler(int irq, void *p) if (ret) goto error_ret; - iio_push_to_buffers_with_timestamp(indio_dev, &st->data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &st->data, sizeof(st->data), + iio_get_time_ns(indio_dev)); error_ret: iio_trigger_notify_done(indio_dev->trig); /* The rising edge of the CONVST signal starts a new conversion. */ diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 50dee37d4b08..baa2d5440185 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -533,8 +533,9 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p) if (ret < 0) goto out; - iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &st->data.scan, + sizeof(st->data.scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c index a5d87faa5e12..845adc510239 100644 --- a/drivers/iio/adc/ad7779.c +++ b/drivers/iio/adc/ad7779.c @@ -595,7 +595,8 @@ static irqreturn_t ad7779_trigger_handler(int irq, void *p) goto exit_handler; } - iio_push_to_buffers_with_timestamp(indio_dev, &st->data, pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &st->data, sizeof(st->data), + pf->timestamp); exit_handler: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 87945efb940b..0369151c7db1 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -207,8 +207,8 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p) if (b_sent) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, st->rx_buf, sizeof(st->rx_buf), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c index 359e26e3f5bc..9dbd2c87938c 100644 --- a/drivers/iio/adc/dln2-adc.c +++ b/drivers/iio/adc/dln2-adc.c @@ -488,8 +488,8 @@ static irqreturn_t dln2_adc_trigger_h(int irq, void *p) (void *)dev_data.values + t->from, t->length); } - iio_push_to_buffers_with_timestamp(indio_dev, &data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data, sizeof(data), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index 40d14faa71c5..857e1b69d6cd 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -766,7 +766,7 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev) chip->scan.chan[i++] = val; } - iio_push_to_buffers_with_timestamp(indio_dev, &chip->scan, time); + iio_push_to_buffers_with_ts(indio_dev, &chip->scan, sizeof(chip->scan), time); return 0; }; diff --git a/drivers/iio/adc/max1118.c b/drivers/iio/adc/max1118.c index 565ca2e21c0c..7d7001e8e3d9 100644 --- a/drivers/iio/adc/max1118.c +++ b/drivers/iio/adc/max1118.c @@ -188,8 +188,8 @@ static irqreturn_t max1118_trigger_handler(int irq, void *p) adc->scan.channels[i] = ret; i++; } - iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &adc->scan, sizeof(adc->scan), + iio_get_time_ns(indio_dev)); out: mutex_unlock(&adc->lock); diff --git a/drivers/iio/adc/max11410.c b/drivers/iio/adc/max11410.c index 437d9f24b5a1..511b2f14dfaf 100644 --- a/drivers/iio/adc/max11410.c +++ b/drivers/iio/adc/max11410.c @@ -632,8 +632,8 @@ static irqreturn_t max11410_trigger_handler(int irq, void *p) goto out; } - iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index d0546c681625..a7e9912fb44a 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1498,8 +1498,8 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p) if (b_sent < 0) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, &st->data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &st->data, sizeof(st->data), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c index 6748b44d568d..be18635ae616 100644 --- a/drivers/iio/adc/mcp3911.c +++ b/drivers/iio/adc/mcp3911.c @@ -516,8 +516,8 @@ static irqreturn_t mcp3911_trigger_handler(int irq, void *p) adc->scan.channels[i] = get_unaligned_be24(&adc->rx_buf[scan_chan->channel * 3]); i++; } - iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &adc->scan, sizeof(adc->scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c index 8f1e6acea53b..92baf3f5f560 100644 --- a/drivers/iio/adc/mxs-lradc-adc.c +++ b/drivers/iio/adc/mxs-lradc-adc.c @@ -425,7 +425,8 @@ static irqreturn_t mxs_lradc_adc_trigger_handler(int irq, void *p) j++; } - iio_push_to_buffers_with_timestamp(iio, adc->buffer, pf->timestamp); + iio_push_to_buffers_with_ts(iio, adc->buffer, sizeof(adc->buffer), + pf->timestamp); iio_trigger_notify_done(iio->trig); diff --git a/drivers/iio/adc/pac1921.c b/drivers/iio/adc/pac1921.c index ef75e9e51c24..72aa4ca2e5a4 100644 --- a/drivers/iio/adc/pac1921.c +++ b/drivers/iio/adc/pac1921.c @@ -1044,7 +1044,8 @@ static irqreturn_t pac1921_trigger_handler(int irq, void *p) priv->scan.chan[ch++] = val; } - iio_push_to_buffers_with_timestamp(idev, &priv->scan, pf->timestamp); + iio_push_to_buffers_with_ts(idev, &priv->scan, sizeof(priv->scan), + pf->timestamp); done: iio_trigger_notify_done(idev->trig); diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index 9a099df79518..2162bff69913 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -425,7 +425,8 @@ static irqreturn_t rockchip_saradc_trigger_handler(int irq, void *p) j++; } - iio_push_to_buffers_with_timestamp(i_dev, &data, iio_get_time_ns(i_dev)); + iio_push_to_buffers_with_ts(i_dev, &data, sizeof(data), + iio_get_time_ns(i_dev)); out: mutex_unlock(&info->lock); diff --git a/drivers/iio/adc/rtq6056.c b/drivers/iio/adc/rtq6056.c index 54239df61d86..6ff47415a222 100644 --- a/drivers/iio/adc/rtq6056.c +++ b/drivers/iio/adc/rtq6056.c @@ -666,7 +666,8 @@ static irqreturn_t rtq6056_buffer_trigger_handler(int irq, void *p) data.vals[i++] = raw; } - iio_push_to_buffers_with_timestamp(indio_dev, &data, iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data, sizeof(data), + iio_get_time_ns(indio_dev)); out: pm_runtime_mark_last_busy(dev); diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 27aec9a18a0f..5159908a2a61 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1858,8 +1858,8 @@ static irqreturn_t stm32_adc_trigger_handler(int irq, void *p) /* reset buffer index */ adc->bufi = 0; - iio_push_to_buffers_with_timestamp(indio_dev, adc->buffer, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, adc->buffer, sizeof(adc->buffer), + pf->timestamp); iio_trigger_notify_done(indio_dev->trig); /* re-enable eoc irq */ diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index 1af9be071d8d..4f514db5c26e 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -140,8 +140,8 @@ static irqreturn_t adc081c_trigger_handler(int irq, void *p) if (ret < 0) goto out; data->scan.channel = ret; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c index e2dbd070c7c4..cfcdafbe284b 100644 --- a/drivers/iio/adc/ti-adc0832.c +++ b/drivers/iio/adc/ti-adc0832.c @@ -225,8 +225,8 @@ static irqreturn_t adc0832_trigger_handler(int irq, void *p) adc->data[i] = ret; i++; } - iio_push_to_buffers_with_timestamp(indio_dev, adc->data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, adc->data, sizeof(adc->data), + iio_get_time_ns(indio_dev)); out: mutex_unlock(&adc->lock); diff --git a/drivers/iio/adc/ti-adc084s021.c b/drivers/iio/adc/ti-adc084s021.c index 9c845ee01697..50a474f4d9f5 100644 --- a/drivers/iio/adc/ti-adc084s021.c +++ b/drivers/iio/adc/ti-adc084s021.c @@ -151,8 +151,8 @@ static irqreturn_t adc084s021_buffer_trigger_handler(int irq, void *pollfunc) if (adc084s021_adc_conversion(adc, adc->scan.channels) < 0) dev_err(&adc->spi->dev, "Failed to read data\n"); - iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &adc->scan, sizeof(adc->scan), + iio_get_time_ns(indio_dev)); mutex_unlock(&adc->lock); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c index 7f065f457b36..9dc465a10ffc 100644 --- a/drivers/iio/adc/ti-adc12138.c +++ b/drivers/iio/adc/ti-adc12138.c @@ -376,8 +376,8 @@ static irqreturn_t adc12138_trigger_handler(int irq, void *p) } } - iio_push_to_buffers_with_timestamp(indio_dev, adc->data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, adc->data, sizeof(adc->data), + iio_get_time_ns(indio_dev)); out: mutex_unlock(&adc->lock); diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 705c146c7dc2..21181cc3bd85 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -467,8 +467,8 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) scan.chan = res; mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, &scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c index f120e7e21cff..d280c949cf47 100644 --- a/drivers/iio/adc/ti-ads1119.c +++ b/drivers/iio/adc/ti-ads1119.c @@ -534,8 +534,8 @@ static irqreturn_t ads1119_trigger_handler(int irq, void *private) scan.sample = ret; - iio_push_to_buffers_with_timestamp(indio_dev, &scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index 77c299bb4ebc..8ea1269f74db 100644 --- a/drivers/iio/adc/ti-ads124s08.c +++ b/drivers/iio/adc/ti-ads124s08.c @@ -297,8 +297,8 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) j++; } - iio_push_to_buffers_with_timestamp(indio_dev, priv->buffer, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, priv->buffer, sizeof(priv->buffer), + pf->timestamp); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c index a31658b760a4..b0bf46cae0b6 100644 --- a/drivers/iio/adc/ti-ads8688.c +++ b/drivers/iio/adc/ti-ads8688.c @@ -389,8 +389,8 @@ static irqreturn_t ads8688_trigger_handler(int irq, void *p) j++; } - iio_push_to_buffers_with_timestamp(indio_dev, buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, buffer, sizeof(buffer), + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ti-lmp92064.c b/drivers/iio/adc/ti-lmp92064.c index 86eef3320de9..3f375c1f586c 100644 --- a/drivers/iio/adc/ti-lmp92064.c +++ b/drivers/iio/adc/ti-lmp92064.c @@ -209,8 +209,8 @@ static irqreturn_t lmp92064_trigger_handler(int irq, void *p) if (ret) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data, sizeof(data), + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ti-tlc4541.c b/drivers/iio/adc/ti-tlc4541.c index 5a138be983ed..f67945c62c99 100644 --- a/drivers/iio/adc/ti-tlc4541.c +++ b/drivers/iio/adc/ti-tlc4541.c @@ -99,8 +99,8 @@ static irqreturn_t tlc4541_trigger_handler(int irq, void *p) if (ret < 0) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, st->rx_buf, sizeof(st->rx_buf), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c index 49560059f4b7..84a9a5e66526 100644 --- a/drivers/iio/adc/ti-tsc2046.c +++ b/drivers/iio/adc/ti-tsc2046.c @@ -418,8 +418,9 @@ static int tsc2046_adc_scan(struct iio_dev *indio_dev) for (group = 0; group < priv->groups; group++) priv->scan_buf.data[group] = tsc2046_adc_get_val(priv, group); - ret = iio_push_to_buffers_with_timestamp(indio_dev, &priv->scan_buf, - iio_get_time_ns(indio_dev)); + ret = iio_push_to_buffers_with_ts(indio_dev, &priv->scan_buf, + sizeof(priv->scan_buf), + iio_get_time_ns(indio_dev)); /* If the consumer is kfifo, we may get a EBUSY here - ignore it. */ if (ret < 0 && ret != -EBUSY) { dev_err_ratelimited(dev, "Failed to push scan buffer %pe\n", diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 805e1973b090..6404b015234a 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -592,9 +592,9 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id) info->value = vf610_adc_read_data(info); if (iio_buffer_enabled(indio_dev)) { info->scan.chan = info->value; - iio_push_to_buffers_with_timestamp(indio_dev, - &info->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &info->scan, + sizeof(info->scan), + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); } else complete(&info->completion); From patchwork Sun Apr 13 10:34:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049275 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 AE3F119D880 for ; Sun, 13 Apr 2025 10:35: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=1744540522; cv=none; b=EHNFUlTTXn8GuNP6IDKRxhH/IqlAfi0JS+Pe3aCUeJmQa04zjf1nfsSUy9O4Vlvy3uMTue53QjHdNogd4pQb9D1+Xba6K+Ws2O6qN5OadQmpyiIxqz3vD9lRdYe3fAm3d2GVB/i+lZnmqJ4aD4Fdugxu5Q18E0DCUvrHlSJcrUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540522; c=relaxed/simple; bh=EUd8/B5OnW6v00Q/S2n0Vu4jeTVNiDvpkap+3whu2Hs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bVWKGf7dj7pUck8wdYRXdaoDcifSAiPyNbzvtszIkgBda3KW7POx6rRBBKERM8LG6aHD2J7QwYTZoMHVBLif7+Lojrlb+5UwBFDuzH5X8Gkgr+J21DRnLBmXEnpuvUjww602LE4F69JyU0WFBbX9vRJA3iVDV54JAGDBKmeANQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lhvG9bhr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lhvG9bhr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAFF2C4CEDD; Sun, 13 Apr 2025 10:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540522; bh=EUd8/B5OnW6v00Q/S2n0Vu4jeTVNiDvpkap+3whu2Hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhvG9bhrKlmUTTipfS1TQbTlo6A684oJg9n+7fePGPu9SpnWAs9maHZRU54S6UAPK VswUHMx5JkYhKKjcbG/5AnuDDg+UzjF6LfDCNX4zq3J23vs9QrLcP1UdK3kk4N9WDH KRSxPv+GiGGQ9nstmRz9FsqhgZFQQI4WMuX6fvqICVv1oAwE+oXhcFtx4y2Rcb2xTa QTlSknmEhjO6G4vkbMjORsIVtuZ2muA5j39WR9ImKcNUzdoUADyWEOs3e9SgvL0EOu g/HewQ3BUu1hATKwiG6jFFspgXbBkb9zuDAvy56b7wHHlomt81ZXZ0iws/3TkOtD0f 1LuN6rkbqSJLA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 10/20] iio: accel: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:33 +0100 Message-ID: <20250413103443.2420727-11-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- v3: White space tweaks (Andy) --- drivers/iio/accel/adxl355_core.c | 4 ++-- drivers/iio/accel/bma180.c | 2 +- drivers/iio/accel/bma220_spi.c | 4 ++-- drivers/iio/accel/bma400_core.c | 5 +++-- drivers/iio/accel/fxls8962af-core.c | 4 ++-- drivers/iio/accel/kxcjk-1013.c | 4 ++-- drivers/iio/accel/kxsd9.c | 5 ++--- drivers/iio/accel/mma7455_core.c | 5 +++-- drivers/iio/accel/mma8452.c | 5 +++-- drivers/iio/accel/msa311.c | 4 ++-- drivers/iio/accel/mxc4005.c | 4 ++-- drivers/iio/accel/sca3300.c | 5 +++-- drivers/iio/accel/stk8312.c | 4 ++-- drivers/iio/accel/stk8ba50.c | 4 ++-- 14 files changed, 31 insertions(+), 28 deletions(-) diff --git a/drivers/iio/accel/adxl355_core.c b/drivers/iio/accel/adxl355_core.c index cbac622ef821..2e00fd51b4d5 100644 --- a/drivers/iio/accel/adxl355_core.c +++ b/drivers/iio/accel/adxl355_core.c @@ -666,8 +666,8 @@ static irqreturn_t adxl355_trigger_handler(int irq, void *p) if (ret) goto out_unlock_notify; - iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, + sizeof(data->buffer), pf->timestamp); out_unlock_notify: mutex_unlock(&data->lock); diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index aa664a923f91..93a868678722 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -887,7 +887,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) mutex_unlock(&data->mutex); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), time_ns); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 978108fb74e9..38f7498431ee 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -103,8 +103,8 @@ static irqreturn_t bma220_trigger_handler(int irq, void *p) if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: mutex_unlock(&data->lock); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c index 23f5e1ce9cc4..85e23badf733 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -1591,8 +1591,9 @@ static irqreturn_t bma400_trigger_handler(int irq, void *p) data->buffer.temperature = temp; } - iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, + sizeof(data->buffer), + iio_get_time_ns(indio_dev)); mutex_unlock(&data->mutex); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c index 48e4282964a0..6d23da3e7aa2 100644 --- a/drivers/iio/accel/fxls8962af-core.c +++ b/drivers/iio/accel/fxls8962af-core.c @@ -983,8 +983,8 @@ static int fxls8962af_fifo_flush(struct iio_dev *indio_dev) sizeof(data->scan.channels[0])); } - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - tstamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, + sizeof(data->scan), tstamp); tstamp += sample_period; } diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index f2496cad8ec2..971b76c98606 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1253,8 +1253,8 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p) if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - data->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + data->timestamp); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index fb14b875e20d..cfc31265cdd0 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -229,9 +229,8 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p) goto out; } - iio_push_to_buffers_with_timestamp(indio_dev, - &hw_values, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &hw_values, sizeof(hw_values), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c index 30746621052c..a2b5bdf14dde 100644 --- a/drivers/iio/accel/mma7455_core.c +++ b/drivers/iio/accel/mma7455_core.c @@ -103,8 +103,9 @@ static irqreturn_t mma7455_trigger_handler(int irq, void *p) if (ret) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, &mma7455->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &mma7455->scan, + sizeof(mma7455->scan), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 05f5482f366e..aba444a980d9 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1103,8 +1103,9 @@ static irqreturn_t mma8452_trigger_handler(int irq, void *p) if (ret < 0) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, + sizeof(data->buffer), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/msa311.c b/drivers/iio/accel/msa311.c index d31c11fbbe68..c31c53abc3d0 100644 --- a/drivers/iio/accel/msa311.c +++ b/drivers/iio/accel/msa311.c @@ -919,8 +919,8 @@ static irqreturn_t msa311_buffer_thread(int irq, void *p) mutex_unlock(&msa311->lock); - iio_push_to_buffers_with_timestamp(indio_dev, &buf, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &buf, sizeof(buf), + iio_get_time_ns(indio_dev)); notify_done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c index c9c4bab08a81..1075c8ce0e37 100644 --- a/drivers/iio/accel/mxc4005.c +++ b/drivers/iio/accel/mxc4005.c @@ -335,8 +335,8 @@ static irqreturn_t mxc4005_trigger_handler(int irq, void *private) if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index 9b00a3d7056d..1132bbaba75b 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -505,8 +505,9 @@ static irqreturn_t sca3300_trigger_handler(int irq, void *p) channels[i++] = val; } - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->buffer, + sizeof(data->buffer), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c index d3ff1287c017..dfac2e44191f 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -460,8 +460,8 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) } mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index e5fed3eac2c8..05d4fd540eb2 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -340,8 +340,8 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p) data->scan.chans[i++] = ret; } } - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: mutex_unlock(&data->lock); iio_trigger_notify_done(indio_dev->trig); From patchwork Sun Apr 13 10:34:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049276 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 534F419D880 for ; Sun, 13 Apr 2025 10:35:24 +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=1744540525; cv=none; b=LuvL3gPo2n9XNTqRAslg08A/KIFdG1aoMdm3iwXrrMLsMEMWYCLzL3kdEx5pB4TllpQbbbbm8UN4JgyPTTqgIuNJdwPxjpZDw4L0T3iKBZWwdfXwdl016afWx3BmiWwzHs5rKbBpA+YgBj5n48q5vYGXHPaizGnziYBXZgjtOFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540525; c=relaxed/simple; bh=7FgPDEuTAqUZvj26PtjNeIJtWCgEQnOO+W7C1fyHUQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CZA47xNxGQL6qN2/4mN4+g2ngCsMSEOZkd1v1JXcpW2FXALgbVGeUXy6kPcUNSwGsn6QsQI5T5V5xrSgoTRKaluNjr8RYtotvtfY3/Qxm3mnxJQl3oxBEoYPVeGjH03xxWnDCzOe0RuBt+82EawfiR/sUFWEHS1Vz5ngLoA/XJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FQCPsNG3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FQCPsNG3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B47AAC4CEEB; Sun, 13 Apr 2025 10:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540524; bh=7FgPDEuTAqUZvj26PtjNeIJtWCgEQnOO+W7C1fyHUQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FQCPsNG3CRRS9Ibf1GNbKccm4OpL1D70LhzeQiq521jp1GzmnXP0QJMJ7aLpGS5+I Xs/9XexZUqogwIjG0Ds3myk8xgNZeqyOp4rich+uUkhvGGxCD4eYHMjxeqPy8eaUpd 8Xwg+VcohTkA8KMl1UWbW3Hppgik52UysloATHVdK+/hO2XnUqjj733xgoLvMrdmll l7mzqoLZzXvGCinmT5RoxB5i2H015nIRoISoqo5MSFmwa5v7MlVi2i7+62cdKtYJXr qaLpjc0YD8YwRTDIKGoicE0kfARnSNAQpOc8v+s5Dcp6v67csFrvVD3JKDHxTQQK3p o1TbnnzKogZPg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 11/20] iio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:34 +0100 Message-ID: <20250413103443.2420727-12-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. For this case, the length being provided is already passed into the caller function so reuse that. Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 3214506d133d..2ff591b3458f 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -228,7 +228,7 @@ static void hid_sensor_push_data(struct iio_dev *indio_dev, void *data, int len, int64_t timestamp) { dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); - iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp); + iio_push_to_buffers_with_ts(indio_dev, data, len, timestamp); } /* Callback handler to send event after all samples are received and captured */ From patchwork Sun Apr 13 10:34:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049277 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 E433919D880 for ; Sun, 13 Apr 2025 10:35:27 +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=1744540528; cv=none; b=FrwrRkqD2fd5VmGdyCA2s9Lp69I1ovrvbPo3KSLrLA4qJvoBZtsQbq1BG9uDnYrzOylPwU3Y6kkl1nkziZmZn72GUevxemmGC1zvCfghHx1n1gS3503t8oKhMEJLXoFBf8+sciLl5K8meLnHUDwpworVBbJrGgNV09bm++3+rHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540528; c=relaxed/simple; bh=YJkQrGVlflW6ppor12KI+5ny20ffUUBmQcoudSfWoPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t08jEsjPH9RE9AmPyrTC6yjDN/WSGVv9cb49GYTNW18nrfYwhugsMiImUzW58cRITO9qY+2PB2o66dPqBfGjjdBXJMUiLKIUwDxPuhFhNTeYCpskVk+3N8HtQRCVHazr7yEjVSWyMbs3DsrpdfP38C389T7Weixfp3vyorkmMtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FEph3w6r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FEph3w6r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46ACCC4CEEA; Sun, 13 Apr 2025 10:35:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540527; bh=YJkQrGVlflW6ppor12KI+5ny20ffUUBmQcoudSfWoPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FEph3w6rOEXVOm73iqHr/3o0MMofgRtfTh8CnvqFIOotCG2yhx4sMy55MbOA95MtJ GK+q1xorFz/AWox8Bt2FBjPS/NSt5GzsnyanLkwdiW7YD62CJFjo7V3MsAJAJBZ+UW q80vqbvrQ8NbY/PueN7p3NAh+sZha58h2E42LJz8m2rGnac5WYCnkCFoktr5l/oNLJ z5kRhNKDtzWH2GHN65dNK9Z6T+Zj5ug7mNX4G43O6mCSVGt8FECgZUgobsn6PaEZIQ iBa2eGpu7YXdBCpDSDFIMZvSxs00NF91JLk9ThYJrMs0v+tDOA+J/7kCQj6G0IY+vA H4Oe2whybC2tw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 12/20] iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:35 +0100 Message-ID: <20250413103443.2420727-13-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- drivers/iio/chemical/atlas-sensor.c | 5 +++-- drivers/iio/chemical/bme680_core.c | 4 ++-- drivers/iio/chemical/ccs811.c | 4 ++-- drivers/iio/chemical/ens160_core.c | 4 ++-- drivers/iio/chemical/pms7003.c | 4 ++-- drivers/iio/chemical/scd30_core.c | 3 ++- drivers/iio/chemical/scd4x.c | 3 ++- drivers/iio/chemical/sps30.c | 4 ++-- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c index bde473f9483f..cb6662b92137 100644 --- a/drivers/iio/chemical/atlas-sensor.c +++ b/drivers/iio/chemical/atlas-sensor.c @@ -458,8 +458,9 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private) &data->buffer, sizeof(__be32) * channels); if (!ret) - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->buffer, + sizeof(data->buffer), + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 9d73fd2cf52c..3e850562ab00 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -1120,8 +1120,8 @@ static irqreturn_t bme680_trigger_handler(int irq, void *p) gas_range = FIELD_GET(BME680_GAS_RANGE_MASK, gas_regs_val); data->scan.chan[3] = bme680_compensate_gas(data, adc_gas_res, gas_range); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c index 1eab256a1e00..998c9239c4c7 100644 --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -343,8 +343,8 @@ static irqreturn_t ccs811_trigger_handler(int irq, void *p) goto err; } - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/chemical/ens160_core.c b/drivers/iio/chemical/ens160_core.c index 152f81ff57e3..6cec60074827 100644 --- a/drivers/iio/chemical/ens160_core.c +++ b/drivers/iio/chemical/ens160_core.c @@ -267,8 +267,8 @@ static irqreturn_t ens160_trigger_handler(int irq, void *p) if (ret) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/chemical/pms7003.c b/drivers/iio/chemical/pms7003.c index d0bd94912e0a..93075f604555 100644 --- a/drivers/iio/chemical/pms7003.c +++ b/drivers/iio/chemical/pms7003.c @@ -126,8 +126,8 @@ static irqreturn_t pms7003_trigger_handler(int irq, void *p) pms7003_get_pm(frame->data + PMS7003_PM10_OFFSET); mutex_unlock(&state->lock); - iio_push_to_buffers_with_timestamp(indio_dev, &state->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &state->scan, sizeof(state->scan), + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c index 3fed6b63710f..8316720b1fa3 100644 --- a/drivers/iio/chemical/scd30_core.c +++ b/drivers/iio/chemical/scd30_core.c @@ -601,7 +601,8 @@ static irqreturn_t scd30_trigger_handler(int irq, void *p) if (ret) goto out; - iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c index 4877bd3e907b..2463149519b6 100644 --- a/drivers/iio/chemical/scd4x.c +++ b/drivers/iio/chemical/scd4x.c @@ -675,7 +675,8 @@ static irqreturn_t scd4x_trigger_handler(int irq, void *p) if (ret) goto out; - iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c index 6f4f2ba2c09d..2554ef74e141 100644 --- a/drivers/iio/chemical/sps30.c +++ b/drivers/iio/chemical/sps30.c @@ -117,8 +117,8 @@ static irqreturn_t sps30_trigger_handler(int irq, void *p) if (ret) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); From patchwork Sun Apr 13 10:34:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049278 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 8B59219D880 for ; Sun, 13 Apr 2025 10:35:30 +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=1744540530; cv=none; b=KH9oBRVbIXONZOsORRm9Av6Zfg4j3v0bUG65RxpSXKrXWySDPvdfiAtzchb6haWcNcM9DOeS1j6aDban/BbxWtpgbGzwMdkRmeR/iKKQ5gl/wF/EaaDQkx7Xk57AVXN9lKG/2KAe0nFZ0J+ZU85Ac/SeIo0ZxmD9ZkoLyfCp1xE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540530; c=relaxed/simple; bh=1yHXZPOOOC+AMQuIpGmwDyJaFHNGjwT63nwpTRIDlEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EiuvfI2hyjosRlywofUoTF1bjvBGfLxQk8J0Wyu0AAviyEhLFJb+Js3Oe0PN6J3HpcLg8y53kKqJcdfZt6AeZ+47ytLeUX/G0GXod/hJL7goZuOsOht8J9pBv6lJh87a1h+Osbj1sXqQi7UgYemp+bC3H6aOgIboWElLdvKedn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ucDGDryT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ucDGDryT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 284ADC4CEEA; Sun, 13 Apr 2025 10:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540530; bh=1yHXZPOOOC+AMQuIpGmwDyJaFHNGjwT63nwpTRIDlEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ucDGDryTp0i/EYJVmqn+mHlTd6rcdWjVXDeJDPrdfjRzwnLQIzOxaxtY2/RPqyUBl CWJKKFua6FcQ6+fJjLjQTogVM0srJScYxl4JoBaSlBCbha7X6Q84pAv3/uqTWl2YIo yBf9h3HJtjqRTYLmJpB8clY6EsbE4+DpGgs5Q+E5/etlu872J+Dh8Uo6F80BELsQra 8M4h96gxAzUxRXkzgRZiHg4Vq7v1IpHExt47TNuVBEN8D6gJzCtuEczPdNN+aKGEUb O6Q93aWToJhP6h4gEvazhGEcrWyy6Ame2CQyDDAXRxsmJuyO7d3bacQWK6AjVPXwog qxfPeWcnFZvLA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 13/20] iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer. Date: Sun, 13 Apr 2025 11:34:36 +0100 Message-ID: <20250413103443.2420727-14-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron The trick of using __aligned(IIO_DMA_MINALIGN) ensures that there is no overlap between buffers used for DMA and those used for driver state storage that are before the marking. It doesn't ensure anything above state variables found after the marking. Hence move this particular bit of state earlier in the structure. Fixes: 10897f34309b ("iio: temp: maxim_thermocouple: Fix alignment for DMA safety") Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/maxim_thermocouple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index 0bbbadeed940..dcfcbc434a90 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -120,9 +120,9 @@ static const struct maxim_thermocouple_chip maxim_thermocouple_chips[] = { struct maxim_thermocouple_data { struct spi_device *spi; const struct maxim_thermocouple_chip *chip; + char tc_type; u8 buffer[16] __aligned(IIO_DMA_MINALIGN); - char tc_type; }; static int maxim_thermocouple_read(struct maxim_thermocouple_data *data, From patchwork Sun Apr 13 10:34:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049279 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 9291619D880 for ; Sun, 13 Apr 2025 10:35:33 +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=1744540533; cv=none; b=QcmhDEfijz15nZklS30C96ena+VFHhOM2h/05amGZ0TnQD+kGxEBwJujQjybNwwWaksEzDjkLJHQWOe6QEaEF+veSR4HyNYavt7Hq7dfiqZNQAtmgpM08zpNEsduE+gHPmJTTVmNZOVgVDI8xRVTJ0frO09N5VfUODHogA02mc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540533; c=relaxed/simple; bh=ldM7JiBxVIgn5zP7iMOoq4BuJDeIr6CUwn4U3xHbIPY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gpcjtQZjKPH6GJTZRNj4CW4PEHznHdgvbIL0hQ6Yui6Do8j1CLr3yoKkLB3GYzQaqgRjiWmodlR0CCa9dIQFXKAHv6O7yUNsRE9NjWEpGo+hmsvITTS9fYoosuDwp33eJlyci19ZBDRPquusWNxMzc0tQ8V5Pmr+NJjeBIUV58w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IAp6MJQ+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IAp6MJQ+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E18FBC4CEEA; Sun, 13 Apr 2025 10:35:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540533; bh=ldM7JiBxVIgn5zP7iMOoq4BuJDeIr6CUwn4U3xHbIPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IAp6MJQ+IbrKsEOkT+dVMGvNeE4LLVx/Kjj2KOqdmQDc4cLuPQ5R3h+hcopmVKzYq Fh8Xf4h0a/AOiQ4mlapW8AOxhgh50PMhQfF/9wOURz3rUYs7XcuJa3U/aFsllrapTf 0pTmiB/cfzTAKTKGmS4DDx5X5mK78pelbEYA8PnoWv5oydMUO1vsJseYgyujedXvGL 1pqtf+YkNa7oJ1vjzS4HhYT69B9MUaSLWWY+1oFfHy1eX0edQgFVKbdUlhLTR5OTyM 5a8oCZ3aEPq29jTAhXzsTck8XZLyJoQVlfXOQsdQoAUzeYlqr8e3ecxjMaAEWJ6byN WOBe5jf6dH2lw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 14/20] iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:37 +0100 Message-ID: <20250413103443.2420727-15-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/hid-sensor-temperature.c | 5 +++-- drivers/iio/temperature/maxim_thermocouple.c | 5 +++-- drivers/iio/temperature/tmp006.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c index 09f470bb0841..9f628a8e5cfb 100644 --- a/drivers/iio/temperature/hid-sensor-temperature.c +++ b/drivers/iio/temperature/hid-sensor-temperature.c @@ -131,8 +131,9 @@ static int temperature_proc_event(struct hid_sensor_hub_device *hsdev, struct temperature_state *temp_st = iio_priv(indio_dev); if (atomic_read(&temp_st->common_attributes.data_ready)) - iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &temp_st->scan, + sizeof(temp_st->scan), + iio_get_time_ns(indio_dev)); return 0; } diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index dcfcbc434a90..cae8e84821d7 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -168,8 +168,9 @@ static irqreturn_t maxim_thermocouple_trigger_handler(int irq, void *private) ret = spi_read(data->spi, data->buffer, data->chip->read_size); if (!ret) { - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->buffer, + sizeof(data->buffer), + iio_get_time_ns(indio_dev)); } iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c index b5c94b7492f5..29bff9d8859d 100644 --- a/drivers/iio/temperature/tmp006.c +++ b/drivers/iio/temperature/tmp006.c @@ -269,8 +269,8 @@ static irqreturn_t tmp006_trigger_handler(int irq, void *p) goto err; scan.channels[1] = ret; - iio_push_to_buffers_with_timestamp(indio_dev, &scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; From patchwork Sun Apr 13 10:34:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049280 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 EC5BC19D880 for ; Sun, 13 Apr 2025 10:35:36 +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=1744540537; cv=none; b=Vlbyi3eIfpXlVUFFKFOAL/0/0vHBbyh/6RKW2Y5fqCqWy+xWTF4CFwY72ZIaOwLnOJ5beg2Kgm1lkHnwBOVFZ78zhFutDAxbfZ+YW84s8r38f4yB6AglN/GmozgBoYDNUh10yP/mMnZ9+ZxNHvjJth8Hv2Ag9IEPdIu98PMWu/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540537; c=relaxed/simple; bh=+mJiOTUlR+o0aNEGRrL7Jf5Fe8fES3DZ+f2VhmqUIhA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eTU6Ov04WGXixPZSJA1suLoOlMubEYDXkpkRt6wrWGyXlhkcrdfh7bPFXMrCgL9Q/l5iM4rOGe0h9cojCT0kZ4nWJzjrd26T1dwFUOiC5fG3bDAClW5JT694Ai/TXiZMTTh8CGUTQ8ZYRqtNLHk8ULD2rfNB6UpthBgiJwi4oDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PGc8AayH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PGc8AayH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1B1CC4CEEA; Sun, 13 Apr 2025 10:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540536; bh=+mJiOTUlR+o0aNEGRrL7Jf5Fe8fES3DZ+f2VhmqUIhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PGc8AayHzsglUbS+GqpbhBAZ56vOsI8jHg8+5iOdI0ocLVAF6L+1QRuRbO1c0vnYn Q0m5B/EQ/cWlemIvgV5vz6DVJqV31667wObg1XPh0G0rznemtSRCVSNOZ4VnyHhdre FM8T+EhlCKeQS02VFM21/Dc9cAvcKNAMg4HspEsYZkrjNd4lkuutaSCq2D2d9W+BJi QjKE7p3ZdcaitOY7VdwDw8R0vDQp7dnj5nlRtB3f779ariBcXj7CuXIibFSlDwdkfs KDc2MDMVB8ktEOoPCIriRrJWfBOj3c0kt58Ks0ZR5pYMpZfizZ6xwgQGOsanexowKb wD0tTLGaZSJ5Q== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 15/20] iio: resolver: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:38 +0100 Message-ID: <20250413103443.2420727-16-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- drivers/iio/resolver/ad2s1210.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/resolver/ad2s1210.c b/drivers/iio/resolver/ad2s1210.c index 80a2f7ebda8f..9b028c8bb1db 100644 --- a/drivers/iio/resolver/ad2s1210.c +++ b/drivers/iio/resolver/ad2s1210.c @@ -1340,7 +1340,8 @@ static irqreturn_t ad2s1210_trigger_handler(int irq, void *p) } ad2s1210_push_events(indio_dev, st->sample.fault, pf->timestamp); - iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan), + pf->timestamp); error_ret: iio_trigger_notify_done(indio_dev->trig); From patchwork Sun Apr 13 10:34:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049281 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 4EE8519D880 for ; Sun, 13 Apr 2025 10:35:38 +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=1744540539; cv=none; b=g3QS1WlwFDx1AK7kPpzcAk9EkgXKvxIfe4PRaUWcKsPpvDl2Y5ba7p6XgMQGMgqkExpYMOuwflYtRF4ETFCzW4tFqJpGN8QYshRkOQjl7YkUZPSIGiq/rZU6u2yZQsYOloufT1a9jMUEDtOTKKTSoz5ICCTyd8OjG1jNAnRjAQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540539; c=relaxed/simple; bh=riZ+Y0aQ6HCCudD/PiQBQji7SaR0mW2OJHVOV0OTV9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQCko8JQaADHF1typuCi/ulcQIh2wza+Z9nMaFIZ0n/vetqAhKic67UQ8umJsI899U4Jvnbo7RLyJXoVVSBYkoSBvb68EUtQmD3Y/OGacFoMzrPTSLDMwqp+bnN/c7Ew7fPt/GV4PPK2Z5j07d08bQgQHyOOEunGnFzUO41YU7w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tO8G9JX9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tO8G9JX9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6CB9C4CEEC; Sun, 13 Apr 2025 10:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540538; bh=riZ+Y0aQ6HCCudD/PiQBQji7SaR0mW2OJHVOV0OTV9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tO8G9JX9TDs9996Ck2LW6ebkXbBAdd6697nthoV2eWxMQvCYtOcat2uAS3yPCY481 qd01VZcGsdDY7WeVTkIpq70UxwbUV4xqJBJA0wasYRCugxYBW/q35TPpZEcNS9zg9H 1pNErRJjho0aP5/in6AOHK/g3+HpUlMZSyUqwmoGbG8OS9jbERJjegocgrFaIpsJsf jpEsLS9mVi/+mjtaG6N5zPm4qBznkUdD19glJ64VryPVEDlcvtfamNs6mFrXHEUkzo Ts+sS3du+538H48/v4H1TGwoKA76loiwdWTisAPMJC0oNOHnbnn4TtjjXu2CJw0Wgz 9rJ2w/G3g8yYw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 16/20] iio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts() Date: Sun, 13 Apr 2025 11:34:39 +0100 Message-ID: <20250413103443.2420727-17-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron The driver previously used an array of two s64, then type cast the pointer to write an s16 to the start. The code is made more readable using a structure. At the same time switch to the new iio_push_to_buffers_with_ts() helper to enable runtime checking of the size of the source buffer. Note that this approach uses a structure with holes, so use memset() to ensure those do not contain old kernel data as this data is passed to userspace. Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/irsd200.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/irsd200.c b/drivers/iio/proximity/irsd200.c index 1b1b6dfdfa78..0d30b91dbcbc 100644 --- a/drivers/iio/proximity/irsd200.c +++ b/drivers/iio/proximity/irsd200.c @@ -760,15 +760,19 @@ static irqreturn_t irsd200_trigger_handler(int irq, void *pollf) { struct iio_dev *indio_dev = ((struct iio_poll_func *)pollf)->indio_dev; struct irsd200_data *data = iio_priv(indio_dev); - s64 buf[2] = {}; + struct { + s16 channel; + aligned_s64 ts; + } scan; int ret; - ret = irsd200_read_data(data, (s16 *)buf); + memset(&scan, 0, sizeof(scan)); + ret = irsd200_read_data(data, &scan.channel); if (ret) goto end; - iio_push_to_buffers_with_timestamp(indio_dev, buf, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), + iio_get_time_ns(indio_dev)); end: iio_trigger_notify_done(indio_dev->trig); From patchwork Sun Apr 13 10:34:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049282 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 EA9B019D880 for ; Sun, 13 Apr 2025 10:35:41 +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=1744540542; cv=none; b=Uwsd1qzvgP7fzm0+D8l8hqb+O7RFOyPACD7VV7utrcn5I/IEI+qA7Bx6kssRjGhZQki3OqNdenUKtVoKSoLJLID80A9Nw+Ib/xtyZyqOXhb60qzZYEw1bGZzHsIBslH9pJzObhyu90mPZfLdgVyubYMdLTw3aOzWsV067GwbwzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540542; c=relaxed/simple; bh=1gKVZKU5wXiQAjF+2FL8EMVU35MVsQHfFJGdAQZiHBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tv5lECaRdD79mC2NF8qU2wtcxa+QNdEUDaJU6ImZDmyM45e3atZeLIHCib3YBS+ZaZwmDA5EWZbwpdYCreQ8wTODSx1fB4NXV6Vl+J8bXFQTGlNB9i/i1pJIu3QegW83mF140vJrLdRnN5fd1odH25IC3woHKdj42RQFZqmAJ4c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X244P7Vu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X244P7Vu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F9E7C4CEEA; Sun, 13 Apr 2025 10:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540541; bh=1gKVZKU5wXiQAjF+2FL8EMVU35MVsQHfFJGdAQZiHBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X244P7Vu+5/Oj4CNKkrEvqab/NS8u9dtXE97lcBehzAP8hiPI+/rgsi47/nFcDTAm 2cLpH8TBzOxVQxt7KT60srisQ/MTrvxqvEk0nDL5HZ6GObFO0PntBpQOiBRkWsQLA9 4dUluyU8fLKGQXPSh4fFk7SamxzyeRPBRG7nRksdZ1aqMAtOWQWdd4w2z0PAmcjNfm Iic46DzUa1GaOknPjffZVL29T711liAGbR0lQKWH82geCt5ov368HN9I8HJJ5m5Xcw YCTLl75intHnIRcWzzASnE306/N8uv31142NpXMIY9pUYt9EAv6wANGHBggqCVNCkK zuEHrDTzIRHxQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 17/20] iio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:40 +0100 Message-ID: <20250413103443.2420727-18-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/as3935.c | 4 ++-- drivers/iio/proximity/hx9023s.c | 4 ++-- drivers/iio/proximity/mb1232.c | 4 ++-- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 5 +++-- drivers/iio/proximity/srf08.c | 4 ++-- drivers/iio/proximity/sx_common.c | 4 ++-- drivers/iio/proximity/vl53l0x-i2c.c | 4 ++-- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index d48d7b572878..f1018b14aecf 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -231,8 +231,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) goto err_read; st->scan.chan = val & AS3935_DATA_MASK; - iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &st->scan, sizeof(st->scan), + iio_get_time_ns(indio_dev)); err_read: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c index f2037fd99a8d..33781c314728 100644 --- a/drivers/iio/proximity/hx9023s.c +++ b/drivers/iio/proximity/hx9023s.c @@ -953,8 +953,8 @@ static irqreturn_t hx9023s_trigger_handler(int irq, void *private) data->buffer.channels[i++] = cpu_to_le16(data->ch_data[index].diff); } - iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, + sizeof(data->buffer), pf->timestamp); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/proximity/mb1232.c b/drivers/iio/proximity/mb1232.c index 24524edae0b4..01783486bc7d 100644 --- a/drivers/iio/proximity/mb1232.c +++ b/drivers/iio/proximity/mb1232.c @@ -125,8 +125,8 @@ static irqreturn_t mb1232_trigger_handler(int irq, void *p) if (data->scan.distance < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index fbf9f8513055..1deaf70e92ce 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -238,8 +238,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) ret = lidar_get_measurement(data, &data->scan.chan); if (!ret) { - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, + sizeof(data->scan), + iio_get_time_ns(indio_dev)); } else if (ret != -EINVAL) { dev_err(&data->client->dev, "cannot read LIDAR measurement"); } diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c index 940fad6aeaa4..6e32fdfd161b 100644 --- a/drivers/iio/proximity/srf08.c +++ b/drivers/iio/proximity/srf08.c @@ -191,8 +191,8 @@ static irqreturn_t srf08_trigger_handler(int irq, void *p) mutex_lock(&data->lock); data->scan.chan = sensor_data; - iio_push_to_buffers_with_timestamp(indio_dev, - &data->scan, pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); mutex_unlock(&data->lock); err: diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c index f70198a1f0d1..59b35e40739b 100644 --- a/drivers/iio/proximity/sx_common.c +++ b/drivers/iio/proximity/sx_common.c @@ -379,8 +379,8 @@ static irqreturn_t sx_common_trigger_handler(int irq, void *private) data->buffer.channels[i++] = val; } - iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->buffer, + sizeof(data->buffer), pf->timestamp); out: mutex_unlock(&data->mutex); diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index 87d10faaff9b..ef4aa7b2835e 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -94,8 +94,8 @@ static irqreturn_t vl53l0x_trigger_handler(int irq, void *priv) return -EREMOTEIO; data->scan.chan = get_unaligned_be16(&buffer[10]); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); vl53l0x_clear_irq(data); From patchwork Sun Apr 13 10:34:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049283 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 BE4E51A08DF for ; Sun, 13 Apr 2025 10:35:43 +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=1744540543; cv=none; b=vFcW3eYzw5RBpo4VKZ8Qz9LTrbxgt5fQifHUYqAcQ+9yQ+0jjzcLKbUpEWdOLaTB1CAWOMDKGHritAJbI6mZqj2nVaW8WtJrvaNOa4La6KdjKC50PEHyMPnwJoyS2TEnGJU0YJFN3BHrwzlrRZosL7FuIoURa+YMGfkUBvrbrD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540543; c=relaxed/simple; bh=5r9r31RBMx2dIw84YeSoHYW0RX5ZPKdhfXyjCUzNHc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VFjiLWSJ06oII72vsBbgFjzbFfLrL9DfHUHD2gBGEm/V2pZBYI696rsu+heZVLV+7Vzoqsx6L+JH1kyfAepQWNRJYoXhnLDs48VOLeFGQYu2e5pGdIYrmKTdAuNoCPa4YAX/nWxbmhP0BB1R1kQCjgHGaR4yqJ5AP6/LnILA7J8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BKxdfmoM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BKxdfmoM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F10AC4CEDD; Sun, 13 Apr 2025 10:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540543; bh=5r9r31RBMx2dIw84YeSoHYW0RX5ZPKdhfXyjCUzNHc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BKxdfmoM2g1z6h455C2W+yYdwfR31dwvmA/mMlis6O4QwuRHzLxImBOpttaaidypd FIh2jOTy/52iijMpzcTfNya0KXlDYmEPixHxmfMqooaMnDDQaZIZHwIbMyQ7PGWsRL RPE71SOgEEe7WuMBh4x3KbXgsN63B7/UxTsL000BJy6jGNJrmHd8+ysQudiuUWVt+f eccXUcEB2qNTSzugMpVuY5ltS9zWW3jn6Zu3xyvUQ9dcL0iT0WPwLEcKCgjwnI3jnc 6huxua6DwEQFNLOUIOrmu12IM5ReY10d0f8mtyCKnte5W1jYru4e5BkbsWuRQF9mez 9A/yKic+XRTEg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 18/20] iio: pressure: zpa2326: Use aligned_s64 for the timestamp Date: Sun, 13 Apr 2025 11:34:41 +0100 Message-ID: <20250413103443.2420727-19-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron On x86_32 s64 fields are only 32-bit aligned. Hence force the alignment of the field and padding in the structure by using aligned_s64 instead. Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/zpa2326.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index 0a510d5fc1d4..30f007794f5b 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -582,7 +582,7 @@ static int zpa2326_fill_sample_buffer(struct iio_dev *indio_dev, struct { u32 pressure; u16 temperature; - u64 timestamp; + aligned_s64 timestamp; } sample; int err; From patchwork Sun Apr 13 10:34:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049284 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 4533519D880 for ; Sun, 13 Apr 2025 10:35:45 +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=1744540546; cv=none; b=KUVoMmXPgajZ2s4BicYGZ0Rg2Y4JUt0SQBEORBtj5fB/QQA3MLGpLRAB/wd9Mt0lfVz48PCr9CjePnlfioq53+oiwR8vG9r/zHGvXKWxknQkOB2xXqcE4tUyYW/VG0jteQ5PItLxkWUByKNF0tP7Vso2svd8i6dnWLid6FvCiXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540546; c=relaxed/simple; bh=caQH8ecAiQuANOIPUSePBk6TVuIqiI38+yGX+UyLsZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WP4+0kTtQUHPdCb6x+92cUlHeBReslSId3j4dMmdnt6pp836OIo+hAp9AZ83MmnYGpQaFMnwRYq4mu9HXKtqUo3iNl8RIbm482aSaZwFFdnMMCDewRMGMxPWFujgJ0CQZder02txvs0sAuZt2kxnXpCC5OHuFEn0VLHwemkrSKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gV9uN2z2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gV9uN2z2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EE02C4CEEC; Sun, 13 Apr 2025 10:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540545; bh=caQH8ecAiQuANOIPUSePBk6TVuIqiI38+yGX+UyLsZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gV9uN2z2ETOpSCRtO+acai79d71Uy6vGFNEQ7+wvVgWB7mNMyjyK60nEbKq9+x5+f G/4h2NjPClvYs3xttP6n06WoAWjt7ko1ekcmi5SgllY1GzV4Kua8mioUS+JAsn5YGt 4o+FhqcjYclS9uOYi+nYPnrS21TJdplI4P0co/GDhrfh69jeAOzaMFLpJZtXuldI2a 75wZ/OS/IuJ4vwGXI0CUxwSwjmqtWpUgrKtT4PgbUyoymOA1Plbu0BQ70MnHI5omJa 7s27bgpylUPO1tF+SV+U7tRmqPr4UxpmOV80VpmnUN79jsbvN11N0qWXFi6Q4k1dxp 4mtbz2VvaCLOg== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron , Matti Vaittinen Subject: [PATCH v3 19/20] iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:42 +0100 Message-ID: <20250413103443.2420727-20-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Reviewed-by: Matti Vaittinen # ROHM BM1390 Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280-core.c | 25 +++++++++++++++---------- drivers/iio/pressure/hid-sensor-press.c | 5 +++-- drivers/iio/pressure/hsc030pa.c | 4 ++-- drivers/iio/pressure/mpl3115.c | 4 ++-- drivers/iio/pressure/rohm-bm1390.c | 3 ++- drivers/iio/pressure/zpa2326.c | 4 ++-- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index d44ab65c94cb..c20cc4a98c9c 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1142,8 +1142,9 @@ static irqreturn_t bmp280_trigger_handler(int irq, void *p) chans[0] = comp_press; chans[1] = comp_temp; - iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->sensor_data, + sizeof(data->sensor_data), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); @@ -1273,8 +1274,9 @@ static irqreturn_t bme280_trigger_handler(int irq, void *p) chans[1] = comp_temp; chans[2] = comp_humidity; - iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->sensor_data, + sizeof(data->sensor_data), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); @@ -1936,8 +1938,9 @@ static irqreturn_t bmp380_trigger_handler(int irq, void *p) chans[0] = comp_press; chans[1] = comp_temp; - iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->sensor_data, + sizeof(data->sensor_data), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); @@ -2630,8 +2633,9 @@ static irqreturn_t bmp580_trigger_handler(int irq, void *p) /* Temperature calculations */ memcpy(&data->sensor_data[offset], &data->buf[0], 3); - iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->sensor_data, + sizeof(data->sensor_data), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); @@ -2969,8 +2973,9 @@ static irqreturn_t bmp180_trigger_handler(int irq, void *p) chans[0] = comp_press; chans[1] = comp_temp; - iio_push_to_buffers_with_timestamp(indio_dev, data->sensor_data, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, data->sensor_data, + sizeof(data->sensor_data), + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index bffeddff5e91..5f1d6abda3e4 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -176,8 +176,9 @@ static int press_proc_event(struct hid_sensor_hub_device *hsdev, if (!press_state->timestamp) press_state->timestamp = iio_get_time_ns(indio_dev); - iio_push_to_buffers_with_timestamp( - indio_dev, &press_state->scan, press_state->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &press_state->scan, + sizeof(press_state->scan), + press_state->timestamp); } return 0; diff --git a/drivers/iio/pressure/hsc030pa.c b/drivers/iio/pressure/hsc030pa.c index 168245818cfe..2d00c0656259 100644 --- a/drivers/iio/pressure/hsc030pa.c +++ b/drivers/iio/pressure/hsc030pa.c @@ -314,8 +314,8 @@ static irqreturn_t hsc_trigger_handler(int irq, void *private) memcpy(&data->scan.chan[0], &data->buffer[0], 2); memcpy(&data->scan.chan[1], &data->buffer[2], 2); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); error: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index 8397155555bd..d6715997f137 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -191,8 +191,8 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p) } mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, buffer, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, buffer, sizeof(buffer), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/pressure/rohm-bm1390.c b/drivers/iio/pressure/rohm-bm1390.c index c651ead080df..dac27fd359ad 100644 --- a/drivers/iio/pressure/rohm-bm1390.c +++ b/drivers/iio/pressure/rohm-bm1390.c @@ -652,7 +652,8 @@ static irqreturn_t bm1390_trigger_handler(int irq, void *p) } } - iio_push_to_buffers_with_timestamp(idev, &data->buf, data->timestamp); + iio_push_to_buffers_with_ts(idev, &data->buf, sizeof(data->buf), + data->timestamp); iio_trigger_notify_done(idev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index 30f007794f5b..1640aa3717ed 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -618,8 +618,8 @@ static int zpa2326_fill_sample_buffer(struct iio_dev *indio_dev, */ zpa2326_dbg(indio_dev, "filling raw samples buffer"); - iio_push_to_buffers_with_timestamp(indio_dev, &sample, - private->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &sample, sizeof(sample), + private->timestamp); return 0; } From patchwork Sun Apr 13 10:34:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14049285 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 51931191F91 for ; Sun, 13 Apr 2025 10:35:48 +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=1744540549; cv=none; b=slIlQPeMNwPtLQ9JUc4WyBfkbl72o7CJzZ5+J4igLcK1JfQYUzERzrMaCS331z2fjaLSTbDVTfVJb5jm14GsLqNL1nlt/YMeOMBld2Plrt9zKLoogkge1YUvde43ihujEHyXpTfY15dBtIbitZIx+oul0W4Vs3elCaRyeZjvQPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744540549; c=relaxed/simple; bh=GlsI+wkq7cKwF7XxxzJyw0aNOV4TLBHaoiAvYb/qAvE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AAa8A/OLxIu1n/al6p3PPs66ahlVV5FgUhdhkrUw+ehrS+WCbI6RXFJrb4EUpjsSWojygJ1cvZIylKJlp6f+6BhGYdKdqY6T7dr1pO2NVc4Kt5VzfuQcysh/4Lo3A7f01eP+JbjM8qNEDrL+pVdwlj1S06u1REYTa3nFs427lMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lCnhGAgd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lCnhGAgd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 776A8C4CEDD; Sun, 13 Apr 2025 10:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744540548; bh=GlsI+wkq7cKwF7XxxzJyw0aNOV4TLBHaoiAvYb/qAvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCnhGAgdkMeK/8YebISm1510vlU6okmhf7S7baWumpjApGhVBE/izH6tD4YkBsZa3 /1yZmtMJr1PhruXtRX/MLPJGKcuD+V7JwfzVmokOeHp46tMLTRt9tZijrzZzIkYqvQ PrOEjhsEl7ousVDnl1kLUhfE0nAs4zpyWx1ckHTt8rsbgYES8qkO49PwOW0sm8Ch5M Q7zXszP7omWUVgNt8SPcUkRhQCzScakeemjMgcY+nJUEzMx7XP06GBGNmh1ndiT+O/ 69mv436HzptyJPwb1GVMqgz6xmgIGWAnkYnG+lXDZFolKnfKH/JuvWFTvHvWyTlwnJ AOujNtM767B3Q== From: Jonathan Cameron To: linux-iio@vger.kernel.org, David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Jonathan Cameron Subject: [PATCH v3 20/20] iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 13 Apr 2025 11:34:43 +0100 Message-ID: <20250413103443.2420727-21-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250413103443.2420727-1-jic23@kernel.org> References: <20250413103443.2420727-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This new function allows us to perform debug checks in the helper to ensure that the overrun does not occur. Use it in all the simple cases where either a static buffer or a structure is used in the drivers. Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/af8133j.c | 3 ++- drivers/iio/magnetometer/ak8974.c | 4 ++-- drivers/iio/magnetometer/ak8975.c | 4 ++-- drivers/iio/magnetometer/als31300.c | 3 +-- drivers/iio/magnetometer/bmc150_magn.c | 4 ++-- drivers/iio/magnetometer/hmc5843.h | 2 +- drivers/iio/magnetometer/hmc5843_core.c | 4 ++-- drivers/iio/magnetometer/mag3110.c | 4 ++-- drivers/iio/magnetometer/rm3100-core.c | 4 ++-- drivers/iio/magnetometer/yamaha-yas530.c | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/iio/magnetometer/af8133j.c b/drivers/iio/magnetometer/af8133j.c index c1fc339e85b4..192ba2da94e2 100644 --- a/drivers/iio/magnetometer/af8133j.c +++ b/drivers/iio/magnetometer/af8133j.c @@ -370,7 +370,8 @@ static irqreturn_t af8133j_trigger_handler(int irq, void *p) if (ret) goto out_done; - iio_push_to_buffers_with_timestamp(indio_dev, &sample, timestamp); + iio_push_to_buffers_with_ts(indio_dev, &sample, sizeof(sample), + timestamp); out_done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c index 7cc4690b5cdd..f9e92e3cb385 100644 --- a/drivers/iio/magnetometer/ak8974.c +++ b/drivers/iio/magnetometer/ak8974.c @@ -673,8 +673,8 @@ static void ak8974_fill_buffer(struct iio_dev *indio_dev) goto out_unlock; } - iio_push_to_buffers_with_timestamp(indio_dev, &ak8974->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &ak8974->scan, sizeof(ak8974->scan), + iio_get_time_ns(indio_dev)); out_unlock: mutex_unlock(&ak8974->lock); diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index f8393576f463..a1e92b2abffd 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -882,8 +882,8 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev) data->scan.channels[1] = clamp_t(s16, le16_to_cpu(fval[1]), -def->range, def->range); data->scan.channels[2] = clamp_t(s16, le16_to_cpu(fval[2]), -def->range, def->range); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); return; diff --git a/drivers/iio/magnetometer/als31300.c b/drivers/iio/magnetometer/als31300.c index 85eb1428a849..f72af829715f 100644 --- a/drivers/iio/magnetometer/als31300.c +++ b/drivers/iio/magnetometer/als31300.c @@ -245,8 +245,7 @@ static irqreturn_t als31300_trigger_handler(int irq, void *p) scan.channels[0] = x; scan.channels[1] = y; scan.channels[2] = z; - iio_push_to_buffers_with_timestamp(indio_dev, &scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), pf->timestamp); trigger_out: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index 88bb673e40d8..f9c51ceae011 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -678,8 +678,8 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p) if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + pf->timestamp); err: mutex_unlock(&data->mutex); diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h index ffd669b1ee7c..7a3faf7ffed4 100644 --- a/drivers/iio/magnetometer/hmc5843.h +++ b/drivers/iio/magnetometer/hmc5843.h @@ -34,7 +34,7 @@ enum hmc5843_ids { * @regmap: hardware access register maps * @variant: describe chip variants * @scan: buffer to pack data for passing to - * iio_push_to_buffers_with_timestamp() + * iio_push_to_buffers_with_ts() */ struct hmc5843_data { struct device *dev; diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index 2fc84310e2cc..fc16ebd314f7 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -452,8 +452,8 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p) if (ret < 0) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 92d4511ed372..ff09250a06e7 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -404,8 +404,8 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p) data->scan.temperature = ret; } - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &data->scan, sizeof(data->scan), + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c index e5162ee64e01..2b2884425746 100644 --- a/drivers/iio/magnetometer/rm3100-core.c +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -515,8 +515,8 @@ static irqreturn_t rm3100_trigger_handler(int irq, void *p) * Always using the same buffer so that we wouldn't need to set the * paddings to 0 in case of leaking any data. */ - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - pf->timestamp); + iio_push_to_buffers_with_ts(indio_dev, data->buffer, sizeof(data->buffer), + pf->timestamp); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index 46bc64e676b1..340607111d9a 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -674,8 +674,8 @@ static void yas5xx_fill_buffer(struct iio_dev *indio_dev) yas5xx->scan.channels[1] = x; yas5xx->scan.channels[2] = y; yas5xx->scan.channels[3] = z; - iio_push_to_buffers_with_timestamp(indio_dev, &yas5xx->scan, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_ts(indio_dev, &yas5xx->scan, sizeof(yas5xx->scan), + iio_get_time_ns(indio_dev)); } static irqreturn_t yas5xx_handle_trigger(int irq, void *p)