From nobody Mon Feb 9 00:55:16 2026 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 D9DFA3596E8 for ; Mon, 19 Jan 2026 10:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768817097; cv=none; b=FkEotezIiXC3LcO4iKaQtF1oU6Rd1xwpWnwecxmGtYOUL+HYaf64I2FePYXDQhPNilsxvBp1prtW8gtcSnJzreckdfZFv5ve4PeQXj2mFwOrrTF38r9d/gZFbkqIGA1PirMP61cNd5Z7l5hmDQjQME6xbqF/JAnAACoHEholfpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768817097; c=relaxed/simple; bh=MkM0A/HsyN7aXTv8muMJJ3kq/6hFQVpMJ9om7R8iWDM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vx0jss2BHMoHcMRdp1scyodPisJa6qyzmUxqvAFjwABGB3r9JYEeddIZqRYddzSfZBX3YOz3kIM+GnqtrgiXI3XV2KapXx3wktyzpJztTmVrQ5L4h7g/avo8l+X5JyjA8K2ErKqV5ezTtByh9DFOpIUWe3pMBga8HjhOS/IOoz0= 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=2JE4x0ZF; arc=none smtp.client-ip=209.85.218.41 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="2JE4x0ZF" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-b87f3c684a1so4625866b.0 for ; Mon, 19 Jan 2026 02:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1768817093; x=1769421893; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X2z+T2tcANuxuNpL/O66Pi5lTdKISXJnPtDtrt0skqs=; b=2JE4x0ZFFIF59kIBSF8mPvAv74Z2IzHmNVuV7afNvrhHDfuzYzvvW8QMCG5UlsEhHf bJL2g5IQ6nH1194PDd7Pfc8Vv7tpoasg5VgTxBbIyD/flWkmB+l5MtYc2dgmfHvSUvMp QLsjN/IAo9H9bQmeir3htoGttjVkR8A0bo6/mvAo8PiR0onEStVlr9SiVHq/ef+8x7+M m3EkzTn0I+3Eu6ENpWaNbJuUEyc0zzj9+LMaVfcybNesLx4h1vANmgwO7i1UhFEueiP5 Ydohiis6qpKbCzLFLe9IQkCa8km7/N77WVeBKb55ByaBU/IaLfriXveVuJnAjxmYEYLE 4n5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768817093; x=1769421893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=X2z+T2tcANuxuNpL/O66Pi5lTdKISXJnPtDtrt0skqs=; b=Te1yzHRC9r5uy44Mw5nnL7A6lmvtZuw7riwsrLkBokyg1FIqNVILoHI/36wfpAvS+f Rsxnf7kaXh7buQ3rmNs/kvcUhtUHAUEjNLVkSb2L6XPHk3FRSUxC8LMLb+qbWymtsHA9 jTbvVsCBACosalv8l+FqyqUtbJOEzIcmi1sxZxNSZFeks6uerYvRPYh1rVYJY6PB40JB asAxou4TP/6sJ/t39l5LKQyMIxLjO81KzonK6cmRsYaenmdhTtwm9urvbwkXAYUNbN5/ zvW3p15aghwoJ/ztnBzLJB8Og2cg93UOOaSt2ZsmwRFS0RRtNDBxvt/46ZrRozornTvY RaRQ== X-Forwarded-Encrypted: i=1; AJvYcCUS7FKqerfxe0Pxwc2PyMC+giYW+6GAdhBuF0FyqQBWt3a8Qd0z7fIoMN+5lAlgMe7YOb9VY2o9Br/0oxs=@vger.kernel.org X-Gm-Message-State: AOJu0YxvHq/JfUgMOUD8/NxH/CJcLO/QwPia7AyAyY92avRFm/hIyaqB 39lhZgGsz+1y9z4FiPuGEotsiysG3GrpRWRdOx0iTucK8fnKeF5iA98poydE4jzXxFk= X-Gm-Gg: AY/fxX5L0DbfxTQm+GqF2iLugyAGMgBArKOf3FmodNcEJ/sydA+zcPKzW75oTLL1W9Y AxnAkJkna9d7wZqZk1kEhyPKUj++ZQvrWGKMzyrc+d90SG7PSPm7vYhxms7n5qDKMM3KIJ/luqI pwgsmSl8mG0JkjDSbFILAzz01BygRDG5xLK9t/im/Y6Ms7cEOMMFJCNE+tCHzV5CJdHHo7+2XwW yIzrQMF2jTMg7IVy1RN4lObbn6kjx63jgr507t9htqXDTo1Kfgm9JJQHr+jR9g6vqmLD7C9bl8u pfYjpGUxFpyzrHnC9VesfRyz1tSXXJpsW2VjKXC0y2LwXQpP5y8uBDnt6wyVOepgryPmJvw01zW QNl/1Gg0IzNnQlMbbwBcpDduiuZ6sJ1dm+gDZACuyIFcs+2SX2RQ7oDM= X-Received: by 2002:a17:906:7305:b0:b72:a899:169f with SMTP id a640c23a62f3a-b8792d6cf8amr1035219366b.4.1768817092791; Mon, 19 Jan 2026 02:04:52 -0800 (PST) Received: from localhost ([151.37.196.5]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8795169dd6sm1121075766b.27.2026.01.19.02.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jan 2026 02:04:52 -0800 (PST) From: Francesco Lavra To: Lorenzo Bianconi , Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] iio: imu: st_lsm6dsx: set buffer sampling frequency for accelerometer only Date: Mon, 19 Jan 2026 11:04:48 +0100 Message-Id: <20260119100449.1559624-3-flavra@baylibre.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260119100449.1559624-1-flavra@baylibre.com> References: <20260119100449.1559624-1-flavra@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2119; i=flavra@baylibre.com; h=from:subject; bh=MkM0A/HsyN7aXTv8muMJJ3kq/6hFQVpMJ9om7R8iWDM=; b=owEB7QES/pANAwAKAe3xO3POlDZfAcsmYgBpbgGpzekMRgLVMzJRzGAWVnmajJ5v55zV0IGmF GehD4DC7SWJAbMEAAEKAB0WIQSGV4VPlTvcox7DFObt8TtzzpQ2XwUCaW4BqQAKCRDt8TtzzpQ2 X8vODACCXUbvZQprbWo5N0TTH+AgAFSCd8P2nUdAUySttBuiD4x+6cjnSXKha2V2xdldqUez0oj BxY2QKviGb+B+L9KbczmjbbJBcRS+8tVk7G0+5xJfTOBzxIFP+4DNFNzVrgo8nindu+K4FJfrvA /FklhRA21ROu4tO4DdQYKUUMBIqQTimyX3tIGRJJEtfR0lDHwuBQfQkUSz0LvcT6jTne7nB2s3R PVTvYSRQ5cvHcMMs8hdVVas9AYz1fb/AKKnfX5Ay+QjBtu5clv6NhiZ5IwHbT9ButvQ5yH9XKBm Mk+oHVveCVIotqEqWsL1ldvt2wczWIyA591JlpgdjnP+81z2i6lZHGQpTrEi0DNLE/zoU6pp9j0 jhwdGPotfG1AOzmmW7oI9hYfrT3uWhPq1cl17uFgiBHCWY3vIRJw5Iy39lly4sn1TImPSfSWtoy CPy+/eJ+hujserj5uNrZztD+M6wWwzPv9+f+dlivEx13cWIPTzu61r04GSDkh+eTMIUrY= X-Developer-Key: i=flavra@baylibre.com; a=openpgp; fpr=8657854F953BDCA31EC314E6EDF13B73CE94365F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The st_lsm6dsx_hwfifo_odr_store() function, which is called when userspace writes the buffer sampling frequency sysfs attribute, calls st_lsm6dsx_check_odr(), which accesses the odr_table array at index `sensor->id`; since this array is only 2 entries long, an access for any sensor type other than accelerometer or gyroscope is an out-of-bounds access. The motivation for being able to set a buffer frequency different from the sensor sampling frequency is to support use cases that need accurate event detection (which requires a high sampling frequency) while retrieving sensor data at low frequency. Since all the supported event types are generated from acceleration data only, do not create the buffer sampling frequency attribute for sensor types other than the accelerometer. Fixes: 6b648a36c200 ("iio: imu: st_lsm6dsx: Decouple sensor ODR from FIFO b= atch data rate") Signed-off-by: Francesco Lavra --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/i= mu/st_lsm6dsx/st_lsm6dsx_buffer.c index 1ee2fc5f5f1f..5b28a3ffcc3d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -862,12 +862,21 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw) int i, ret; =20 for (i =3D 0; i < ST_LSM6DSX_ID_MAX; i++) { + const struct iio_dev_attr **attrs; + if (!hw->iio_devs[i]) continue; =20 + /* + * For the accelerometer, allow setting FIFO sampling frequency + * values different from the sensor sampling frequency, which + * may be needed to keep FIFO data rate low while sampling + * acceleration data at high rates for accurate event detection. + */ + attrs =3D i =3D=3D ST_LSM6DSX_ID_ACC ? st_lsm6dsx_buffer_attrs : NULL; ret =3D devm_iio_kfifo_buffer_setup_ext(hw->dev, hw->iio_devs[i], &st_lsm6dsx_buffer_ops, - st_lsm6dsx_buffer_attrs); + attrs); if (ret) return ret; } --=20 2.39.5