From nobody Thu Apr 2 23:54:46 2026 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 AB62C257459 for ; Sat, 14 Feb 2026 21:00: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=1771102854; cv=none; b=Q4VAYQHjnUunnHUb0segcPbzwhOUeWrLtBY5LV68Na3HzTrW6+XiW0q9BZ8wHAzey9WJY9xxzeXw8bAb/oPI3iFziBix9QRmcsmWuslcj85PgyB4loJbDOtIJqZOazVSn9GFcpVYrU+ZlAGfuxl69EZy7oPcZS09ccm07fvZpiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771102854; c=relaxed/simple; bh=R+GDKBxHJ8ivRZ9xRlhbfMw9VAbVyebEmKoXSpw8y60=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sSpnOz3LoEzq8mZkJzFmHoFnNBf7mqWzk4PIzO5P6pdcPWqqXTmbMGWPvyJE4UxrGD3Un4NFbuDbXRcMmUEqIyMG8Msmi9KY7hzSj0sGhf+h3gVOWlI1LvU4tyBZ5eSLaZf+tO84Ba+merBBmkA32aVS4FL1OZOvfmf5zP46rO4= 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=dTi+Djk2; 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="dTi+Djk2" Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-7d1890f5cafso703995a34.1 for ; Sat, 14 Feb 2026 13:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1771102851; x=1771707651; 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=1h5TdfsaHf3o14xhxp5+kuRImMLBj24k72741uMsvLA=; b=dTi+Djk2sED1d/Fh2e0Sa0ARPMWC/HMw6wuCyZuYbQDmvjSEiP8hfWScuUAhhp1UYZ LtCb+SpIBiJvXmAMO/K1xTVrneHHEOcE3UfSiMyS1km5N2kve7qqIsDKWQg6wCoCuAbB Vrf4nd33SqMVM3YxWQ64mW5oO3SFfFGVgArDItnbRh9/0Q8A4+sOqZNQoaTREaJoA6eL MO/kT6aLuLy9T36o2a/byRITvDuEavdaT0KO8mIWOb2D7HoAj1xnVsXKdRC2sGnHrfcY V9unfGMKQAXKYmjAiE/FVPfd7AKZkqXHqfNASy5hPQIoeulipWHL9OIE4sibhvcQT/ue yu0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771102851; x=1771707651; 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=1h5TdfsaHf3o14xhxp5+kuRImMLBj24k72741uMsvLA=; b=kt+MhIaVsLWR02LPQBZJPAXLG3+ll1y/IPXKiGVVeFfNzkep3qcS+/3ldGdSi8ZbNg 8NncoZuy8XQY8DvsJmDm/PWZlWgDbtWgspoij+Ryv7LWHMPVI/i1nkjrVZgsmmjeq5IN l5I+Zkpn7VdO2Ym7rPokDwohBXImb4AjovN1LQ4CzFMKZ2PDVz9vQhc2hd9p971KugFH Q/wD4caOB+hf40YlFHvra3PxyzyNa8HTh6gqVTpOWerr80QgLCSl4QKYcV9rctQGPbyr ZjuE5vXxybOccvISsXTu3WUjRTSsBHKMWkeaMp2JUtc3CozMMZH7cG60rvxMSV1Bn0z2 K7MQ== X-Forwarded-Encrypted: i=1; AJvYcCUYPB6xEuPLJNydiCd9aLf6PIo5yhKzgrX5FH/AFt8Z9JXfrRigLDVGb5+Xu4iZo6DA2E6wuoUnmFN5TR4=@vger.kernel.org X-Gm-Message-State: AOJu0YzCWLpD3cmDINYbVV6RDfU8mH34Cj8WKjB0IWov3vZ8zfJNcMAC birs/UA3A986ErT29vwiNjYDXkGeFtDYiREWsUHBB/umAdJOIY65j1CunTrHIQ9K5Pg= X-Gm-Gg: AZuq6aJAXaHNu8GQCYKsv/6nMuQ7tQr81oREUTnjgFj2IT8ToHL44buBK/3CRtWbMQD hVW3cD60mh73yyIu1EYBwVj0E1NWDmoSokKhE7e8xAE7+XRzrjJDTwlHflmv6JSpOkyRqgb7/m3 F76ruGZCacVD2l3+SAAMVLWw4YnIb7RYhqLhv2LW0jWambBWwJHo+9nx2MvClNyO27uYHwVAQV3 j587q50Aa061d7kAajFcnqcZoQ9d0z6yL38XFCYeCcwCCqR42bvvfZw0qGAdWg9gblRXi3iXlvB uu/qqWGlW/OGSd7JeIIeRM29vG+pLszyQs7Qw7pBG2VmN9oeHOGhJjaSUHeM+MY4hioqUMeqQGz gAJA11Aah9wYBbFzCPub9YIhenIG7/LE6krEIFhpD/hPoSbnUtRoGNiyvmYHSDqrq5Czh30pwHb AcsNfrBxVqYAsBSxohxDb4nmM+2Eixkrzb8GEJ X-Received: by 2002:a05:6830:640a:b0:7c7:5458:75f8 with SMTP id 46e09a7af769-7d4d0c32828mr2243774a34.29.1771102850690; Sat, 14 Feb 2026 13:00:50 -0800 (PST) Received: from [127.0.1.1] ([2600:8803:e7e4:500:109:393c:254e:962e]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d4da074c15sm1181680a34.15.2026.02.14.13.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Feb 2026 13:00:50 -0800 (PST) From: David Lechner Date: Sat, 14 Feb 2026 15:00:20 -0600 Subject: [PATCH 1/2] iio: add IIO_DECLARE_REPEATED_ELEMENT() 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: <20260214-iio-fix-repeat-alignment-v1-1-47f01288c803@baylibre.com> References: <20260214-iio-fix-repeat-alignment-v1-0-47f01288c803@baylibre.com> In-Reply-To: <20260214-iio-fix-repeat-alignment-v1-0-47f01288c803@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=1745; i=dlechner@baylibre.com; h=from:subject:message-id; bh=R+GDKBxHJ8ivRZ9xRlhbfMw9VAbVyebEmKoXSpw8y60=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBpkOJzQSDBD9vP72HTDUJ6jFzPLuedxVXxcFXCa qONJJ+MvrmJATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaZDicwAKCRDCzCAB/wGP wK/SCACJq/go6ywDx+yyaWqW73vW2C1C6TPsEUvWklyajKwGIeWJ8ZBhE3OZUZO/WNCgNldxRxi BpopXldOuIHgW5VXSe7uX48UYS4VnroDYOi4xmzo9V+oS4Ob47/cKROhuiusZuG80lSmTEhdyBh fMnpTmX2T3nvlHctnhpIf6PMQRhTIJb1gwh+xtJSwY3pYw3n/bTDX2We88gmOYrC6u+8pWctCcM e5baTTlOnfRkqLhCxBlShrBgaxyIkS4WIVNcAxmIJE/s4eNjbjCWUMTI72892c0DBOzYau+i07L TfOwxbL+Z8+eAwpXGZw3Kht2G9VeHcLQU+uZlw5oau+cOuEE X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Add a new IIO_DECLARE_REPEATED_ELEMENT() macro that is used to declare the field in an IIO buffer struct that contains a repeated element. There are only a few iio drivers that actually make use of 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. Signed-off-by: David Lechner --- include/linux/iio/iio.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 872ebdf0dd77..28b708166b9b 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -816,6 +816,19 @@ 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_REPEATED_ELEMENT() - Declare a repeated element + * @type: element type of the repeated element + * @name: identifier name of the repeated element + * @repeat: number of times the element is repeated + * + * For special cases with repeated elements, like IIO_MOT_QUATERNION, a mu= lti- + * word element is treated as a single element of a larger size in the buf= fer. + * As such, it requires alignment to the size of the entire repeated eleme= nt. + */ +#define IIO_DECLARE_REPEATED_ELEMENT(type, name, repeat) \ + type name[repeat] __aligned(sizeof(type) * repeat) + 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 Thu Apr 2 23:54:46 2026 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.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 9819E29BD8C for ; Sat, 14 Feb 2026 21:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771102855; cv=none; b=n4toltx7XjD5yzWSnxprV61STNSL1incMHAfu4rfJKI6V/Deu72GBOW8WwWW/sDsea5ng+RJ4ouoi6RkmGZC6BNIMqbiS2omA3qcaZBPZs5tvB+xnLpwoQ3hvSZXgAIE+MxLYc/FWag29UMCtqipY95dpTjdlBgf+XRVVHBCVkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771102855; c=relaxed/simple; bh=jNjN7gD3JF9jQQ5s2IgcCsLWPxaJVNTVrn2kWorSt6Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OocAjdjSJ5JNDMrpVL/hRi4CiOFIzPtpjO+Adq4fVWphVrNwf0C78tt9TwneDZYZLlGnYrxqr8u3SxDhgBKjKGJ7NtcKeDsKSkXrmcAjOzDqxoEXJqH5z0KaAqcIR7UN7YQ4X28bekZI0soMS6HWVKOAnb7T7df7I9NMxt3VfzA= 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=vzK8yPtf; arc=none smtp.client-ip=209.85.210.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="vzK8yPtf" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-7d4c12ff3d5so1828392a34.2 for ; Sat, 14 Feb 2026 13:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1771102851; x=1771707651; 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=3KssbkPb1gHaJEaz+zWwlaEszLsE5KF10Og3GBOyj4o=; b=vzK8yPtfEKbUSKNY/rOj8/Weem9BsWSqg/he3CsZjWPttBFKwqRbrT4KK969QSh9FE ZXlg/Fs5DlKgPHcJRqA47ThYl1WzjJyk39Oa10IjWZTDAla7V/LPo118YxJCdcH47PsE 2GfVWPhzXOee5YrVq6qdAJgcel4hFwcCQtxbA4x2JWbOPeh2XksgJu0lhHjNQUY/IxK/ pEbZ78PVyjGKuQnZmaB9Hpcbj35cgE2nSHwOMZemAaLDJUQq5ucwOg/wHioNQj80iJCx 1edKBQDH2Wr4poze6GXJgIb9j9aiff/4ngwxoGh3oiVl62z0LbE3BNLlKw0b+CZ7kdra 4naQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771102851; x=1771707651; 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=3KssbkPb1gHaJEaz+zWwlaEszLsE5KF10Og3GBOyj4o=; b=wuGBMkgsDG7hQ5srlyQDPXVfRcSKpYJPHAtM91Jb8KRF8gk6Qiias0Dd9PP65y/edf vC/RAX+JbmpEMkWFDGUcMO8AuA7vxEOFqWVFHpFBcGExEEU91LbBKpbWuLRvVHdFmxZr suUBGShVuGRAzxHg1Q/gburp5w7r+x+VHeKeKiJQdL2V5Fa+6xValkYgdLa2hidFCaWQ XmjMsU2ElVgHhH8uFG6zRYkO1Nan+BjMpVR/GmeL+N+JtHHhS4iCzbzn4PQBiThrRIuZ rMO76W2TRiwT8IhEo2tMHq3IyDZd1caphtTm9429VsaVWv04J18djVRk5/Z4KnjGiCcF vz2Q== X-Forwarded-Encrypted: i=1; AJvYcCWBvLYbmb55VHigxWfJQbD3AeTFqkCCc64ehhvKWPHd1CR5ssyJl/OsesEzhnNN9ayoMqqIGOPotT2sOTc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5ENUAuNWTAsgHAIHSY4dnJbId5+m9ReedsLnb35/Nd2jief7d 326GNpQ01PrXN0+jzn1E+IjFijQIkQKmVL11A6/V9yokNz5+cYxQ7mSiJ1v2bLsCcXk= X-Gm-Gg: AZuq6aI7kYwFbGl5jNK/hPbl8rZO7IcKmYb1ihDpL5D/uneMxOFKPdAXzBtgR/EefvL izzWiuwohGnp/iCtd/crsiLPLw9yzal1NEnD5zzwDoCnI8neHhnHypSkBjv2birLQffErSAMCkI IDdMXOKVxW8kg3ObuDZPftFVuKTz6UEcydMoGm93N0LNmtDSWfzI5ewCcIG9yalAkEiE7MBgRF+ 2tJ42as+D+65uDFcmgOc0CKwc5GsDiLCNfYLZGsAbsJtSLJH0tyQcpj8YSRrwEG3HEDd5lLLms/ P/DNUYRFEFwK0bKwqS3FWWCNSvSfkhHJ//JJaI2RuulcCkCVO9BaPpSG7siX6IuazDILAiJCf3Z tizg5JDUK/WPBTRPUxIm0/oqsk1hnCM0xAXuK0A7jUruFxKD6He6HANNsCMTir2MqRP/eYTj1x6 YN0BPRNfpFqYfHsVDcL42TNpQMbg== X-Received: by 2002:a05:6830:2e07:b0:7d4:bcd0:db07 with SMTP id 46e09a7af769-7d4d0c7aba5mr2222848a34.37.1771102851474; Sat, 14 Feb 2026 13:00:51 -0800 (PST) Received: from [127.0.1.1] ([2600:8803:e7e4:500:109:393c:254e:962e]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d4da074c15sm1181680a34.15.2026.02.14.13.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Feb 2026 13:00:51 -0800 (PST) From: David Lechner Date: Sat, 14 Feb 2026 15:00:21 -0600 Subject: [PATCH 2/2] iio: orientation: hid-sensor-rotation: fix quaternion alignment 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: <20260214-iio-fix-repeat-alignment-v1-2-47f01288c803@baylibre.com> References: <20260214-iio-fix-repeat-alignment-v1-0-47f01288c803@baylibre.com> In-Reply-To: <20260214-iio-fix-repeat-alignment-v1-0-47f01288c803@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 , Lixu Zhang X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1239; i=dlechner@baylibre.com; h=from:subject:message-id; bh=jNjN7gD3JF9jQQ5s2IgcCsLWPxaJVNTVrn2kWorSt6Q=; b=owEBbQGS/pANAwAKAcLMIAH/AY/AAcsmYgBpkOJ6F/c+o0+u4560tz2ShMNf0GrCyrMUkjWcg EqwUCxz7j6JATMEAAEKAB0WIQTsGNmeYg6D1pzYaJjCzCAB/wGPwAUCaZDiegAKCRDCzCAB/wGP wO0aCACNVpVpzq5Z0KzGvMClnuShr68EGfgfW8/MaM0b0blIw6AOuLMd2H8WsUzQ6t8E6jg1Ibd PUYL7b5N98E7WTU7ObNs3Ulj/ewdYqxgHl63xDVPFY8NbjxjOwGZo7L9o7wYHpkoQVJ+82C7/Wn /Wx+IhxkUhqnFF1+1qu70AeTX5PU5CyvNB+BOLxV0abWA6xEMOjiL+OGJjm95Cs/o/y8hZYj5++ zOyQAdcRaHo3BWdoHNCRGitXWADDNbrAJ60QknZgBnO6IlaRhTtymRYWOtuaecXvC3aLTfSgis5 k00n/YwwDJYRYYSxwe3i65WlLEtXzjVOXTNueLaUSKRWkPDN X-Developer-Key: i=dlechner@baylibre.com; a=openpgp; fpr=8A73D82A6A1F509907F373881F8AF88C82F77C03 Restore the alignment of sampled_vals to 16 bytes by using IIO_DECLARE_REPEATED_ELEMENT(). This field contains a quaternion value which scan_type.repeat =3D 4 and storagebits =3D 32. So the alignment must be 16 bytes to match the assumptions of iio_storage_bytes_for_si() and also to not break userspace. Reported-by: Lixu Zhang Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D221077 Fixes: b31a74075cb4 ("iio: orientation: hid-sensor-rotation: remove unneces= sary alignment") Signed-off-by: David Lechner Tested-by: Lixu Zhang --- drivers/iio/orientation/hid-sensor-rotation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/or= ientation/hid-sensor-rotation.c index e759f91a710a..9df955ecfbac 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -19,7 +19,7 @@ struct dev_rot_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info quaternion; struct { - s32 sampled_vals[4]; + IIO_DECLARE_REPEATED_ELEMENT(s32, sampled_vals, 4); aligned_s64 timestamp; } scan; int scale_pre_decml; --=20 2.43.0