From patchwork Sun Apr 6 17:19:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039423 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 01748153BE8 for ; Sun, 6 Apr 2025 17:20:20 +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=1743960021; cv=none; b=N0ZZdzVv4bcmj3T5FC1+UhyCQd9WAJweeCzv3eyFpoVM84DFRgxraOUL1JuSTzEmWzoC2fnjoHzhSyBMQIUJ58B6lnRdlifPWQcw1JHXo5fkkL0mqx7xLmZwAZo0l6PJfTjCWSOOLEdmWVOGeBht45hPqcPA9ywu+an31OGyMfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960021; c=relaxed/simple; bh=dYNeYVx++I7OnDVoGxb6Nq5EygJVEHBwjgYtImHxCYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sMAOnkeSGJRPFfvd2c1bPA9xSHtMkgtmvrayG4x+7X5o6eCgqdoeB6/Vc70xxm5iP4eLdoq5gZ1kYpcI82KX0A0jqmNDIUh79xMp4KEAOowDoKUrT03I8/wPdxYol6a8FAiE/wTmeBs1+UhTnqvQ0AmmBz5vwYDAwnOE1bJeOcI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MRA2UYb+; 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="MRA2UYb+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18139C4CEEA; Sun, 6 Apr 2025 17:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960020; bh=dYNeYVx++I7OnDVoGxb6Nq5EygJVEHBwjgYtImHxCYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MRA2UYb+mmE5RByeqQLKJ01lCbOvrNCIjDeHfw+DgFEFE1+X6DxrnZNnQnBtPbggB BokAc6d6e6QcUkk2x/cxI9shonrJfNvSHAU6A7YXfUC62zXb7xzWKjmV7p4oDIl88v eMOpW/jDCbFWezQ4fcYXWtwuH4xvsMiK4ShBYyXNvFZUvae0ldEJtzF7ulfoOSjgOW 4CvNgeecTTiXYBtGZl6bFcLLCG6lcIS9tcyU9JG7wMwjXZqKs47UcBruJXzdkPK8dG bo76hPLzokCHphOYTbAKCsbAxw/zqJB/KZd8/I1FX8tpQq955Y+L+3fbgBOBPJrZwj 4dYPJfA6D3pmQ== 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 v2 01/20] iio: adc: ad7266: Fix potential timestamp alignment issue. Date: Sun, 6 Apr 2025 18:19:42 +0100 Message-ID: <20250406172001.2167607-2-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 aligned to 32 bits 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 Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sá --- 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 6 17:19:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039424 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 B30C51487F6 for ; Sun, 6 Apr 2025 17:20:23 +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=1743960023; cv=none; b=t/YhmX+AZVqfE/+2UtMrz6IGuPcjxxMNj1+VirVgMwJ5y42R1slvtNumQT2pEFLogRw79L90UcZUCYNUpRqaypthvYM1KSN4OOThAkS0PC8T/itJyyq4fLkZCgIFDLRuYcUT+VtUbgVeAQBCJLp7yLmbZTBSqT+XFPwcl3UrHmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960023; c=relaxed/simple; bh=poRtUlqGEnmS/q2VwRMLFPMIvDU105ZgBO8Drq9gGpQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IgSJMUZtWQ9dsa1HH2z5G5FuRlSqO5+3nrRcS2Mb0tBcGOhy3c0g+nlV2MBoOz8trAdYy64UOT932NS5FRYEGHHWO3iKIS+J9nnikkZPPLuiJpIaD/Z5tRoSIH0oO1/HeU560d5uTvh7Ig8hyp5uuG1n9eHCh4HTqsCXEq8feJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ikeis5Yz; 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="Ikeis5Yz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B159C4CEEB; Sun, 6 Apr 2025 17:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960023; bh=poRtUlqGEnmS/q2VwRMLFPMIvDU105ZgBO8Drq9gGpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ikeis5Yzk4dQnmDbsSpXmXjjYat0MYgzq3FbAzfxNl+n2w6tkE7NVvCjWIh7myDIe 7ZnvjDg5IuE97mAMcqTy3EtZ4LghJXtuqW+5gjI5+tQg6ljL2Y9ZyYGY8dbA7CHDJW 4eF2hxXpQs96QXBss1hrqUsRct3eI/DSQkDVbA5tjNJNi3FCGB2HzBQEKCv5no37Tn jcMFyGttBmr2udysmZo33KJWAKz9yD4ZmxWzBEl/+QWfpcdTx8mZFABbWmM1CY5huF Gx8Jlbl0B4/Vi2V/E8qz/gXTjE0MfHja6Y/+TlZsEUsry2TcjNbpGIdst5oZ/chWCy zo5ykkwQSjKNQ== 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 v2 02/20] iio: adc: ad7768-1: Fix insufficient alignment of timestamp. Date: Sun, 6 Apr 2025 18:19:43 +0100 Message-ID: <20250406172001.2167607-3-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sá --- 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 5a863005aca6..5e0be36af0c5 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -168,7 +168,7 @@ struct ad7768_state { union { struct { __be32 chan; - s64 timestamp; + aligned_s64 timestamp; } scan; __be32 d32; u8 d8[2]; From patchwork Sun Apr 6 17:19:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039425 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 7D3041487F6 for ; Sun, 6 Apr 2025 17:20:26 +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=1743960026; cv=none; b=C8MkJygvYp95/G1KRXVnzu2DfZcW/AkPyRZ25kJc3hvpRozaVZJUjQCGvH4TiN6OOuO3oc4A6VvcnwywSrRJN5XQ2I5TIIXEX+WokGDxFdVnvmSiK/lyYsKgpwfHwYmmcSNl7cNBESHWtu8drkF6g85VKy7f7d2C8a5uxoGFEes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960026; c=relaxed/simple; bh=1D1Wx0khjbmdz2WHj7erW3C12LGblykqws+vP1NgRJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N7ngnjf3XwDNzl3/ibxfmF2WACOoRfl7JH9xdONPJ+Tq3IYqx+1uyKQ8xg0pXjgtyj5s2w8E6j9cPIaG5l3rxyJyYyIR5D1WJ3+mw0zWUExhrr8UB6FIVTBkXMNwOg+OhKW0zkXoKzQ3sO4qBkGDmZf9C5KLnzGZP+fZGKnab7M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KJGUFkXa; 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="KJGUFkXa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23B1DC4CEE3; Sun, 6 Apr 2025 17:20:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960025; bh=1D1Wx0khjbmdz2WHj7erW3C12LGblykqws+vP1NgRJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KJGUFkXalYyun/sroIDwZBy0q3aFpP/g/z+bG69mH4rZsPYFwBIOgyQ4bSyu5rPP8 2x1CUhnktROlgqAeUZtHMGSw5sg1N1QSKC7tu2dPnUW25s8rPYfTAOucSWAwsU9CEd /FeIQm92yl+evomi9P0tTa1EI4v2jK3tAd1rKQdl82YCJgxx6BE5LANSLVTcindugR roVcbtSDIQRnz+3Xu9u4xOk5F0quXiGFsvZdqZtWmJtMF+e0D5Q+dXMdFFVrBZIfkE jhuFbsBvm1NxWGcQiC4KkBuM5hyZnUCq/cptfwlco5NaBNWCE60xQx58XY/gQUhVpw 6Aw7/UieuijhQ== 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 v2 03/20] iio: adc: dln2: Use aligned_s64 for timestamp Date: Sun, 6 Apr 2025 18:19:44 +0100 Message-ID: <20250406172001.2167607-4-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko --- 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 6 17:19:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039426 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 023B41487F6 for ; Sun, 6 Apr 2025 17:20:29 +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=1743960030; cv=none; b=KjhIfG8VXXnsPoz2ZaaCCI3H10jskcArPQQFxhOdQxuHCm+5UuGzbYNOQnErxeLJkGfVlpJdZaN7k+aLUL/vbJHehQuvZFZiTjTAhZGVPvgDgMYbyEusiwl9Ley5SV0T9cVqZUc6si/86xpgVQcjt0h94fgCji+9IGiTPppNH9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960030; c=relaxed/simple; bh=WgCBp8Ztrk5AA/HvkspT5LSPAsx73/TNUTk5OZkhF+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MSW8H6A4ZBwWRgl2CwA3oe+Npq8dAgrc2f5uYG+siDajXZdE05BOJ32xxMF5XRhUaReEvk2rdSMBG7Q//B5Y/xGzzbLbODu+0IZJBvG7BHcYQXR7vxS8UOxmRlkLeY+3EhV/UZBkYYBrwlhU7we3WOLXRgJBv0Iphqz5RGkL/vo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hKLKW/b3; 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="hKLKW/b3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE7A3C4CEE3; Sun, 6 Apr 2025 17:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960029; bh=WgCBp8Ztrk5AA/HvkspT5LSPAsx73/TNUTk5OZkhF+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hKLKW/b3dvxkAU7MbODc6vI1HmrXN4jknkYQMb0XDdUm4GsABVpppAPJbfQ4LPYgZ XdbU0PwFKFf9lwClIDMpm/ZjssvmXw3cOYhEtyNclZyvo8CKJI6xIhurECAflvIVFP pyWxEASawKmPnZjVekwFa29zcAFC0HXuYqQjONC6+HlijoIY04U6+iiohDtkBE/pvO fvcxC0uM7NCRPPI3SQ5N91wSrg1Vxvgvyh9r4AjGuUiDHKwcRFycfscjBpgSQa/KqO br02cgJwWqZhRdfYmKus8YtIoD78wgFoTSQDrqoB5sgv0Uosp5rLUJy1IZrdHYwTIx Vtp3DcnVMFrOg== 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 v2 04/20] iio: accel: adxl355: Make timestamp 64 bit aligned using aligned_s64 Date: Sun, 6 Apr 2025 18:19:45 +0100 Message-ID: <20250406172001.2167607-5-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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. I 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 Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sá --- 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 6 17:19:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039427 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 611D61487F6 for ; Sun, 6 Apr 2025 17:20:32 +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=1743960032; cv=none; b=ChD1nKa45IDRAcusVfmDt4bs+t36kMG1zqPBUcMXd4tPuok7oWTSxKwAfbZzc+6gzVU40nk0NdsPOxZBtsdmWMSLiE4tCm1Hr2UezdGasiX2GXsRCosylGc8NQRxdfvOdzWAlxOXlZZvnjLlHOBY1HgAe8RoXeNApeYQvsoUfgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960032; c=relaxed/simple; bh=/7pW/XwveocHbDYzDGr6Y+qEQgCQ2M31wVRjMsYrUW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JG01PAJR8wbnVgOlbFD8QLxfTcE2bBe6jMxDBaJYApNVG+i5mbekLYdnRfG2LKudPXFDGV9edqaqtrA9TnRqe27wyz/Mr4vp98YD1jQWUqB7m95YoXM64VzuX9HylFrlic/uDQm4Ykrty7jHeY31nPocpLeRYKQdmDkII+T1fTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OfoanVXP; 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="OfoanVXP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DF26C4CEE3; Sun, 6 Apr 2025 17:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960032; bh=/7pW/XwveocHbDYzDGr6Y+qEQgCQ2M31wVRjMsYrUW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OfoanVXPbVFSOA625rvlGzCbidpvTgERhjSDtRhnQoxFugM965A7YiK216fTRO+/F mHuSHRry2JLlHVn+SvYff9cLwSuTIW7g05qUK1YVWD4mRV5eTZ6gZ35+Fvhcs3GZVY iRSxg7mFfqtf6qCUu5pXzC+zryd03Dh6djyif3SEOH+nRUr8rezNe2olSHQLVZhShW 0vOX02/S0hLBeKSCktKbuRl33imGC4BfzjJPeuf6nwgLAHchjMwpCVtiNBpj1azFr0 d6vcRcZbwE4DiaeVOfz8TsIqIGgX76EJVbUS4/q45dNtZVLGB+WE64kT+TFc5/I6OD jdnR5rcVA7uWA== 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 v2 05/20] iio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument. Date: Sun, 6 Apr 2025 18:19:46 +0100 Message-ID: <20250406172001.2167607-6-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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. Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sá --- 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h index 3b8d618bb3df..49c5347f35ea 100644 --- a/include/linux/iio/buffer.h +++ b/include/linux/iio/buffer.h @@ -45,6 +45,19 @@ 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, + int64_t 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 6 17:19:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039428 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 A9ECB1487F6 for ; Sun, 6 Apr 2025 17:20:35 +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=1743960036; cv=none; b=DnbKj6c6YRfP43lInXTdIMA7tCtNG5SvEYTsFbMv6k9x6v0Ctqvc0BkX1pJmx57Mc0nKnDNlb8ww3KnR4sOJNlP2zNK2IgXgt9uZmYhY0H03tzB0KMicFNi+W8eVKvt2uKkmYL4CTd7jXN65zD9mvLqcfZfFBt1ZnJKvfv/rcBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960036; c=relaxed/simple; bh=gkpXFhKfjFsrwr+J1Mh/7swCsWVpkiy27IDthZqCm9Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OVOt53IJgJSabZTHg24jiws63z9kW0rRPNNRi94/oPBtQlsoOIcRfcuhkS2jEnAvD4CyhUTtSEjdgLC7vTy17wWPwLCsFZgphSCahDkVNtz7t7gvGeKEwpAJ0BBQOF3F45Y69bb0RMOvp/lWDmBAng2BXvZoR8zxGOJt0Jz9gQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hUVd3RwC; 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="hUVd3RwC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF8EBC4CEE7; Sun, 6 Apr 2025 17:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960035; bh=gkpXFhKfjFsrwr+J1Mh/7swCsWVpkiy27IDthZqCm9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUVd3RwCw8QwFyU0CJNrdYex5Emulr9tVyshbU6+u+slKz+8OBARzxZb9n970xGyt xzpXX9GlPPzn1pB7jeb4V2zlu2yHOB6EHuyVEeualQLfQiRR0GxuEfaX35lhOQ61yu pPdmb2p9zIuZfAEFjLCRPbF4uS3AvVwu5Rt9y73CRA4qYs8aUIji+gnkr28i1J+Xu2 ToVzB8UIxMDskIVpkz6grvxmVlHYakqpGQ7/qzTgIMhX1zbBBZuKANZuH/4yZx99+K juagD2fHeK2yEHbrCid70Jl7mJnB4gSiBIeUzpxiWIKoQ1wEXzlTzARlAsj9jDRKf6 WicSR5jTz6QSA== 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 v2 06/20] iio: dummy: Use a fixed structure to build up scan to push to buffers. Date: Sun, 6 Apr 2025 18:19:47 +0100 Message-ID: <20250406172001.2167607-7-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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. A simple anonymous structure definition suffices here as even though we have a mixture of signed and unsigned channels only the signed ones use the full storage so the unsigned channels can used signed types as well. Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sá --- v2: Add a comment about stack buffers not being DMA safe. --- drivers/iio/dummy/iio_simple_dummy_buffer.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c index 288880346707..eca5f0652d23 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -46,11 +46,14 @@ 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; int i = 0, j; - u16 *data; - - data = kzalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (!data) - goto done; + /* + * Note that some buses such as SPI require DMA safe buffers which + * cannot be on the stack. + */ + struct { + s16 data[ARRAY_SIZE(fakedata)]; + aligned_s64 timestamp; + } scan; /* * Three common options here: @@ -69,14 +72,11 @@ 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); - -done: /* * Tell the core we are done with this trigger and ready for the * next one. From patchwork Sun Apr 6 17:19:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039429 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 EA16C1487F6 for ; Sun, 6 Apr 2025 17:20: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=1743960039; cv=none; b=KTdSWjQLI6J4hipx4rZ7cLNwvlBWkVNtdhjaNim4PKY64p53lAU/fucsZ3Ssot3KAuRQQD1E8xVouutfzJ3Kzl8VyzAYRgOQuCxsITK6z6sAalWf15lmlQGO1bpJXu5Ux17b/OPo4wa90VA2jxokPWkLFftSP0s4HK712Ho25Uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960039; c=relaxed/simple; bh=X1re6tjkDhC95EdCAoKUNa7RYQSZR580C6uSuYUaJB8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ubbghP48pwi/PV94N/GK5G69Pu6DzwAKTbc+/R40DbLQliWDvmAmLW53A4BdYCNoHwGE9GcjbWAqz4AbrNFH/4i6GsmBRUOUBCyqZHgg6xptoFfjuqz29bHcJSO/I++rMAvXhn/7weR55TRLJHr3vfh/iYmsbnd6IPsXqbsi9Q8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Md2+mgE6; 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="Md2+mgE6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFBD3C4CEEA; Sun, 6 Apr 2025 17:20:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960038; bh=X1re6tjkDhC95EdCAoKUNa7RYQSZR580C6uSuYUaJB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Md2+mgE6RW4MHa+SXve8Yyp6DeXxZM9FEp/3w/n1S85YLlDPECp/q1XjLG16X7Cft G099U8HBes5UAB1jJcdAPgS8gbiRCvqIpNqt8h84XqA4jXGe8OWQWYZJwfdYzsQICs skPnfRHuk4ZPN8rs1z4DfIE0015pie5FdVZ+2+7HZwecj4H4rgCWZzl9rjqKzUI14E 6oXthgF913Rz1CfLk4Fl4b9+Y0CHf8TMVHTZAuAYRIb//Uw4cqDa5spDespf3bslwa xHr8N1B3ja70FZ4FDqRCzXZw5JLSVJMoutkE7cFUvsoNjOyk8kXLbERfZmbfYRF5gv vwpR1TXEKkcfA== 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 v2 07/20] iio: dummy: Switch to iio_push_to_buffers_with_ts() and provide size of storage Date: Sun, 6 Apr 2025 18:19:48 +0100 Message-ID: <20250406172001.2167607-8-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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. Signed-off-by: Jonathan Cameron Reviewed-by: Nuno Sá --- 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 eca5f0652d23..7b5adbb4a422 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -74,8 +74,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)); /* * Tell the core we are done with this trigger and ready for the From patchwork Sun Apr 6 17:19:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039430 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 98D671487F6 for ; Sun, 6 Apr 2025 17:20: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=1743960041; cv=none; b=HcWWOpCxd+M7ZBk/UeG0hXk3fXpc6XVcLxv2Gmx1TPYLLYZ8/kP9FFhgP3EL2/z2fVX8BbmDfjfjyLXVRLZpSAFKgS9SU6vTq/N/1Det72bwewFYU8hbMmuoZA6NoYrKNCeGKsAKlcIzwQJqaiShqB9k7XwnyXvtL/KcRpskpgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960041; c=relaxed/simple; bh=cckiBeCgHuM50hx7XN3+P47dlqCQlPsiu9kcJLJ6SX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B1TRbiQdJ6jDCg8eibyyIdWyWQE2u/qs4x8Z3zrK6hOEv2Z3S/bvbw7oqqsC2eumKdBhICzOJo3HgfM93F/IgOXf0OOLyO3tLxbp//D46GPpgcSPoPRX/LZvDynNGZ9+0GoYLpsaCTGv24O1jBYtCOWh9HpQxrbfaRr7rdXovvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=prH24OLt; 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="prH24OLt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12AAC4CEE3; Sun, 6 Apr 2025 17:20:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960041; bh=cckiBeCgHuM50hx7XN3+P47dlqCQlPsiu9kcJLJ6SX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=prH24OLtn/3vgSGed4rkRznfdSBxSYjGApJpX87qVERm0jCTEIf7pTZpkecJy9nX0 1trSYl725UiQnjs7rAVzjYOWyj4T3eU+N/GjdeSIhyANt/LT+rjqjccVbOdT/wHtcX u0aAo94QtxX5Lm3LeoAn1PUJQ5lHXra5QlprzAFNJlsX6SLvP/G18uoLStYgyJr+uo OWEi2P3zeBZGLDiAKh+Xi0va26jJcIdhE4X9RFuu70LnkYcEjCzhM4SQq067nd0PP6 FBOnByPcFe6F5z4EsNVglgTLgJYlwB4s9rGEYE7xQKfnZ6/YEC/gmRGETXDdnryCfz uJD8In1JNQDXg== 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 v2 08/20] iio: adc: ti-ads131e08: Use new iio_push_to_buffers_with_ts() to provide length sanity check. Date: Sun, 6 Apr 2025 18:19:49 +0100 Message-ID: <20250406172001.2167607-9-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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. Signed-off-by: Jonathan Cameron Reviewed-by: David Lechner --- drivers/iio/adc/ti-ads131e08.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c index c6096b64664e..6e83d370f0b5 100644 --- a/drivers/iio/adc/ti-ads131e08.c +++ b/drivers/iio/adc/ti-ads131e08.c @@ -664,8 +664,9 @@ 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 6 17:19:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039431 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 BC1B61487F6 for ; Sun, 6 Apr 2025 17:20:44 +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=1743960044; cv=none; b=BkR5XvtK4CGNZRUyZ6lunjEso1/KgbKid7s7C2Bs5ObWnAZ5w36jyTvrD9va4FXD0LZp6NCfIY9titcg3X8nPyuHCrH8KZgAO0bTEli4blfX5KtHBaWJS4xs3y3iwa2WQWtCzur/bWszCJE2foz2kaXh9G64ELGKXWo6R+jkwf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960044; c=relaxed/simple; bh=RRyuYTn3tFg4hg2wAdgl7DeHbUBjabe/zZgJayOghvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=csoZtlqGuLKNapJ8fzQVxUwFcScD7EYHTSWzqWVvdHjcv3HjsRrYI1AVM5f8TJeRHDADdWq1kVj5k84SxSikJvPca4mhee0Ye9af707hs1TKE2O4Iz30BA7JaVw33squsQSd71ptbn7SdUYa83OgJg9xHLM5j02abMm5uGFTSDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mcFlxbtt; 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="mcFlxbtt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D27FFC4CEE7; Sun, 6 Apr 2025 17:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960044; bh=RRyuYTn3tFg4hg2wAdgl7DeHbUBjabe/zZgJayOghvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mcFlxbtt0huunJgIW+riQhauJ8EQrfW+cPFkclsdGa4d3+QvW2lpF0c8XwKeCoJTY Lx9A4CIn8tZX88d42kc6DkNY8nizUhoTrtPgSLvDE0ACCrXAzSj2qJn/GqtozbY9JW 5jmS8A0mf5xt0MTLzXA75W+F0CFz9Np9jQ1TtktLN8i8NLszUJo/P6GqMiJzXAVGAV +Mfj9jJN/xH5WCJ7+8Lct9zTNuyNwBIGOa287pY/Jzv1DOudmXN6A0esmgSl4g6JC3 ENQRHsRyw6NeeFxWfB59b+RY7vlvAcfOCEKTfc+xzCPkezN8OzeyFV0MqfBiYQt5fa Bch31M43zfw3w== 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 v2 09/20] iio: adc: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:50 +0100 Message-ID: <20250406172001.2167607-10-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 --- 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 | 5 +++-- drivers/iio/adc/ad7298.c | 5 +++-- drivers/iio/adc/ad7380.c | 5 +++-- 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 | 3 ++- drivers/iio/adc/max1118.c | 2 +- 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 | 7 ++++--- 34 files changed, 74 insertions(+), 60 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..e681a2120abb 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -87,8 +87,9 @@ static irqreturn_t ad7266_trigger_handler(int irq, void *p) ret = spi_read(st->spi, st->data.sample, 4); if (ret == 0) { - 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); } iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 28b88092b4aa..def5f91dc343 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -155,8 +155,9 @@ 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 4fcb49fdf566..2aacc74b1994 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -1328,8 +1328,9 @@ 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 60a4e599af1f..dccb26010517 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -594,8 +594,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 5e0be36af0c5..127867f0c9e4 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -474,8 +474,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..9a1a7749624b 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -766,7 +766,8 @@ 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..e140fa30a385 100644 --- a/drivers/iio/adc/max1118.c +++ b/drivers/iio/adc/max1118.c @@ -188,7 +188,7 @@ 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_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 35717ec082ce..928c9ab04a4d 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 beb5511c4504..d8fcad514ec4 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 5dbf5f136768..32e7938b3892 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..d068b6e71be4 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 1e4a78677fe5..1fc2fe91a206 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 f506ca4150b1..a67da9dd1811 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -592,9 +592,10 @@ 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 6 17:19:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039432 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 2B9A31487F6 for ; Sun, 6 Apr 2025 17:20:46 +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=1743960047; cv=none; b=fygGOprHFLgUn0FjDOVPdNWPbd9tzWLS6UZGMym2jyXo3srsF4asNUnk0EQ/BaHkeZaNtFwXRNkmX2VkJcPCA4D3puoBsxFLcZEXwPWN69l3tAcstncIFay7rED3eQiLteZPI58P8cuPQ7vhreQA6pr58nB6k0Z837mTw7Lah4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960047; c=relaxed/simple; bh=J5+fJiNQev89vYUam01qKG5bKYAz9Ngw3VZUmxWDNos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TfJlWV/64gR1kuAAetn4DNw1tvWEbOOSPsBTOkNovogLjqKRRG7X2l7n0rBxfFM5+YhTx5YDPkj3jEHdkpmLa2J6u3AQ0OkanZNzE0GnxulN4XQGpcaIOE+3TlVV5IH+W/dU5CgB+BAYHTd4pH+kkIFpsUMnQUeJxxCX8qUCEfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YYzXw4CE; 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="YYzXw4CE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6454C4CEEA; Sun, 6 Apr 2025 17:20:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960046; bh=J5+fJiNQev89vYUam01qKG5bKYAz9Ngw3VZUmxWDNos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYzXw4CECSjKns9RjfUIw7xMYl6A+YL/d4ukgqCIiWGVaOM+RBvgsJ0hHKreS7zX6 rwicKJ3cL1MobTCApI0N6SCJ44dWamjd+3xJYfyWiYaITOf0nXwDHeziQ9Jg3I2D/b k0g5EXf5Tl+gzZu9R9C/+8etWEEAvwhpy5sgZFnd0zCJGXZUn9EJ0WLulsnFJlZwjh D8GaxCWWvEZoszsEa2LQNoCufYmh3Do9OOyBc7o1yFJga/KSgrUIjL8YkYFp+WpCwN gOZTziNLzvCVSYdkG+wrZ/klNw1rS3D3rypa7K3Fe4XYZRISnIL2LNXo0N/pklatt6 msMbs32rjUPbg== 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 v2 10/20] iio: accel: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:51 +0100 Message-ID: <20250406172001.2167607-11-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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/accel/adxl355_core.c | 4 ++-- drivers/iio/accel/bma180.c | 3 ++- 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 | 2 +- drivers/iio/accel/stk8ba50.c | 4 ++-- 14 files changed, 31 insertions(+), 27 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..a3af0026f679 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -887,7 +887,8 @@ 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 96ba028157ee..2d27a592a61e 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 0ededf8cfdca..558a79b48967 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 cb5c4e354fc0..e97026a18046 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 ca0ce83e42b2..b5f3e2175248 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 471c154c3631..139234da82d4 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -460,7 +460,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p) } mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, + 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 cab592a68622..a96324ef9869 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 6 17:19:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039433 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 2F4491487F6 for ; Sun, 6 Apr 2025 17:20:49 +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=1743960050; cv=none; b=Hl+jwUnuz/k88I7fSqHQaF9l5ayUzCMQLOn6X5hDGBvj/DYZ+MAPQSD6PxNL64XDRZOUZ/FUnkAQuoGGAA6yWY5YyipCcxqEAs4AUQukPLbYphfT+ANUSKSvjRLYFdTlKT6zVtMYpUFs4KdTB09mZjy0YBTT2GjgatGqX9f2bXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960050; c=relaxed/simple; bh=fNUFePM3b7ToKpeytHsJCtcpgi5vxQ2ucK/nslPCPcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WxiX+TWjfALaknhNrd1tSgWIgVF7bpKX/jgXzZPkX+cXiFDCsF4FmExw8VKgdPPRfSPFc1GED/W7fD72MFGq667LUAHXZgzURb4SsLZtgZWCQueLQUMpHiw8fhHTcVxARavIcMu4Wpwh3RRCqhRk+rgumQKfsLCFZnhD9xHotuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UFmC2aRU; 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="UFmC2aRU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46A0DC4CEE3; Sun, 6 Apr 2025 17:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960049; bh=fNUFePM3b7ToKpeytHsJCtcpgi5vxQ2ucK/nslPCPcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFmC2aRUMFWJn9f306nawkEB8iP9oDAT3wh5JdWzf7l3O1DrUzPSwPebAim3/KuiH 06Z3cmzojL28jAC1++Y6AvdWdE/I2mfN6sOUJwSyxQSfU47BsjCg5D4chMTvajKj2H lX5KhwCUcnNBgb86mIZcwAN44tO+QJyskeq8Lp4VqyteWdXaV7pT2oZ9mvfJPjU+1P 74kTCiZUbKadi8OOb8oM/kehMVX7uAzk3NR53NbW1Wt8ON3+fWg7rZNSBxl+BRdq2c tDsrNefwQcjGznI25u891PTIHu9NA6bEdpPCRqS++iYxwtFCARP+yLVDVFrbJB772W RVbMRyJYPKxeQ== 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 v2 11/20] iio: accel: hid: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:52 +0100 Message-ID: <20250406172001.2167607-12-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 078fab2abb68..fe3ef3592e91 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 6 17:19:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039434 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 95ADF1487F6 for ; Sun, 6 Apr 2025 17:20:52 +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=1743960052; cv=none; b=FB1gnRwVm5q7ssVrzhlKboUzkgrIbS2HjTtrRl6i9R3xSkaCCr0UO4rpgP1U09ez/xUyZu/6LCZaM03oU5aGKibvpdqaTy4fKEosTQYSV2uy2kBu7PyJoPdPC9VsRvf0NAa2xA+Fk7i0qtuw/dH09Wvgn6N9i1xCNCSoetBP4EU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960052; c=relaxed/simple; bh=zrG5xFKeYlA7zxnU4/g2pIMqmBGn2uG9o8FJf3eKWxY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FybXHCLT/eKZgvfkEIBdy5gIzbWN7xoRLP4sDD8H1tgws9WgwkByl21ndZbeUMLt3EtdHNwxfkqQtipxiHGrcptB2MCF79Am1MhuDyStZgQXLX1ZtUuurPd8QR2JMXmMbYg/Gdbf3jW5yNFwycxsOeUZ2FSwU5xc6vz6LEQBYQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZJvlAyCq; 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="ZJvlAyCq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F14FC4CEEA; Sun, 6 Apr 2025 17:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960052; bh=zrG5xFKeYlA7zxnU4/g2pIMqmBGn2uG9o8FJf3eKWxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJvlAyCqPT7nOePiYm/qgQQB8KesEOID7iGLrDWJYrThOZ01rhwREXLw8S4P5/ZYW 5zujjYZ8E0wiuYK0pT/6A0ArrjXPfdnlOFAimWkgG0Yd38JH6uAQSox7kNcbkEdZHI jHxx+Ad8BnMnEovcrlSGAyDQ8oYFmtCri5oUYVi8ZmDi4on/+3MfFsb8e5sR44s72G KGg5ln6S690K4cPwwZ1sl+d+yGF0ZXslM9XWRUWqJn0meexlE/UU5471tVfuSctoC5 weHaAkldohqgySdgaR9YZ+Fmn//vdYF8KxNZPJgipNHDyk2z/mB0Id0FVYSu6THzHk QGIFi+FMdFXtQ== 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 v2 12/20] iio: chemical: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:53 +0100 Message-ID: <20250406172001.2167607-13-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 | 5 +++-- drivers/iio/chemical/scd30_core.c | 3 ++- drivers/iio/chemical/scd4x.c | 3 ++- drivers/iio/chemical/sps30.c | 4 ++-- 8 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c index 593b73ccbeb7..39181bb3e953 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..d268d05cdec9 100644 --- a/drivers/iio/chemical/pms7003.c +++ b/drivers/iio/chemical/pms7003.c @@ -126,8 +126,9 @@ 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 6 17:19:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039435 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 599931487F6 for ; Sun, 6 Apr 2025 17:20:55 +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=1743960055; cv=none; b=QhEeZD3/aPQlFAAH91qmkfl6Owfc1fv0b669mlpBpE/l+p9YEsNLfXzEh3rW4E/RkacqYCjwWjCMc5QWXRHePu8xzVTwlNzynWgoPMOV6y6BofxJcBwk+ZmHF3h+y6PtNgi0ccqTaV62nKy/9xOmWmspUObvPblNe4k8AeA90LQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960055; c=relaxed/simple; bh=9uy1gDWjKJ2sFZwUHmxI8KKbNHVtzGcCIRyEpJTX0Rc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qisheIvGH1UFKeFbBzxzmuttXgedCIiAEXGA2wMKzsejS4OrvAkFahtMR98NGJFFehScDDoGPuhELxt24yM5k3VUdgcRpEJHQq0yFeq6O0Z7p4gFg1azUKMa1qnjFd/LQYz/SRUXbrocsuy5+9fKz+Pd1Mc2Te0rirwewTXG6vg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GviZu8I7; 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="GviZu8I7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E02D3C4CEE3; Sun, 6 Apr 2025 17:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960055; bh=9uy1gDWjKJ2sFZwUHmxI8KKbNHVtzGcCIRyEpJTX0Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GviZu8I7RAEO7rj5yNvruclX5icAt17Tl/uprFSluuyBqpohOWLkAVvkB3+LBjuDQ n4gib2qES2++2BbWGbf9+8OGCCBB25E4rDmE6omZTBMouzbIxA9z1GEtbEdwNg2oQj qzeOT/FRlkFidHjT7fujh+V9f2TB8r8QNpGhmRNxn+Cyn53Rj/ZeBOG1FPeSUCzoHK o3xtErq1UZGZhRtKZHx/QEhTLqutTesEwtTVM8o5niQJ9Jx7UWubVGsGVBZj5+i8aJ U7YMq2qBGVS3a+xcl1TxW85f1zst1WbZRLFxAHwtdXF0RGBLmaPBKf35G7sERqhTjs 01Fm2sSmI+9lA== 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 v2 13/20] iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer. Date: Sun, 6 Apr 2025 18:19:54 +0100 Message-ID: <20250406172001.2167607-14-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 a13efde76397..db2149d5f78c 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 6 17:19:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039436 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 D54B71487F6 for ; Sun, 6 Apr 2025 17:20:57 +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=1743960057; cv=none; b=gtbE/RzRDpjtiaTk6HJQcKH7s7g9vh5tR2UIACacRsZjSXXjz0XxAuCLBJu3lCywb1ZD/aGsp121GdKEutVz+UU23I6QY/l2dcGG7KsfMuY8xo5XlQaTN0/je4t2v+yc04qVG5zONgb7U8S4Z6CzNb5qCcapM5d5PZaNA8Hp5Hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960057; c=relaxed/simple; bh=n7wIqSLwJOIAOMsQrvyspqYXyNkAYFwi+RB/2RRduzQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y35azBXlYRA42nlIVS+o8x3c34tvbk7j00bh3XpCE75YtXRdcHtF2p5Kut0OnIxIhETsga2D6Y0YB460+boo6JtwvA7VULJMjcwGSdoscWMPOa4ixMQhv8ZzqVLpWUT/vb8VyYBYq6H1YWM0AD12I91t6LjMFF1uLG4xOg0tRUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZVYHUsRv; 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="ZVYHUsRv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16203C4CEE3; Sun, 6 Apr 2025 17:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960057; bh=n7wIqSLwJOIAOMsQrvyspqYXyNkAYFwi+RB/2RRduzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVYHUsRvyaDzauNi6iUxqYZP8Jlg4889Q8V8Gt5obDW4wHuQvsoKH+D/KSkdHYvO9 4pONtKOW+9xAhEebhr8rIS5cDFbs4VAZbgdIbiQnFzXs1z7/Xwdhh41Guk56YZlgfI AcuJz4Te+3bxj5jgiXpqJ7hdl/Xnkc3ks/Dt3cdg8siF6v49KhXrd6LIfw0ABg9cZN SA5lFHxJB80YTX3bKHm0Ob8eL/tv+wgeQe8V1uaCWxX/6XM9lZWInjiHgA8Q3xj5BK CljoGtps4grCoMArfGAOD7yvrrX3NgOTYIQ4plsayagKy5zw/FPpZo3fujdOjlkb4r zk1G2c1pu6WzQ== 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 v2 14/20] iio: temperature: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:55 +0100 Message-ID: <20250406172001.2167607-15-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 692520e1c497..005106a9e03b 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 db2149d5f78c..2db13d381dbd 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 6 17:19:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039437 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 19B8A1487F6 for ; Sun, 6 Apr 2025 17:20:59 +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=1743960060; cv=none; b=niwgb0pTrf4KuVTkRwQ7rfahyvyFB5y923eraq3XIY3/kV1vp/Ie1HkyjWGc1ZEyJzjl8qHAuN9JGoCC1lCjTl0ECXZPlv2IT7ID5168j1QoZryxwMeU1Nq1T71+JOGVFYNgbAyfXYDrQbRAFpxeopBy5Pbq7wDgnbXneMGxqCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960060; c=relaxed/simple; bh=9E6lJUXBZG9MHuc0TPKRoODte0DoulOyWiMalyuUveo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F+3jixSgc3hZHVvnhXBrbU1K02PhnSy4QaPrNZn+TRwytGGo55+lF9NJzgJ+GRZnpHUh56q554KTGOCba3jwbAnKje6kv5QGRlEy3Ms03okRIyQMPvW/HGtiDRkJNGuBGNzvN0NIhaRpyec85cqdnoFUWzSA8hCceFS6cZAf4gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WkD1plPj; 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="WkD1plPj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25B28C4CEE3; Sun, 6 Apr 2025 17:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960059; bh=9E6lJUXBZG9MHuc0TPKRoODte0DoulOyWiMalyuUveo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WkD1plPjgTBeTabO46/Q4BGSgO63iHBPMEsjWY5+GEVAq1HcNRIWwRhXgnTh5OSj4 bkmdmmKRasDVQTCX/2JQzJAIiIwZUUOHmVcifW841JAqcDnKb4dN0ATRpL0hMFZvBW OtJ9lRXDzXqyJlfQk8S7edDceSbvaphOjyUC8GUqp1cO+vdvZLqBWCPpts4BKVArlk 1Pb2rGe2/Fkrlr/mf6YBb+nCehiXIx0mUOgSOA2AlYVe3FiCod/nB3GoQZfIZg+0Bm Duczk9M/cz7JM+xUjHOQvznnjfwDgU/Na9qpaf8QdAcScia1RZYwLN4GrTZj+luhJz SFxxBsjy58Apg== 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 v2 15/20] iio: resolver: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:56 +0100 Message-ID: <20250406172001.2167607-16-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 ab860cedecd1..f79399353b0c 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 6 17:19:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039438 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 5A4D61487F6 for ; Sun, 6 Apr 2025 17:21: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=1743960062; cv=none; b=T7c5vgDaoiQYzj0QH9bVt+shZttyjiHTpbsi56tbsj8vrncUQit/ldhTGihk1bCElS/AozflprUezy0Qz9fJu/PlYI0xizo5n2VVup5n24k5K2SHC1qCs8KImgea7AWXUD/PM0zhZDsVLwbSPjBUfhGoDQEh0gWRabPjHicVM0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960062; c=relaxed/simple; bh=DOqfhQzSozf7YdkIxQMRB1DIbXGfVmHcfOFSV4qRBf0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FR4raz9YWbaLijwh3z1ftpxBhgQeDfzgXAl7nzVsYz7ITNeydbZulK448gx6o9irh5JC8oHN0NVFywj+bkAweaafdWpnvcKI+c29AMQn00Xa/gsw40GlHb5UoUaLXO+NY7c3BEM1ycXHYY6yDz9KD9wiBKk4g+dR911aOfYYVB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=satz3QMh; 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="satz3QMh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46639C4CEE3; Sun, 6 Apr 2025 17:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960062; bh=DOqfhQzSozf7YdkIxQMRB1DIbXGfVmHcfOFSV4qRBf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=satz3QMhtqgVIffgvj8YOk95PAXVutS2x+iDbpJhbps6NT5n1ZlqAaOBZRolV6w3Y FeqgOm2DLAY6Ip3GWY+KEuiTJvo1AGxx6LsgAXlxT3f/iXjoKaVUq8kKL302fIxQKo 8kMEPCEt3x71EnTR49yEAl5Mb1asPkJmrjwAXjecmqvL2qZka50+H9TdhEeMnED2mj 8Q8jwQonJQTnaTZFJk52DQbrGpcOmiS6jMgqbIk1FOdPKGd9XF7+KV/aKt3ThOQJQJ Gfv/ioZlfXC85K30IU5jnhPc91UAoiX/6XRtAqJpNhfJXq3keO8QGUXaUjGGK0Ybp/ 7PyMxT8Uctp8w== 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 v2 16/20] iio: proximity: irsd200: Use a struct for scan and iio_push_to_buffers_with_ts() Date: Sun, 6 Apr 2025 18:19:57 +0100 Message-ID: <20250406172001.2167607-17-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 b0ffd3574013..ed15c06c8ef8 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 6 17:19:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039439 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 566621487F6 for ; Sun, 6 Apr 2025 17:21:04 +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=1743960065; cv=none; b=nSmyJGL1IyDmWdUFhCH+roxZrhkgZ+be9XqVY3FTTxGWUaPB86a2KeXYbpVxa7kIvrUsx8luCGdRmfMoH1bBcLVepJnC1yVAa28921RfwC7tehWHtRyrTZU2Kd7fCvW6U6xVcijWjzsNiWKWjNNQ5zk/j/DKfeGF6oYOpJbDApo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960065; c=relaxed/simple; bh=gYh5T4U2NnqW6T95B7U7DRqxeJJlmQarp25sdM315b4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hVWNM0lyorg3utwoag2UDqFbr0PZRBjt+8f9e/Dgi4Fox5ROwuTX0zVb8c5Vd5l58t6deJ5LlzW6+biBzf9qKSr6lXc3WNdjFmApp9drLgNygwdxWMw1B0ESO714DU7E5Yr5xmK70LGXi4GZlJPInM/OdNWBsVSX3938BtGsxeA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HNdl0/69; 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="HNdl0/69" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B63C9C4CEE3; Sun, 6 Apr 2025 17:21:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960064; bh=gYh5T4U2NnqW6T95B7U7DRqxeJJlmQarp25sdM315b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HNdl0/694BhaAGE7+FtncXw3mMv7LhcFfwCjmxWo4TCX+fI3X+kgBxsQ1c/LPFsWr XUMoEQ2kzXN4cdSbBRhIBHv0bLWoYg/yKYjSScnGcnEbxwQrCKwGidOvfb2pjSPoy+ /SG+iKhc5gCYQ+vCPLFSXYEIIzPOy94VZQxD6uzio3RFA8cinBI+/c6xlc5NxpfkZk xcYfPzSq527qzAsqIT91zlVP44JBXsB5Gj0gs2Qb4FhyVsj6+6GoUgD9fU+ZfuGjRO Vl2tSpRQ4DReYV7OwIBpMDBWZybmx2Oc6i6nXJrLq+4c2g8e11C2m6zlNwUH9Kw1a9 h8aDP8zO9z0Eg== 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 v2 17/20] iio: proximity: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:19:58 +0100 Message-ID: <20250406172001.2167607-18-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 9d3caf2bef18..d91a1fefe74e 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 5be5f4986347..e49d5e226fea 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 cfc75d001f20..1c3a23b6dfe3 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 86cab113ef3d..694c943455aa 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 6 17:19:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039440 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 EB7271487F6 for ; Sun, 6 Apr 2025 17:21: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=1743960068; cv=none; b=tdoBYikj7zLvnyfbWCOH+QHronG5KMyT7pTgBBUuXZBP8VC24maT1zrm9JjTZL22keyY2bhLIBdsaUMBaz9TBjaUSYAZOO/xXggryCFcY+lgJH2MKMJoVApsF+n3MVqJdWIF4jNhKziZOHwV8IuP8N5et8OEABSnCytl1zCtZuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960068; c=relaxed/simple; bh=js0cKWb2TK+NH13fFKlcUicIJeUNidrwWY12NGr2SII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lolWCIpXHw1e+jPwTjDdl43te0gi4Dz8S2y3KpvpJGDRQyHwF1z+zrX2cLidGZedSlVlkbD7VMPHIN/tg3wGIx653JqvrSwkQGfgZ/uyTPwNHsy+7xy+Nz9prlSbjHWTgozNymJLKnggmBjpnl/F42hy1lst2W3iRNwvzRxCjoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LAepdR7s; 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="LAepdR7s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96BBDC4CEE3; Sun, 6 Apr 2025 17:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960067; bh=js0cKWb2TK+NH13fFKlcUicIJeUNidrwWY12NGr2SII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAepdR7s0B2rUPnZsGSJFzv0pQWPWudHWFMWZ8twzKXzbr3uT46hnp3CtSC/LvmfB XhD5OQgS5CLUUV62rQddhMZOa8B7paN1OGKDGIhMJ6vgzrFizGGOIdKwk38w+Ke9Zz /3AkTgtETcyYGAS0NAXgDkKIVXd2RmpawV0DRxCdOrbsoWSNrMBQI3HN+cEHC5QDAB 2DEonf81OL5O5cfjBlet3SykXFvTlVbR3NzHxTlZCKwWCznqa6OUeDeS4Bd9e69XwK bYpbUOYfbHz3WWL322U/01vjT6fuQIcplWgWc8cMOGXKFdJfOFZJAKC7JJpokuewzu k6solSQyVH50g== 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 v2 18/20] iio: pressure: zpa2326: Use aligned_s64 for the timestamp Date: Sun, 6 Apr 2025 18:19:59 +0100 Message-ID: <20250406172001.2167607-19-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 aligned to 32 bits. 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 6 17:20:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039441 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 6ACAE1487F6 for ; Sun, 6 Apr 2025 17:21:11 +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=1743960072; cv=none; b=R07eIYwt8LQn83MG3zW0udKghk/T1pcdkKmoaxhGPHkNK9TpUc2K1vMfmaiyEBP90NmCMe0w9Lad36ArP8fzTxLKZHY7dvPPXFomsd5AcXEbJnqrXi8rjbXUkjyyQKRE7efKNAhjIpnbgVIxn7V0BJZZVJXV3IYdrMpBec1KP3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960072; c=relaxed/simple; bh=Jso09oURncs+WA7m5qihotdrpcfVf4B+AAstsv0BA0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k6cQ2utGRn3yRMIBT09bk17cU1bOVIk3wH9bRWUzOPGrzrKZsYD10rkb3wtMitRCCmwEbnYPcVBGwsrxixKKVqBah1V3gDEn3pH2+ARnLH+z9rmxgDLIaxnzQMaKEwktba8Ksn2VKpDG70f732C/V9DW1ek+30idRWWMrdBP53Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VeRR/IhY; 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="VeRR/IhY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FC58C4CEE3; Sun, 6 Apr 2025 17:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960070; bh=Jso09oURncs+WA7m5qihotdrpcfVf4B+AAstsv0BA0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VeRR/IhYjvD4fNqKS31hfbdAydX4xOMxC07FQUjJ1VKXXNQl+31HFuvlfBX3rEwLH FNYaN2WzO0zkL6JJeoMsIQrXDrvTCVGpdU7hw4RfXtfjXvl6eFzFfYnX10jxCkIxc+ FqWuZcurrpqH6Mq3ce/E8JuctuKZl6tKLxE0vtOUaqBS5iU3TN7ksPvS0sfbID4IfX GFeVyeuGMz7qvre3N7LM/4ujb6a8CwT7nzPXJchD7B5Gucx8+7JZ3zNWnpYxJn2h51 N1eGlW5H9pgsa1jGvUbjoIWRpo4YKSWWt52MKB1yZDt6a0IdCRY7TuB+d6BulW3JXi /bnck1acW/skQ== 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 v2 19/20] iio: pressure: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:20:00 +0100 Message-ID: <20250406172001.2167607-20-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 Reviewed-by: Matti Vaittinen --- 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 f7273d30c5f0..a8561df9f666 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 c48231739f48..cf5f48874a68 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 6 17:20:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14039442 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 DCC401487F6 for ; Sun, 6 Apr 2025 17:21: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=1743960073; cv=none; b=UMZFBLhUc4kjZmKX1tFJydJ4bjl0OXYZufO1r6wbYbj0sU/bASmwqViAgkjeZ4NL0eXZB2sVqUrM/NN9R2fdIDZ8EJWAgoiwT/M8IeLXVNb8mfHAb4u9o2z692GoLjwGk5XlZF6Kr7uXU66wLFelpbVufRJP+Zfu4Yo8yOR3n50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743960073; c=relaxed/simple; bh=yKTrtyJtsORhzbs/Q/E6Ysgguin49g4DjTe16XauQk0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OupQKajA+xGiFyziiT5YnYryK8MvmVDxbEVHJ0e1of6yJ2TLyvfIWuYAkVo7T58UjiJtw74zZNMXGh8iGu//ETRnDX9rHMjfR1jTUI9oOqyevVl7BjkiyRsxLd7jsCNCYjCHfY6FDs4k7o2aH1zBxWCFsjPHUdJ9BkR6T5y4k1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EiZdYpqF; 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="EiZdYpqF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8749CC4CEE7; Sun, 6 Apr 2025 17:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743960073; bh=yKTrtyJtsORhzbs/Q/E6Ysgguin49g4DjTe16XauQk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EiZdYpqFDCHVjteI/IMZ0m5xhK+kmG14OC4Qwbx2LsGL0r8DVPIqIze3FMlrln8j4 kvwlhwx7wgI9Mg/4CvJqtAPCr1ewKioDp8zvKfT9CjAF3h+F786OYVqb6414++qgIV BorVIOdjn+9WXBD7vYy44uMGFGJRMgy1hTHpIX8mXFg5hjSQf9JrQLvVJMRGuXix4E TH8kTWkrIarfsCordR+J0k0YjKOlaS2JODwWhko8PeWpwr+cF7kdq+NycMVggYkdmJ Ccq/EpLHFm3Ohq4TvEAe/HFR2wYpSqUwAawJz5L8a4DGuMUEBMeUVOGym3Hw2y+3aX YsikdyxTVnFwQ== 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 v2 20/20] iio: magnetometer: Use iio_push_to_buffers_with_ts() to provide length for runtime checks. Date: Sun, 6 Apr 2025 18:20:01 +0100 Message-ID: <20250406172001.2167607-21-jic23@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250406172001.2167607-1-jic23@kernel.org> References: <20250406172001.2167607-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 | 5 +++-- drivers/iio/magnetometer/ak8975.c | 4 ++-- drivers/iio/magnetometer/als31300.c | 4 ++-- 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 | 5 +++-- 10 files changed, 21 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 44d8428a69b0..6b784af7d779 100644 --- a/drivers/iio/magnetometer/ak8974.c +++ b/drivers/iio/magnetometer/ak8974.c @@ -673,8 +673,9 @@ 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 ef1363126cc2..abe9f4fccf00 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 87b60c4e81fa..d5db4c8343ce 100644 --- a/drivers/iio/magnetometer/als31300.c +++ b/drivers/iio/magnetometer/als31300.c @@ -245,8 +245,8 @@ 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..81da063fb38c 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 28012b20c64f..6ff34b3b6a62 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -674,8 +674,9 @@ 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)