From nobody Sun Dec 14 12:15:19 2025 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39C4028F946 for ; Wed, 7 May 2025 20:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650624; cv=none; b=LQmSY/e0cmDxIoNTKDXcWdizOH6uABLMXBAhgOzWhXD97Htg0MopPdbXvfxlYfMGEjlghakcc+WnX+7a83OpFxJgzrxTlNeAw9jPXjBe/vxxoz6sLNpL8o9hAZp8D1oc3VzDPa4ICUA9e7b+R1YWphzYQSHgTUo5O2j0OJ7rlpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650624; c=relaxed/simple; bh=KXhEzNu9vMA0LlJD+DPGW7NGscBEnrm7VeMGbRK9U/g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nN5Ojp5UY49d/y7x1rsvg9iM2LR7QKCWtH0aiulGoLZfzGhokkF4XGJsWk5HTqHZN0pp2v3TSU/9fmSoAWdbDZDM8tKCQSeEtnnty4Ko87LK8tTo33CbCi4kcUvpPBOXPhZodDJ8IV75KEAbm8Xaydvsc+lL2PNP1pvW61Vr3B4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=AztOIbFo; arc=none smtp.client-ip=209.85.160.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="AztOIbFo" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-2db2f23f174so208174fac.2 for ; Wed, 07 May 2025 13:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650621; x=1747255421; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nsDoH9wedifhugPM5JBN/pxKp+uLG0gE7R6WQkp6CbY=; b=AztOIbFo/40+dbLiN+K9vEq8Q27BO5256hxM2PWEh+9azhPiRF2OWGyNl3cmAv3PYL G1HfNh/LgS/UM14FNTG6HwYRhakNKv3ku/jymdVqI2KTeF60u7bXU5UDgN9dP7c4VBxw l2R0pcMv4MxYPL17ly1AjRVs4d2IYb8BDTZd3my4BrPo8pLV6y2Fr7OO1puFTbV0KPDq 3wvjf77z5F1qnrDmVSIbRU0Vr4kz9lRD2Dvc0OZY+l4C9JAdO8XsSlMk4AgOnOU7Wq10 FMlqpN70WyLGVmlavxiUa5H41QyqXQF+exFmwXgChS9s66OAxkgA1luNYWMPdfZQgg0N ai4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650621; x=1747255421; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nsDoH9wedifhugPM5JBN/pxKp+uLG0gE7R6WQkp6CbY=; b=nnES9vlu9k11D61OqliZIbeSub0oMo2HcS9LnI097wovw3g/qacpdX1PmcYWGpXou5 YgUVCy5F9EwUbe9IoAfSW8PnNduKergerVJvqs0SHuT0hnnWncj0wTQmUTpaTiDzNp64 V09W6kZ9wkke2oPzeJreAGUOggPzWe0ixNNZHCqqC57YMGJHz/VuEMis1zPeOH3QmLxa eA1O1/fk1bB/wi/TBEk48sgDBgSqJF6SUc73VnzT3QjY8vfOvnRi3pNR3iNUfvdvGF2U YSxxqsOZLdX7Vkl59x4UiMwuz0Vo/bxG2rg+x96al9gxo5T/Dgc/k5itDgjW2R9rpndj y02Q== X-Forwarded-Encrypted: i=1; AJvYcCUqrEs5s3BsU3t81tjxof0YT+GD70WYsYAsmj+exMpNF0zlUCclehYZ6ZY3AjUCLEpcEvJxj9llxqIIYKw=@vger.kernel.org X-Gm-Message-State: AOJu0YzJLbmfPJbIrhChHedQXhg02pqp9dYTfgOuo8bnPxBOK8lMOPPM oYdlG6GhnFurzfzsH/7w9hHredDshTWi059U3Kamqm2bp3KzjdFrLj9tlBNfbPI= X-Gm-Gg: ASbGncux52ghF47yRN/JsUimd+HOLrg7IAeX2Fxhfsdc1VtImbPK4bm++VEkNC+naUI cfDLyQRV5HqNA/B07Hw0K6EXlOKrDFLZNmCXdm4lSubSvP6s1M5Ssclg88GkzLeBhaX9e/4OtP9 Y/MfcyXC3fKfV5eZ25NAfS5A1SNTdXnaI5sMOUMn8ZG2epbv0FxofzcglWlfYr33y1DvImAj2v7 qocfULWp0etR2/uoJ5NXjNDo4ROv0QXH4uFxZJdoCR2n3S9M/+54qGLP7PSUhAwvVHYM/O0MaiR ra6VJktaQ28bk3pz3qqdukqcDsk/3A7yTqp/irW8JYB/kQ== X-Google-Smtp-Source: AGHT+IGuMbSopsw0kPB3BOKdZwGLMyA4fTqZkg1sp+VqbZBKSh74y17YUdx5+VNzA+Dlkjgu5EqA2g== X-Received: by 2002:a05:6871:692:b0:2d5:d5c:a851 with SMTP id 586e51a60fabf-2db5bd81d15mr3352825fac.6.1746650621211; Wed, 07 May 2025 13:43:41 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:39 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:40 -0500 Subject: [PATCH v6 1/7] iio: make IIO_DMA_MINALIGN minimum of 8 bytes Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-1-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2051; i=dlechner@baylibre.com; h=from:subject:message-id; bh=KXhEzNu9vMA0LlJD+DPGW7NGscBEnrm7VeMGbRK9U/g=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XMenAMAnq7gPRRFS22x5xeEEEtJEsUd6xym y6ke1GkKsKJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvFzAAKCRDCzCAB/wGP wLngCACRoGSeRFy1n5EjP/iotCrHZcEvDzkEXMr6F/ZItm2ApnS+GHg2GEuOB5DOqzcUTIIXHCL 9KQ+3veOSVxITb+z1+PHlVLj6hf79gLTAyV7h9dW3x8s3rY3fCT58TNwyK7/Se70eOlNThdaIu2 pkXyZHdfmNZPSjbfvTMxxLG4PsvkaX1byJZXk40WocOq0pqQXFzD/5+jvGeNRfsUHhrhPN0HCJL Eg2YmfnUHvbYbWafrR8i25s9cd+kPm+MKU9xU3mEjale2EtU96Ej0fX4fvekuvWL8X0rClfwM3S cdjsFjvGtSkBlUpbBSnj3SZSLZBce9MRNi27B3UPREc1YOcX X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add a condition to ensure that IIO_DMA_MINALIGN is at least 8 bytes. On some 32-bit architectures, IIO_DMA_MINALIGN is 4. In many cases, drivers are using this alignment for buffers that include a 64-bit timestamp that is used with iio_push_to_buffers_with_ts(), which expects the timestamp to be aligned to 8 bytes. To handle this, we can just make IIO_DMA_MINALIGN at least 8 bytes. Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- v6 changes: - Removed the #if and use MAX instead since apparently clang raises an error that __alignof__ isn't defined when used in a #if condition. --- include/linux/iio/iio.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 638cf2420fbd85cf2924d09d061df601d1d4bb2a..a574f22398e45cad1ea741d20d3= 02f88756a1b13 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include /* IIO TODO LIST */ @@ -775,8 +776,14 @@ static inline void *iio_device_get_drvdata(const struc= t iio_dev *indio_dev) * to in turn include IIO_DMA_MINALIGN'd elements such as buffers which * must not share cachelines with the rest of the structure, thus making * them safe for use with non-coherent DMA. + * + * A number of drivers also use this on buffers that include a 64-bit time= stamp + * that is used with iio_push_to_buffer_with_ts(). Therefore, in the case = where + * DMA alignment is not sufficient for proper timestamp alignment, we alig= n to + * 8 bytes instead. */ -#define IIO_DMA_MINALIGN ARCH_DMA_MINALIGN +#define IIO_DMA_MINALIGN MAX(ARCH_DMA_MINALIGN, sizeof(s64)) + struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv); =20 /* The information at the returned address is guaranteed to be cacheline a= ligned */ --=20 2.43.0 From nobody Sun Dec 14 12:15:19 2025 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0489E28F94A for ; Wed, 7 May 2025 20:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650627; cv=none; b=TD6xfENA1HqkFkY7WTKtTSyZY3Y1Tt6rjTlE6rV7dDo7GdOx3bkRayu7dXihShuPrcSjVBZe7exy2TUncwATstUSHNYccD5COKyLaV4xbWmpLf+tc9Cs72jOAAvjKJW6gXuSiQ31mfDSY1aM/er+jOar7qnRLl1GFFtSaYkFe5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650627; c=relaxed/simple; bh=Qkz6TboWaI7MFHoD3asvbEdknvmftSA+W8rgLRn7UjM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qIkEsDDpVC8SmAb8zvYkPdoXEnrFxuvmouE7fiWDD7QLemkpNhSgkR6zFmNg3t/33ZNASgGpw0rNqCpMMv/EDLmKdXN0135QjW3QlVrEwizMJ7kGgrs8rgQcZZTqJCBm9moeHylMStg5YT80mDd87PHGfmtz9natOs1PxsyV8rY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=mH4Kug5w; arc=none smtp.client-ip=209.85.160.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="mH4Kug5w" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-2d4f832069bso207325fac.3 for ; Wed, 07 May 2025 13:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650623; x=1747255423; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Z9C6eh6cD17EJef3d5HM9D4tHLrLT86syKoOQcjPQwA=; b=mH4Kug5w1lChHbBYu8jIZXmirJ3eh4oQEEjeZYC1lceGHh41VgeJPkyyWIT5PtpFUO r+DSemSuVOg/QEjymfh4G99CanvuRTtISTZsshyYKwBfDEOw48Y4YgP3AQ9s2U5t4sja TfJQsHDMP6tm3C31bMeiK3EVqm2vKhALfENMAW2X/7ZcmhNAvqqib0pjlLhJnSvphcZy HrbW0gpzaMnTd21/4YUAx6E2qwJ79Re+uLNcR2GaVAAT2GBlp0KgNtuP2tjyHRe8ewse X4P0GZ43Xzs0i4l0KzwL8XI98DFOg+3mMBVLe2NvKhx/WIvPOm3ERj/FQS7hi/Ancppo y5Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650623; x=1747255423; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z9C6eh6cD17EJef3d5HM9D4tHLrLT86syKoOQcjPQwA=; b=EtJAMNOTEYEftdFEpcFXkAqIr3LVufi3xfQXk478FE4Ijq6xCnCqKY+r2ar9kbN3A7 rN988H91+egIL9qcp6ZOP8udbLrB7LznZIamIeachj47lGGp8A0IriwmVKRc+GPNQkJJ 6zYJRMRMHk1mZga8sCt69Cs/0731k/rY+CXguUv0ISS5l/En7Q6LJTVrpMz0WLA2DQWw 0D+LA1gTxvM0fFttBTRNRtNtGRBZO8Jht0K2+KT77EpNhgnd600Shf6P5lnP3ELFh5Mr f4puxSs3hY8KJHK8qUA4ziVaMG+4m8Pd9MgkR7qAObW3u/m/ttr5klalwpk9AxwMkmWJ mlmg== X-Forwarded-Encrypted: i=1; AJvYcCVQd6hMjQy525ghbgBm559botop4UG5jIsTpFf9PSw++qyKuhVjGUAuAv7unL5dWBh+5VfAg9TZ4/MWioo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7LSs0s1XAgrOf79tCY2R81rWWI34yoQk1l/cDa2naLFudGruq /qZEUQ6BfmCix2Zt1x0LtjPK0WXh4rZPp/HbpC5o6fAfgEYj55xERmdtGSQXLo4= X-Gm-Gg: ASbGncvFTB6OBkoOY+kgF1Sax1z1FmUpS1yIGw7ezVncNY2YG+O11pyeON6titBx8oe TbIjL2Kkd5BXVX2hOxboOpNDJ2uwPVgneDzM+EJosgUsp1SeNLNY9c8G3MRYN5qcLh8KYM4m88U Ptw+tlvQmoJQd42M+zR25r1nUesxmXPMq7BoOY3h18UwOKeWwawdqRl2x9TD8TLnvQujELMvj7c 1LxsecT9FzZym/TQFztUGVBXHcYQfoHa6Kv9HI5f5ruUXzFiDYqPpvCaSV6F7GN4Vj+8mEXRkDR 10Mc2F17JTXMOzZdpsc4m/ozpN2fmIFEVOrb+9196ZMPg+/+grxD8uyg X-Google-Smtp-Source: AGHT+IENPH7fJFVZWI+5hLQbltsb6uPLojsgCu0d4mLuhreNgObStagGp6+xSfl6IozpO/zVgnEYcQ== X-Received: by 2002:a05:6870:a7a0:b0:2c2:3eb4:e53 with SMTP id 586e51a60fabf-2db5c126f05mr2877972fac.37.1746650622970; Wed, 07 May 2025 13:43:42 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:41 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:41 -0500 Subject: [PATCH v6 2/7] iio: introduce IIO_DECLARE_BUFFER_WITH_TS macros Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-2-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4238; i=dlechner@baylibre.com; h=from:subject:message-id; bh=Qkz6TboWaI7MFHoD3asvbEdknvmftSA+W8rgLRn7UjM=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XSBGqWPSVzxaO0ZMnShg5EsgNFTw6d5cS5L syZI6ewvIOJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvF0gAKCRDCzCAB/wGP wB0AB/9zqie1eENWSL0OQQqBATpe+2eVgIQGMFWAEa7WJHYw07K73zYwEpmZbJvfjFhPZzv57ot hxvzp7Y94iu/G1vwtc/vQ88etn1VI36o5jAMreTZHcLTQEhizFV1b217USh5XdaWNhEYc+3aHu5 y+sIQtY93SDTnbG0utUX24FNFXmUwc1+s0KjcsA3Ccdyp/nlLLsL2ufTNdYMu0uVT5IrcGrLKiG KOX1enYu/mmX0alZqmCPeQulRunaS+JiZe6EeUveJb6Wqj+9exstphlnAZk+J1y77ZE2e1AuOhh Fa5k0E3X+cmHL3E+zO/B5ZHV3CpOoDUzaQRcCKPJSOUO2vMG X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add new macros to help with the common case of declaring a buffer that is safe to use with iio_push_to_buffers_with_ts(). This is not trivial to do correctly because of the alignment requirements of the timestamp. This will make it easier for both authors and reviewers. To avoid double __align() attributes in cases where we also need DMA alignment, add a 2nd variant IIO_DECLARE_DMA_BUFFER_WITH_TS(). Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- v5 changes: * Revert back to __align(IIO_DMA_MINALIGN) as IIO_DMA_MINALIGN now has a minimum of 8 bytes. v4 changes: * Drop the static_asserts(). Some 32-bit arches were triggering one, so we had to address the problem instead of hoping that it didn't exist. The other made a multi-statement macro, which isn't the best practice and didn't have a way to make a really helpful error message. The condition we were trying to catch is still caught by -Wvla. * Changed __align(IIO_DMA_MINALIGN) to __align(MAX(IIO_DMA_MINALIGN, sizeof(s64))). As the build-bots found, there are some 32-bit arches where IIO_DMA_MINALIGN is 4, but we still need 8-byte alignment for the timestamp. v3 changes: * Use leading double-underscore for "private" macro to match "private" functions that do the same. * Use static_assert() from linux/build_bug.h instead of _Static_assert() * Fix incorrectly using sizeof(IIO_DMA_MINALIGN). * Add check that count argument is constant. (Note, I didn't include a message in this static assert because it already gives a reasonable message.) /home/david/work/bl/linux/drivers/iio/accel/sca3300.c:482:51: error: expres= sion in static assertion is not constant 482 | IIO_DECLARE_BUFFER_WITH_TS(s16, channels, val); | ^~~ v2 changes: * Add 2nd macro for DMA alignment --- include/linux/iio/iio.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index a574f22398e45cad1ea741d20d302f88756a1b13..d11668f14a3e17654fcf17a4e85= 3d4b493205019 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -7,6 +7,7 @@ #ifndef _INDUSTRIAL_IO_H_ #define _INDUSTRIAL_IO_H_ =20 +#include #include #include #include @@ -784,6 +785,37 @@ static inline void *iio_device_get_drvdata(const struc= t iio_dev *indio_dev) */ #define IIO_DMA_MINALIGN MAX(ARCH_DMA_MINALIGN, sizeof(s64)) =20 +#define __IIO_DECLARE_BUFFER_WITH_TS(type, name, count) \ + type name[ALIGN((count), sizeof(s64) / sizeof(type)) + sizeof(s64) / size= of(type)] + +/** + * IIO_DECLARE_BUFFER_WITH_TS() - Declare a buffer with timestamp + * @type: element type of the buffer + * @name: identifier name of the buffer + * @count: number of elements in the buffer + * + * Declares a buffer that is safe to use with iio_push_to_buffer_with_ts()= . In + * addition to allocating enough space for @count elements of @type, it al= so + * allocates space for a s64 timestamp at the end of the buffer and ensures + * proper alignment of the timestamp. + */ +#define IIO_DECLARE_BUFFER_WITH_TS(type, name, count) \ + __IIO_DECLARE_BUFFER_WITH_TS(type, name, count) __aligned(sizeof(s64)) + +/** + * IIO_DECLARE_DMA_BUFFER_WITH_TS() - Declare a DMA-aligned buffer with ti= mestamp + * @type: element type of the buffer + * @name: identifier name of the buffer + * @count: number of elements in the buffer + * + * Same as IIO_DECLARE_BUFFER_WITH_TS(), but is uses __aligned(IIO_DMA_MIN= ALIGN) + * to ensure that the buffer doesn't share cachelines with anything that c= omes + * before it in a struct. This should not be used for stack-allocated buff= ers + * as stack memory cannot generally be used for DMA. + */ +#define IIO_DECLARE_DMA_BUFFER_WITH_TS(type, name, count) \ + __IIO_DECLARE_BUFFER_WITH_TS(type, name, count) __aligned(IIO_DMA_MINALIG= N) + struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv); =20 /* The information at the returned address is guaranteed to be cacheline a= ligned */ --=20 2.43.0 From nobody Sun Dec 14 12:15:19 2025 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34E57290BAA for ; Wed, 7 May 2025 20:43:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650637; cv=none; b=l+KZqsI+dEMtkOOLpxcufadA1Fq7njocKFk04lksP3P8qeD/xr2H6LAwVzKow9rk1S21Pb/eDD+kJDEmqH3WpopubRpjNXa2sQqt3TRoJPE4QB+jQTfaL7TIkQXcez/MiwHZL3E95P+yKS3d1K7agGEAzU4Z9CbOJ10pmFFlCYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650637; c=relaxed/simple; bh=FKpB3dJAiexqEBZWnTYr74fw3YEDDpNI+Is7oC3Guzk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EX65c3EpGhyORzsaK7BTJXYkWssjIQONFNdeyKW0uVNsiXcce0+LHa1YKXa7uQEuyyKzdZcglrDrIviqq/A2TsyD+zI7fREAQUDp0vo6Wqk1xNIWfN2RYWAyIUSj8alGs6DDrXpAZmOHY425KvESix2W4W3WAK5n0AGy3uyIh88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=RVftG6V1; arc=none smtp.client-ip=209.85.166.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="RVftG6V1" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-85e751cffbeso17113339f.0 for ; Wed, 07 May 2025 13:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650635; x=1747255435; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=R2eAy2RW5hS2l6KPQzT1N6BY4unTaPpEg4WKTF1g7HU=; b=RVftG6V1Lhufs1DG0u12iTwU0jKh8gUGI0m/6Krxuw4w1MkgUU5aC4JzYJxrZMRVTX ck0KcrlEQ4MgvTUXNiNmfLQJ57DrDqYO9oLgFm3YfEwRxLcU/pyLTgmXWVsClKyAkfr1 UGpWBLqA1QN7qFmi4lvFA2Wa4Oa+eTkI79nPJMYpEMXtDb8gh4+LdURZEUw/HLU2x4Ed MXtVE0QmJX6tbva3zG4LARMj6jOTjSdtVEyRJCUK71PSS/nL+HOQfMXglaroyBfPpqBH OVm3hBGA0i1Fmc2RzQ0Ef/qMCPsxg8LaUlviGzOlP77WiItZI3A6tzMY/E10mphtk3oc iHrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650635; x=1747255435; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R2eAy2RW5hS2l6KPQzT1N6BY4unTaPpEg4WKTF1g7HU=; b=l+UCIAU209bQLsXDIU4ro6zUi+QcMJ30Hw9+av+I6UIQKIJzDKLZBbsuIMKipRQ4eA 5sY+p6ElouADOwW4R9B6+lhYESRbO2txw8vaypoKW1ltElbRQSX+cdVTKRKT20hRePVc uHlQCSWJBjeYHZIo5kFoDmz8/yIWXrZKIYUlncwD9jiNGRxCfEKtN8Qg7Z3BCPSfa0VM 01YQEEbboDkT5Xhvr/ImaClI1Y95xIvoTDR2721u8k9AInMsRejJJ0db5nNndSfIMt8T 4fkVS3crkB29nlvmJTszLiyLBykQJYM7tlSInL+L5Nz8I0Wg/25jjeJRrFSR97bgi/n/ BG0Q== X-Forwarded-Encrypted: i=1; AJvYcCWVVcJbDFlp4h4TH5NjA07ixh6pqV/Tb+BWe45moRsAOmhoYCjVU5+awed5wzBUXBK5qH20gPj49wFAo6Y=@vger.kernel.org X-Gm-Message-State: AOJu0Ywf4oP/iLeo9CknIGCurAicPwqlVepcLi8Qf8NT1wTEsQ2rw2xV xTvFKht8xhgCMNRYlw0aGPuN6Lp6B1TQvQqp5MIU1tjkElzffC/ScFigWodzDrNZxc/LuFLDUv9 M X-Gm-Gg: ASbGncuHIEwCsmCelr540g8P9gcO0sxynnnCfoCSGeyE/GIqFe3LUE9Ndjo3G4EdWDd nTe4aGXzdOe15vPzO7vzxJXa/mmFM7ApQeE5hwO5cDK5ghgjAbSf5PbEty7Cz8oLMoPFIglPW/w 5r5ngsjXf58s1u5XeI0IKB5Vb61hIstjAcs3npUzia/dTAJYcsCAgs85uYa2tyjDqqm9R3q+N/Y RfozGPYcou+up7hPT9fw+wdhBoR32VcI2h1HESWcG5yyOGsXYtfb+RBxTpsD35O432cDR+ldsAt ZEqmnzY4Hrdb974MLdP1xPHPN2ifdKrNCQR8QcFlPo3v7A== X-Google-Smtp-Source: AGHT+IHzAHhf7adgAgCwkuC/t79NMGTnVH1TVIxPBrVXd3EvJcltzOzimp3xX9uDQtvTagqhfmWlkA== X-Received: by 2002:a05:6870:9a17:b0:2d6:241:aed5 with SMTP id 586e51a60fabf-2db5c084b8bmr3450729fac.26.1746650624758; Wed, 07 May 2025 13:43:44 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:44 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:42 -0500 Subject: [PATCH v6 3/7] iio: adc: ad4695: use IIO_DECLARE_DMA_BUFFER_WITH_TS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-3-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Trevor Gamblin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1118; i=dlechner@baylibre.com; h=from:subject:message-id; bh=FKpB3dJAiexqEBZWnTYr74fw3YEDDpNI+Is7oC3Guzk=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XYJuOU1coFxNGXKJ8ETwdyznURBIo5GKTW0 fBmAN0sBOKJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvF2AAKCRDCzCAB/wGP wNwqB/43rBhN0ftZxpOAJIUlM+JDMGXM3Gn1VMlrXdmDKN5av4LjjrP7qsqMeRZtKu6gtCeGuVm uTcKbDXFWKlXySdMtaKESE05oUfYN9sxjSyl+8XDHIzIdzt/X0zePBoCPD0UTi4BMiPxp05uh18 A4ltomln1OzMmicJ5HhtVRH6q8Hd3aa701di+9Y6P1dcJT35pCV3t8QsT+rzhD9Pga/0+sgWc2m JlEl7QrVVWti4trSwEpjkrtjDr08ohggzW3i7oPd/fSjhybXBV7C+gelbR2Jbg+gn8edn8Eb2Sh OwWo6ZofWr+dNGQjVAemLQAFKR8ZKYcS0UzWuEzSsfuz9cgt X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use IIO_DECLARE_DMA_BUFFER_WITH_TS() to declare the buffer that gets used with iio_push_to_buffers_with_ts(). This makes the code a bit easier to read and understand. Reviewed-by: Trevor Gamblin Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- drivers/iio/adc/ad4695.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad4695.c b/drivers/iio/adc/ad4695.c index 0c633d43e480d5404074e9fa35f1d330b448f0a2..992abf6c63b51dee222caf624e1= 72455fb9b9900 100644 --- a/drivers/iio/adc/ad4695.c +++ b/drivers/iio/adc/ad4695.c @@ -160,8 +160,7 @@ struct ad4695_state { struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3]; struct spi_message buf_read_msg; /* Raw conversion data received. */ - u16 buf[ALIGN((AD4695_MAX_CHANNELS + 1) * sizeof(u16), - sizeof(s64)) + sizeof(s64)] __aligned(IIO_DMA_MINALIGN); + IIO_DECLARE_DMA_BUFFER_WITH_TS(u16, buf, AD4695_MAX_CHANNELS + 1); u16 raw_data; /* Commands to send for single conversion. */ u16 cnv_cmd; --=20 2.43.0 From nobody Sun Dec 14 12:15:19 2025 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74CB328F948 for ; Wed, 7 May 2025 20:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650628; cv=none; b=Fht1n8xumKfOqD+vglgjj7SDSAJQGUofdhsqS/bDdLzx23kH+sUlgEmzjd0CJ2wUQV0Mq3S5CBu64vpgjv55YKI4HRX7MrSXlk+Dx/gPA5Qnp1szS36wXXqcT3wspZIQyteWZfXHI/1geghHhkp0CSMV9bxE16qjDb7u7mtZVno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650628; c=relaxed/simple; bh=dYl7QDWnMJdjHkS6Trycc+ojlEKZD6od1/EKbXvOHQU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LpdWorh08BX/CntIKpf3BwPzXvHwFMb6pRTdOwdLt9BcMVMnfmqFcYGmJx/gTdr1Hivg5raBISpu4aJWoGhy3yy9UqVwhICxM7F2HFnxlmPp+h6ojeTUJAUsXoQr5fu0X+HfMDpJDwgETO7IWLglS+YKhhFq+2i7Bp9T+5C3+H0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Uv1zLvDn; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Uv1zLvDn" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-72c14138668so80126a34.2 for ; Wed, 07 May 2025 13:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650625; x=1747255425; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=M71PJ7VtKfkJnKGztH25+j4j9U1WKWdC9Y0jHLrJYIc=; b=Uv1zLvDn5puRDAdxU9uilZqS59K7g9upToVs4T7RNCqXMM6ufHwYek+ct317youaO3 z6l22645P5mcTKLLR1J5e3/kEzHkPZDvSmVr1Umrl13d4ryEJMqV37QbnqXCZ1EQ4ZeR dHfvkSKfBMDZoqmEEVj9LKyixAnk0YUQs3dqPPBqKH5lRPUOhZdBKAHG4WpJ2dCODKJW lPhab4jxEtFpUYGPp4AVrQAD5KezLO2UnJ2GPCFrgcJSVQKr6LQrsrTRZLNISUjdNbnS memVRKBeSKx8iNvnx23iOFNI+QjGuUjdNv3W0P8a0NclA9gUX2O0p/02brp+U0FH3GTl eVqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650625; x=1747255425; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M71PJ7VtKfkJnKGztH25+j4j9U1WKWdC9Y0jHLrJYIc=; b=vBkARZUXDQcBJ60xd3rM1XtJcHw/b0nSH1ACkkahQyfBMy34csUn3cfXLFHW083QPb effFA+zqPzN9vCXL06Mw5nOzpsuVrOxmXNe1MUBZ25pZyOavJKkIgDQxGqcQMBvfeEeS 5f041tp9FogxciPww+VAmiSJLH9tJAb/IujI3lZnapSgBTa/jsw22faNaSQ2+HlIWjKe 7KIrYb4MiLX7g0it+J2VMQDl6Q/MPxa2CMNb9HW/jGNrEFUqOaCcWP+/O5akn6/08Icd 2pN8m3k3Y2k0UxFkEF72s1Pvoz3Vk8HnU6qLlsC8yHtDUvNty1fzegXxxUizHevjElm/ pVEg== X-Forwarded-Encrypted: i=1; AJvYcCXX4RKUrajFBF25N7SlyZwGuCOd6oZs2t+8L2CGWv9Cg1iPV7+yHruwuiDdm2Y78ossbXi8eMbcaHils8w=@vger.kernel.org X-Gm-Message-State: AOJu0YwSln8kszKvlANZWv79DYkgO/eCeMoA3xhruzYttwuzzsdNNZvs PozSg9kPOB/FJ4+mkqVkPrhLyKIgxckztmK1ZURcbt/Dffxd2Pz22dPYT1Vlh+UFjopNnEBcJWZ T X-Gm-Gg: ASbGncud9nF3w+1WiEMtnjAspUtWI9lmR75BJDPUPHUGwxugV9mm1Sm8qn3JzepxqnW t+yRBBItgRgQJg/wxUT7yJAd81OuAvnIUN+zNXCMQRtqrdQUIDoL+vkgBx3QKPaqocSbDjagnEb Gz+dK2As2Z2RxmFAevV9/D5QQ8nc8TuHb+Fm7kAl92ksW0F01n7aLbKeAo0gAr6oMdxgTPoPYGU j18mbPrHtSZq5QsaPrngqWcea1F/1btJCBrGt81IXRxK9FehZsFEZiHNl2I0ZdzIVauNFYg3ghN 9WsA5NPwGYq9HISz4vOLfsVrCzG6X7+l2JtoZfQ78rr9iA== X-Google-Smtp-Source: AGHT+IGS5PMAI+KEXQKldp5GePhVTN6wjk/dkrFbe+bPctRj3wkBCKD/uHIlHK8DVJazvFjRCYZKIg== X-Received: by 2002:a05:6870:5246:b0:297:2376:9b17 with SMTP id 586e51a60fabf-2db5beb9803mr2860430fac.19.1746650625566; Wed, 07 May 2025 13:43:45 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:45 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:43 -0500 Subject: [PATCH v6 4/7] iio: adc: ad4695: rename AD4695_MAX_VIN_CHANNELS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-4-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Trevor Gamblin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2047; i=dlechner@baylibre.com; h=from:subject:message-id; bh=dYl7QDWnMJdjHkS6Trycc+ojlEKZD6od1/EKbXvOHQU=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XfmG4GSRwHhO4k5Xnu6UTAM2KXs49zHopNQ MTp8SUZxyyJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvF3wAKCRDCzCAB/wGP wNJcB/0U6S29hjeNRGS09dG5ez/9bJJ40VCUhk8q3UOeKsPlTU/w1YytSw5Bw0w3EuHvaAAVdY/ gUggcI4EcAp4Vt/4nxknyAoo202s77qiFZwB2q6rwdgpR3YwlJ3fidz/Dl6QFKRvPJZeJgnIIx4 ilCsxvPKWwarTrp6o+clsBtp2xGc+IdrNGVTYL3N1SvtGiFALJjgEisiBnbDLn0s+2IWrLUs7ps DAD8ETakvbGbS7FOWb62oo2+13gwy3dBGAxQ2T/MRIXitJtS8HCowyXnab/3q3eri21ahmZxOiw fDjLxjf/0RkLfl+iCqiN4eiAQgVsfvQYX1RXPnIg+fhZErPr X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Rename AD4695_MAX_CHANNELS to AD4695_MAX_VIN_CHANNELS. It has been a point of confusion that this macro is only the voltage input channels and not all channels. Reviewed-by: Trevor Gamblin Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- drivers/iio/adc/ad4695.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad4695.c b/drivers/iio/adc/ad4695.c index 992abf6c63b51dee222caf624e172455fb9b9900..cda419638d9a88debb3501d05a5= 13b17a4ecde95 100644 --- a/drivers/iio/adc/ad4695.c +++ b/drivers/iio/adc/ad4695.c @@ -105,7 +105,7 @@ #define AD4695_REG_ACCESS_SCLK_HZ (10 * MEGA) =20 /* Max number of voltage input channels. */ -#define AD4695_MAX_CHANNELS 16 +#define AD4695_MAX_VIN_CHANNELS 16 =20 enum ad4695_in_pair { AD4695_IN_PAIR_REFGND, @@ -143,8 +143,8 @@ struct ad4695_state { /* offload also requires separate gpio to manually control CNV */ struct gpio_desc *cnv_gpio; /* voltages channels plus temperature and timestamp */ - struct iio_chan_spec iio_chan[AD4695_MAX_CHANNELS + 2]; - struct ad4695_channel_config channels_cfg[AD4695_MAX_CHANNELS]; + struct iio_chan_spec iio_chan[AD4695_MAX_VIN_CHANNELS + 2]; + struct ad4695_channel_config channels_cfg[AD4695_MAX_VIN_CHANNELS]; const struct ad4695_chip_info *chip_info; int sample_freq_range[3]; /* Reference voltage. */ @@ -157,10 +157,10 @@ struct ad4695_state { * to control CS and add a delay between the last SCLK and next * CNV rising edges. */ - struct spi_transfer buf_read_xfer[AD4695_MAX_CHANNELS * 2 + 3]; + struct spi_transfer buf_read_xfer[AD4695_MAX_VIN_CHANNELS * 2 + 3]; struct spi_message buf_read_msg; /* Raw conversion data received. */ - IIO_DECLARE_DMA_BUFFER_WITH_TS(u16, buf, AD4695_MAX_CHANNELS + 1); + IIO_DECLARE_DMA_BUFFER_WITH_TS(u16, buf, AD4695_MAX_VIN_CHANNELS + 1); u16 raw_data; /* Commands to send for single conversion. */ u16 cnv_cmd; --=20 2.43.0 From nobody Sun Dec 14 12:15:19 2025 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7877428FFCD for ; Wed, 7 May 2025 20:43:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650631; cv=none; b=GxCmZaOeJzvsNYWlt6j2e3t3toCaNVx0UJsqnpAGWtbSrUTUIdxmmUnyXiTzOHQuDuh6fbExijxfnN95prj2OSvY++5Q/ay7nI5fKZKBLRQcLRQlgtUn6FBoTEmaAu5J3fD/aLX7Q7t+ez+4xIxd6soBbcxA4gaVMiinphU8WE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650631; c=relaxed/simple; bh=qTxxm8SfPufoyQPrSsaW7TicDEaOrmpRvi6YmXZisJ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eopWgv+NMdmnF2pjdmqgek7gU/m2gjM4Hld5TGY2RQIm7kMNS/+WJIMLOQfqagHr4KjUw2MP0xuWdL2ZIgeDXubbPZSRejRUG4GfrQZNG+snXZCVJk+4CONl37CvmCRbDov+wTTVKe5YWrQtEhRcA9l6WAzLv3CxfMLmK5X3QPM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=ybQv8gBW; arc=none smtp.client-ip=209.85.160.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="ybQv8gBW" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-2c2504fa876so169387fac.0 for ; Wed, 07 May 2025 13:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650628; x=1747255428; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Pd1rWEvK2H4HurtXzFWa/x9Szbu0oBY1TfY1+UU3AHc=; b=ybQv8gBWjSUNEdSDY7GyPVL59jR7GAG0qUOyrmNwgHCWam1Ajbe9M5YDQDMekrhOtA lKQ9do8IvjHYN3gdPqbOlYQtTq8jsSeulauSUUtzux9R5zaxUT4141jPnDytXs9L/3A/ KoLObW42+uLJT3oUpBKPXw6b0VEtLD9JM2gfBYSmqYTZ5d6vhJWb2VW8qISV7c5AOCyi DdM6v2B+UrpWZpxIkw0hXwbPjJsVDiwFekDIZcuOB1Mnu/q4/FVRGzrKc6Ce04rMv9Ur MDHqV5hHdb0nsigYviTTukfrP4OjWjkgyirGOZaOhC7ImindJSMCWLf3r4eBxpYckA29 ZwuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650628; x=1747255428; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pd1rWEvK2H4HurtXzFWa/x9Szbu0oBY1TfY1+UU3AHc=; b=qjm1Dx7ccQkANJoPaFA+ID2DMcSDM7HWwYIZOYdu50f4hBs8SULWux9UjSbUmH1gLJ riLLs10clWnR/kXhqr+quiMrLmblzQZS32C6SZ16zJ+gJOF0ZYJvY6rTnVoknxi+dIge vmHm3mfzZsxGN90jiDurqYujGyBi95Kxvs0O/Lbl/M6lFNzugzlu8qhgAyJD9wtMzq5u wpto7nBSUK/LM9daBsBCXf8TDKC0jFhIAnIghiGdKUbp9Ln8eU8tHXmD72FhBALJFknV X8R1UjeYo4UEgYsmALfIoWKjInKv4dXgwzl9CgRia3e1mmXs0EEOyKDU2quXP3t/NRay uisA== X-Forwarded-Encrypted: i=1; AJvYcCWSC01xYWirz9lfYQSOP2I4oAAi0ufEzlI3tLTMyvexiu+w++gLM1Jt28aVp5xkKdWt4Lmno6G54gm6mT4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9Hv01wc/0eqXiumbxBH80iu4VLosxAFzPE61EqkxylkHZ92Dw diPJ+K111oIG/w6K+xxYky/EtcWUe5DZueM2YnPStN4gddI5JZFBbqy7nFDnBug= X-Gm-Gg: ASbGncv2a6zZ4WMcDzfNqf3lpX+ac7+N4xJcV+rJbMYBthtV5+oEqQfA7TkHbb4cymc 2YnwzL35zpP10b8BCFjTf3tQi7ld2xaLZlq47eADzaXS8HLF3us9VTMXjFtmQRjwEb/pZOE4rJL G05SLkVs9Dtl6ZuPnbD6RtS3m6ANIHT6HEbte3a0zYrmlVMtKZm5za7Ai5gs4XgLjQQQn9//25/ /2ETeAB1hksbXPvCTcYJsXdkd344pTNzmPBZjYgdu2R11hMINHNnKf6IYPM0XQL2vNV0pycMKt1 Tk7NnF8HGD9msiB9I43NOEQtPYtIymBE6RuZZIxo+ha0tg== X-Google-Smtp-Source: AGHT+IFG69yhKzeAewFZifPcUv9VhJ1g9tWX1TCPK3VZrLJYfK0PymFFMWYMU/UQ1P6qhCb/J4P36g== X-Received: by 2002:a05:6870:898b:b0:2b7:7abf:df6b with SMTP id 586e51a60fabf-2db5c0800cemr3373849fac.26.1746650628324; Wed, 07 May 2025 13:43:48 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:47 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:44 -0500 Subject: [PATCH v6 5/7] iio: adc: ad7380: use IIO_DECLARE_DMA_BUFFER_WITH_TS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-5-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1297; i=dlechner@baylibre.com; h=from:subject:message-id; bh=qTxxm8SfPufoyQPrSsaW7TicDEaOrmpRvi6YmXZisJ0=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XlBguqCmqtDIVqJDkB9dfLXj5+9lqxiP29V msICqsmsqaJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvF5QAKCRDCzCAB/wGP wPyNB/4w+gWujWX4jrqO+DhhHJDthKJLkpfmKOfGt826Ejvq9ojUsmr0EKTXXTuQoDDSteDB83j 232ECMEEZ1/KxZMYGwRwHiM7Ql44o7XJVgtVi4/DjdGE9ifE1ahwNlEGqa47IszLrZdnK2RpumW 1TuYPeS83q/0utvHbfyguuS0I/5Y22fc2zz05e3brqnNH0DdRYqEafq5YI/1W+xHeUgqLJeBrYi gpkXbPspkbP10Fa7K0EccZnti/onu6l8ieO2a8V5z3Kia7EVPO4B9snycru05rcE4psJ0OZcwJY AavywEoibXqRuD1VIRuAezcdL4J+GPfOlgNCxhb2k8DLea7R X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use IIO_DECLARE_DMA_BUFFER_WITH_TS() to declare the buffer that gets used with iio_push_to_buffers_with_ts(). This makes the code a bit easier to read and understand. Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- As discussed in v1, this one stays u8 because it is used with both 16 and 32-bit word sizes. v3 changes: * Use IIO_DECLARE_DMA_BUFFER_WITH_TS() and drop __align() v2 changes: * None (but I messed up and there was supposed to be a change). --- drivers/iio/adc/ad7380.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c index f93e6c67766aa89b18c1a7dec02ae8912f65261c..ed5e43c8c84cfcc9c4ce1866659= a05787c1d6f5e 100644 --- a/drivers/iio/adc/ad7380.c +++ b/drivers/iio/adc/ad7380.c @@ -909,8 +909,7 @@ struct ad7380_state { * Make the buffer large enough for MAX_NUM_CHANNELS 32-bit samples and * one 64-bit aligned 64-bit timestamp. */ - u8 scan_data[ALIGN(MAX_NUM_CHANNELS * sizeof(u32), sizeof(s64)) - + sizeof(s64)] __aligned(IIO_DMA_MINALIGN); + IIO_DECLARE_DMA_BUFFER_WITH_TS(u8, scan_data, MAX_NUM_CHANNELS * sizeof(u= 32)); /* buffers for reading/writing registers */ u16 tx; u16 rx; --=20 2.43.0 From nobody Sun Dec 14 12:15:19 2025 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5A0428FFF1 for ; Wed, 7 May 2025 20:43:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650633; cv=none; b=cK8snCEV6WDu2TjhNVAaCdC3iQSk7Oh4Ov3z4mF1m+FZJ5Go7/x5/4K+VCPfbs8tA+n9uFP3ow5JzJw4nQCNdI9cC0NqTdlZCA9TOZzCVLzAr7E2kj2kPdOiUDF82IUYAIV5idvDv91RJJ08HAWONGyUATlg59/c4MATVqREwrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650633; c=relaxed/simple; bh=dvUFehPiHRrmTSC3dtvpsj/U2poRcpbR8vHtY4i3nHY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UX4R/P+wko2ozWzguL1Pz2zGmUI9D3S82TyxuzRBzqAKVaEckj/Syze6kPXjHTgxsczjlbPUzWZkHbmE90iERsXl4i9ajQL8ydJky55WpowSd2OKeAfxzupo/XPnR7603E2eGlRterT2Xpa2/gWC7dUXLojdMdlbgzhRYouv7SY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=yBmCPAW2; arc=none smtp.client-ip=209.85.210.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="yBmCPAW2" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-72c09f8369cso106346a34.3 for ; Wed, 07 May 2025 13:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650631; x=1747255431; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fzPdaraet1qd/hRhYNfeQIRYquiVkvvOEQ3W8/ikI7E=; b=yBmCPAW2M/Qi81OLUmooCJzME1E8/SDFJhCaYD4BsZAMfIYePdj1SyIqSjc/4FxI8o gFDqyTOR7uCSlRrc2b2GosUetDFmX71HngCJYyXR5nxdCqw66seVrEI63ney4CjPAYwv USt3IfT6bOAiR1dH0fhpL5OiXfIaAm/3d+aS1OWhZ5dCMOAEFy7w0NQs8mCIWqOj3xfa 87o/uCwrOLWGiGo4MDZ3e0GS4tnR0s7gR2kaNcRllEB9lJJnmCm0z42tvuDj7ewhn7GL 2TQwab9etKiLAe09+/33JVmuTxEvuaVH+XFRGVlacEJEE0VoN5iHuALYpr5gymRCu4tz 2ESQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650631; x=1747255431; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fzPdaraet1qd/hRhYNfeQIRYquiVkvvOEQ3W8/ikI7E=; b=Ai0pkc9up303DqVLQxUbvzgR96LG9AQCE5rIbuArL/ZqKZqIHAjcjcwPcyXVkQDs/T wN71EDT7MkDDb5eWlUYr3lPsJnATl146zlWNMfF8eW7OaSXvvHqWXef0FHpYCpqCDdKk lRqVbM1eEE34ugVCf67kIIeDyr4EOdHnVt4W9iiMQPr7spXm/Ou9hBrJb+pCnib6aJ/+ 5jeBjnSGwMlQn/HzZ4y4zs/ok2i8TJTenciR+VVJZ+UJDJJ2gpd1UP8felo/BpUpfNP8 oLs8ZuLGevj6/mgru3R57Lp1YIerFXfR44Jx7vT6Wag0o7o3lB+k/WbpxycOTirUgsbe 5bNw== X-Forwarded-Encrypted: i=1; AJvYcCXu/++5/RegmS6k3EmdohdfRq/5BW/QBQUMS84sqpcdyrvCYFs15B3pWlWF57U8q+SlU0r1X+zFJP9FZFA=@vger.kernel.org X-Gm-Message-State: AOJu0YxrLDx6l0NfHFCfyNGT640xIifBOEi7BvOzyiCLAmhsoq9hpZPD A1PDKy3uN+blBpsOEt6jSq/QQUEz6rGJYwQFaTtb23u/zPJJxO1i9PE0CaIahz0= X-Gm-Gg: ASbGncsxlPpAixPQJgYpwpoEVB/7aiNTYN1BWSt0bafTpG3zEkNbTAADJLg9z2+o6BK Zz3VKw2fsEtMC+YUTdMLoKc+UUORsVoVo0KzdIVRtCsmuyRC1dh8w+E6WYyvZ+NavWw6+zDRhBH Eapac28e0KfFNsdWf8etSXOx4xp+NX3B/wslh7WrlH8hxaDAgTZZHlys8KzSSWnwl5DmeQ+YGMW llhteRq/gfTldTnyKNTAAfr6HVpLSuOF/RjPcV2yzkz+bArz6y/07zimqTJoGiVb/N5/7es9jyw OtVUE1xVQXgl58XcGhq1vwX6xCkt9G+Q+0tVFTncTl0YOw== X-Google-Smtp-Source: AGHT+IEpHAnG01Scl8J+PpIsjJyBK4Ozzp5Btge1E7DtlkBYgx1uC1tvjoReIGhc8pl1J4BDBekRyg== X-Received: by 2002:a05:6870:4591:b0:2b7:d3f1:dc72 with SMTP id 586e51a60fabf-2db5c0689bbmr3206424fac.29.1746650631030; Wed, 07 May 2025 13:43:51 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:49 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:45 -0500 Subject: [PATCH v6 6/7] iio: accel: sca3300: use IIO_DECLARE_BUFFER_WITH_TS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-6-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3024; i=dlechner@baylibre.com; h=from:subject:message-id; bh=dvUFehPiHRrmTSC3dtvpsj/U2poRcpbR8vHtY4i3nHY=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XsfCtuj9afQdP+zJ6RY1Bvt2zemL+sDgCwQ kXeNrGbo4GJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvF7AAKCRDCzCAB/wGP wGyqB/9o5h9iBDRuaIoFSHY1pBm5fkeyDKqnrw3bEgY8R0uUDWwzRNWAvrLeZFaFG0JPwu2sBNv +l0AZ6J9yMJ0J1nong62NfhEOxIpZg+qRE8RipH3LscKnXoOcMuu4ptiF8Vh9rOA2Fb3+j73SzJ z8SdMyDCVIML7mH9boq8DnliwmotlxdYo0Mho0+w+f3qZArRypNzHQbKKqgc6nZDXpTy3Djqeq/ O76xOo9fkthmY+F5ZQda/ZaFtlQrGU5qn2/lyEPzmunUU8XlFG5FBCgybA44jKN+A+b/qoZ8ZVz fpAtYnb4YwBP9R+XYPexIC4pazTSS28lU2TQPYv4uxc7clFX X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use IIO_DECLARE_BUFFER_WITH_TS() to declare the buffer that gets used with iio_push_to_buffers_with_ts(). This makes the code a bit easier to read and understand. Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- This is an alternative to [1]. Also, this serves as a test to see if we can get a rule of thumb to decide how much is too much to put on the stack vs. needing to put the buffer in a static struct. SCA3300_SCAN_MAX is 7, so this add a bit over 64 bytes to the stack, make the stack now roughly double what it was before. [1]: https://lore.kernel.org/linux-iio/20250418-iio-prefer-aligned_s64-time= stamp-v1-1-4c6080710516@baylibre.com/ --- drivers/iio/accel/sca3300.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index 1132bbaba75bcca525fac2f3e19f63546380fd4f..67416a406e2f43e4e4172104109= 04d44c93111d2 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -58,15 +58,6 @@ enum sca3300_scan_indexes { SCA3300_SCAN_MAX }; =20 -/* - * Buffer size max case: - * Three accel channels, two bytes per channel. - * Temperature channel, two bytes. - * Three incli channels, two bytes per channel. - * Timestamp channel, eight bytes. - */ -#define SCA3300_MAX_BUFFER_SIZE (ALIGN(sizeof(s16) * SCA3300_SCAN_MAX, siz= eof(s64)) + sizeof(s64)) - #define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \ .type =3D IIO_ACCEL, \ .address =3D reg, \ @@ -193,9 +184,6 @@ struct sca3300_chip_info { * @spi: SPI device structure * @lock: Data buffer lock * @chip: Sensor chip specific information - * @buffer: Triggered buffer: - * -SCA3300: 4 channel 16-bit data + 64-bit timestamp - * -SCL3300: 7 channel 16-bit data + 64-bit timestamp * @txbuf: Transmit buffer * @rxbuf: Receive buffer */ @@ -203,7 +191,6 @@ struct sca3300_data { struct spi_device *spi; struct mutex lock; const struct sca3300_chip_info *chip; - u8 buffer[SCA3300_MAX_BUFFER_SIZE] __aligned(sizeof(s64)); u8 txbuf[4] __aligned(IIO_DMA_MINALIGN); u8 rxbuf[4]; }; @@ -492,7 +479,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, voi= d *p) struct iio_dev *indio_dev =3D pf->indio_dev; struct sca3300_data *data =3D iio_priv(indio_dev); int bit, ret, val, i =3D 0; - s16 *channels =3D (s16 *)data->buffer; + IIO_DECLARE_BUFFER_WITH_TS(s16, channels, SCA3300_SCAN_MAX); =20 iio_for_each_active_channel(indio_dev, bit) { ret =3D sca3300_read_reg(data, indio_dev->channels[bit].address, &val); @@ -505,8 +492,7 @@ static irqreturn_t sca3300_trigger_handler(int irq, voi= d *p) channels[i++] =3D val; } =20 - iio_push_to_buffers_with_ts(indio_dev, data->buffer, - sizeof(data->buffer), + iio_push_to_buffers_with_ts(indio_dev, channels, sizeof(channels), iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); --=20 2.43.0 From nobody Sun Dec 14 12:15:19 2025 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0B09290097 for ; Wed, 7 May 2025 20:43:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650635; cv=none; b=MtjvIKfUiK5lAUFR7d9d5tmkmgd0o8VJsBazkPgGb8l9GZaRb32lmohQztDsWaaVbfPFO9Jy04GAehkAisEk6dBFyFu2QkklfaHBy1HPWzaMa+xDaOKUDTKAaszaz3MCB6nsWeNulibUo06r12iDtR8nwuZzZea9XnMRSsCgBmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746650635; c=relaxed/simple; bh=E9PIAfLoyJ0RJi3D/ewNgK6tsUeqLYCSdDUrepVzsaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HsFuHVtnbpyr/pWJbdvCrDYeZAkGBddC85YqyBrnAsaaKKIwGA8dXfjn5TLQtCCq+3OjkMWREAp8OkKQuOSCRr0PfUAs8VJnavBNbeUtpKm//PLTvxrQJ7lb1nBh8dAQcLpH0WN3uvRMB6JvuP1AXNhdWmWWxfQWc1hq/BXOjkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cBnxvw/p; arc=none smtp.client-ip=209.85.160.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cBnxvw/p" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-2cc57330163so305381fac.2 for ; Wed, 07 May 2025 13:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1746650633; x=1747255433; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AkEEnGIyeDiVPJ1Vchg86i4F6EdVT5nAWBfWqQhvCKc=; b=cBnxvw/pK9M+OgCA9fecZ6Qj6seCy+4+ZfudiWK0UfdFC+AgrKZrR+T8DKCBirFM43 DZ90jmVifHGRTiVRtYSuda1E4RteaU0+4ItZgxlDMAk6nFkTBa1bof42yjH4LzHZKx3+ Y/uSLRDbdn/q8Pqg1qmWOoCNAV+bSORgYnYxiWGc8fExRXqUqkTt5XgtvUSF/LhkTMEl oHfgQ5m5xDGwLPjvL3Z+MjbUbJSRKaVB/UFz1XnX+4tWbwSBROe1FYmEp8wuplenjAux fk1lm/Q3qm1QhxmKKhbbdaWgv/iVMMFUbptLdC3TOcA/Fb6rKZK7adlQF/0A0La+xF6a CgEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746650633; x=1747255433; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AkEEnGIyeDiVPJ1Vchg86i4F6EdVT5nAWBfWqQhvCKc=; b=ZKN5PX/X02o0ynkp2osULggrLB1sqR6yBiz60YDK053XE7esQxGwh8NBcZV9giOCxg l39NcX1wxcrQoJ9w+8nd3ygfl2pKFRtIeTLdw+uHfvCvWYzmNyiVII0YQgziJ1o35jv1 cI3OEsQ7AO7TKLkRB0g7ZP7Bm1eLKcbcnSgtwj8L9raiSd3QYEsAOzWTOlqU8nNsQlV0 jZOzkp1PqA7gLbx5hOoya05rjbTevox2wiUgDoLMuUAe96yiY7DdL7t211J1o+k8jt1a EHgLDw661oykhjmkLyWxakdrMDSnN1WxQd6Yfr9SPWjPvfXbcuMA4ZRhZO8ZNqWOwhf1 e/Rg== X-Forwarded-Encrypted: i=1; AJvYcCVLVdbN0THUw/pIdfePDVyy1u+D8jGFDkWk46OV9+Mh3S99BT8vN/U0aG2Wjd91ZZmBL7oPhlau+jqATWA=@vger.kernel.org X-Gm-Message-State: AOJu0YxxmgEK7i/akzD/WAsCIk7ktcDaVPqxN+12osElQjOiQoWOxw0M krvHdI6BrJNE0qdBmVAdM9Hxs/tusJ6N2Xyen2ptGm6RCZdrARBdNwYib8OB3NQ= X-Gm-Gg: ASbGncsJyfd2CxNxlydToUYiSt89Dtv1waSmi/VOcVrQAOM+W2FzDnH9uPjWf/YrSNZ 4zA8pV0VJPLv5NjI0O2srzzO/UVnozT5hZwyodqe5xpnk1aTn6lNzPc/aC9w9gi7szzEtXE4I+o 5Ow6MqyqvRfY6PIsHeFZsDy5OjIX9syLYZXL+qtydW9G0ufTI3GlBFLHCwDEIdL64b1H1YpzG0Z 23hHgBxe5LiE0TnQk3M6X9n5H8+ovxsWd1HcNMwxvtpZ4SgYvo183z/CRJUwZ+i/Rmic/Yg0OhR RdnK0ZlwEk2VQdlbZi7e2LkScakY+PnERw/9IQDC7/uXqA== X-Google-Smtp-Source: AGHT+IFv9/lwSfeqqxrnWeC2Lb3fTYoOfdj8WDrV1djbCLjHfaiWSRE1YF1jLbIdYdNWncmdHjrl4g== X-Received: by 2002:a05:6870:47a8:b0:2b7:f8d9:d5f7 with SMTP id 586e51a60fabf-2db5becfba8mr2933835fac.19.1746650632817; Wed, 07 May 2025 13:43:52 -0700 (PDT) Received: from [127.0.1.1] ([2600:8803:e7e4:1d00:3356:f6f6:bf76:a32]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2db5cd716d3sm898642fac.21.2025.05.07.13.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 13:43:51 -0700 (PDT) From: David Lechner Date: Wed, 07 May 2025 15:42:46 -0500 Subject: [PATCH v6 7/7] iio: adc: at91-sama5d2: use IIO_DECLARE_BUFFER_WITH_TS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-7-4aee1b9f1b89@baylibre.com> References: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> In-Reply-To: <20250507-iio-introduce-iio_declare_buffer_with_ts-v6-0-4aee1b9f1b89@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1780; i=dlechner@baylibre.com; h=from:subject:message-id; bh=E9PIAfLoyJ0RJi3D/ewNgK6tsUeqLYCSdDUrepVzsaE=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBoG8XzuxRWPot5Lj1UBI0PQHvKcH+S/2Js7bWDC MwB352L8NCJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaBvF8wAKCRDCzCAB/wGP wC1JB/0Qrc6VwdlpFKuZ/ZskSEubr5JpckDQsyuLEoWu5pHwj3LfH2VhLa8WVcMwLPGyWbNbyQA 33488s4yfq3TNY1UOh5vaoWaqGkVmfSzeS24yx8k0aSi0KKfUJWNZparRvnuBocE6/6fF/dQKGX 9DTINk3cX+Nsrl+Ohqa0A8MU114uOBom9yKi0ukZKc3ue+pkKI/LKWU1lUYP6CPz9/Tmo0Aiom0 kXxkWMtUU0ZBWlzv8u3nQ67fLe/pKlrlRh8noB2RDIK1ucNK8cgf3PgyZi8pm+NVMw2MWx8OOQl dlVuaTnCVHdp0ACpYSrD2WYk9ahopTw10uq3rJEVjmBWh2/N X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Use IIO_DECLARE_BUFFER_WITH_TS() to declare the buffer that gets used with iio_push_to_buffers_with_ts(). This makes the code a bit easier to read and understand. Reviewed-by: Nuno S=C3=A1 Signed-off-by: David Lechner --- v5 changes: * Fixed missing space at end of comment. This is an alternative to [1]. [1]: https://lore.kernel.org/linux-iio/20250418-iio-prefer-aligned_s64-time= stamp-v1-2-4c6080710516@baylibre.com/ --- drivers/iio/adc/at91-sama5d2_adc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama= 5d2_adc.c index 414610afcb2c4128a63cf76767803c32cb01ac5e..c3450246730e08cdacc975ed19f= 46044dc76848f 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -586,15 +586,6 @@ struct at91_adc_temp { u16 saved_oversampling; }; =20 -/* - * Buffer size requirements: - * No channels * bytes_per_channel(2) + timestamp bytes (8) - * Divided by 2 because we need half words. - * We assume 32 channels for now, has to be increased if needed. - * Nobody minds a buffer being too big. - */ -#define AT91_BUFFER_MAX_HWORDS ((32 * 2 + 8) / 2) - struct at91_adc_state { void __iomem *base; int irq; @@ -616,8 +607,8 @@ struct at91_adc_state { struct at91_adc_temp temp_st; struct iio_dev *indio_dev; struct device *dev; - /* Ensure naturally aligned timestamp */ - u16 buffer[AT91_BUFFER_MAX_HWORDS] __aligned(8); + /* We assume 32 channels for now, has to be increased if needed. */ + IIO_DECLARE_BUFFER_WITH_TS(u16, buffer, 32); /* * lock to prevent concurrent 'single conversion' requests through * sysfs. --=20 2.43.0