From nobody Fri Apr 3 01:28:25 2026 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 B0590430B97 for ; Sat, 28 Feb 2026 20:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772309045; cv=none; b=r3tlniRmn/472RXqthK1e1NhC+IcS7Y2Ff9rrCtvelUsK5MDB3/Ep+XtXHMzTrOwQ/lGOrp4PRnra8KW3ABAAA2oV12KRiHUUifAKboYU6HN0zXojWSdx4LQiPX+kDpo49P5WzPlIQProVrm/+/iGw2kd3s2vCTgk1SUANA9iC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772309045; c=relaxed/simple; bh=XR6VB6nJF8YrvnTcNVIaVT4Xgebpbma1v4k6wmlyTok=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JwNeoD4cSncxWfmUHGFCky0+UI9xK0FDqFXfPoxpLsyECmqz9kd8zVXvzYVm0RC35gxJOIzo+jijTCTbRAPIQrM2KwUYMrxWorl2Qw7WqdxAZUvdvM2qnET7jYdVr5iHyClP+ItvAspR/L4uyEuTUAAWkMJIw+gWVn8LWEO4DGE= 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=swcClr48; arc=none smtp.client-ip=209.85.167.177 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="swcClr48" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-463208653d6so2543885b6e.3 for ; Sat, 28 Feb 2026 12:04:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772309042; x=1772913842; 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=7RA354iU71vdxVtpuvKh7wmklzvLwNqQbv7Pv/0iW5c=; b=swcClr48MmzE91O3+lCFCvVK+w18pTnIWUDCsPG5RRFwOLSs8tPf0leO6S3hEnuZpM nXLh9cfsedyIxCOr2Dw9WpdiykGbgSnJWmzejPuYROExOsra6xTEuncVYlB3dEQc/Scz 057fFqr7rGuKX7UEAMAZxZmpbd81NG2QwXiNNYSO09hEKqT3WlhXOOJ1hq8o08WDKHQp SRsq+nGEIKYm3MKmXh+B4w9T0OKmQcBsiru7cWvzgn8HZZ/hF2YxFR5wrg8v3zcT+KuD PAUsXOjcafjiJXeNCMIXPPwb5nXGnNfw2BcxPOs6yvTU+FICzqyBCED9wxKXORHMZl2X G9qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772309042; x=1772913842; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=7RA354iU71vdxVtpuvKh7wmklzvLwNqQbv7Pv/0iW5c=; b=GUvgEN96SUksno+6S4wxsmPIB7UY6Z/qDBjcrgcBzWVEnsy8iu9+udzUcKFuCZY47t SQR1ij81dUQWAzGivNvO8N1X5fCLUYt3FF0v1VfoIzDUAbQiy0m3MIqHwQCWFjHStzAB uspz1koGuRSydskN6fckUPdnJ1u8yB3vc6PqgLBubCCQIFgj4kqmcLESvP/6ZFJThoJT +0fil6dAqI6jWMaLeiAsFYNGXx4pKMG4FKfWXrYxfnG6jRNU1UcLXI059Q1KUTxj5G6m wdmtmzxDzD/tmsKUg8g+9QBeuv6MYD2uEkd74JM2ml89a0rzUsXi2YDrADExC+LgsmaI cO4Q== X-Forwarded-Encrypted: i=1; AJvYcCXu17F3ejB3B4TDkT62WyCY1oaoZNmB8q1YYltcW6xIg73C6STzJOQIlSt4Xg9uI92lt7dMmm5+LdEBzrI=@vger.kernel.org X-Gm-Message-State: AOJu0YwP2cqAArfLDILLdV9S/6EFbmTXz0Ygdy4GI4fn3k6QjNOT861W orGrOR8h5LdBUeBCDllGe4I210iZ3kzth7Lkgc/dHglaeHHSzkDUXnQS0MNrjhpKOCo= X-Gm-Gg: ATEYQzzbT8QD9BOsU16jfPfLB3xner3k0QjGtiFxc5umihhvK6XJZLlk76ddfhEs835 vGFCLfZpnseAMZXa2C3U6GRPEsZFj6KxCgio8YfRhMpQ9quY6VKnaAK/wygfZhsr9r5q3TJKR2S uUHbLrNmnPjSakeLbOwopb+EwWHM/grLHnkNwfSo3ZArry6ldBHNDd21HFVq/oRl+0fdtXYjJPr nODHiRzDHRUWMzyPSBxO0iq7Jv47vC4+usQkOTFfEv98Y2Bm9r4gaNIHwcIKFniC1DDYHXkDH27 NNzNYdJf5FtSEZsGkrm+BwOYOYvIIv9NqgBJsF2Qw+E4oVkiX08Vp/A7T27q2VFd4gUEX1o7UBj NcbeE2FBo56+nWMCvEkrvmcy7kjJ0smWCbeVNsX6L9aiUP5kL8TJyKeb5MIFX/6ebAOugKoDFwJ Qjj01Aw0bopUEpLn0o3cIQIfczmQmx X-Received: by 2002:a05:6808:6f93:b0:45e:a1e2:2808 with SMTP id 5614622812f47-464be9e264amr4592348b6e.27.1772309042658; Sat, 28 Feb 2026 12:04:02 -0800 (PST) Received: from [127.0.1.1] ([2600:8803:e7e4:500:1031:c44e:9f1f:17c1]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4160d2cf00fsm7579785fac.20.2026.02.28.12.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Feb 2026 12:04:01 -0800 (PST) From: David Lechner Date: Sat, 28 Feb 2026 14:02:22 -0600 Subject: [PATCH v2 1/2] iio: add IIO_DECLARE_QUATERNION() macro 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: <20260228-iio-fix-repeat-alignment-v2-1-d58bfaa2920d@baylibre.com> References: <20260228-iio-fix-repeat-alignment-v2-0-d58bfaa2920d@baylibre.com> In-Reply-To: <20260228-iio-fix-repeat-alignment-v2-0-d58bfaa2920d@baylibre.com> To: Jonathan Cameron , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Jiri Kosina , Srinivas Pandruvada Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , linux-input@vger.kernel.org, David Lechner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1688; i=dlechner@baylibre.com; h=from:subject:message-id; bh=XR6VB6nJF8YrvnTcNVIaVT4Xgebpbma1v4k6wmlyTok=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBpo0oj3aPK6TTibAywCpnnXbphM5bdQhcyMCAKB SO0lC7iiGqJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaaNKIwAKCRDCzCAB/wGP wLj1B/9HqCuuUKHXKZFQAMuLL2CVLsEKFAPI9dc2LA9n9Z9xSKLtDQRcABPPYz0zos0H0iSqtXJ 3tgqd/k+NH29iprDIwR8g3gs+mRNDZ/kGTiTNgjQzZpbsylIeXDceSeYi9kj+H5d142Ge7rXK1d 6nLXQj5c7OEsZ/k7kN9HfIJGs1+G9KXupeWGz6y1Tb/yopXgvjZ6088w43HAAnRqehkwzWSB2pe 05nAae1116lUUbHRzUBpBYozfYwWEaM7U0nHiQBgZy5vuiaVMjOYBaGaoMjf+AwKhjO81Eekiwi l0rxaP/6geEzi+bP8jpazjvkmVoc7n1J9fCP4ObrWQm2w++o X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add a new IIO_DECLARE_QUATERNION() macro that is used to declare the field in an IIO buffer struct that contains a quaternion vector. Quaternions are currently the only IIO data type that uses the .repeat feature of struct iio_scan_type. This has an implicit rule that the element in the buffer must be aligned to the entire size of the repeated element. This macro will make that requirement explicit. Since this is the only user, we just call the macro IIO_DECLARE_QUATERNION() instead of something more generic. Signed-off-by: David Lechner --- include/linux/iio/iio.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index a9ecff191bd9..2c91b7659ce9 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -931,6 +931,18 @@ static inline void *iio_device_get_drvdata(const struc= t iio_dev *indio_dev) #define IIO_DECLARE_DMA_BUFFER_WITH_TS(type, name, count) \ __IIO_DECLARE_BUFFER_WITH_TS(type, name, count) __aligned(IIO_DMA_MINALIG= N) =20 +/** + * IIO_DECLARE_QUATERNION() - Declare a quaternion element + * @type: element type of the individual vectors + * @name: identifier name + * + * Quaternions are a vector composed of 4 elements (W, X, Y, Z). Use this = macro + * to declare a quaternion element in a struct to ensure proper alignment = in + * an IIO buffer. + */ +#define IIO_DECLARE_QUATERNION(type, name) \ + type name[4] __aligned(sizeof(type) * 4) + 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