From nobody Mon Feb 9 21:18:41 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.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 4FF4A3EE651 for ; Thu, 22 Jan 2026 16:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769099028; cv=none; b=JV6wRDmxMio6nT5XurypiH1s9oKIwTtlWuB1XdSXHQvy2lJiCZvWCB46p7VrY7+fyTkhYaFvDGqkaAUs64fKP0/sKhpGeCLz4yBokpdSVfQl36ZXZv63I3pcc3RDngwSEX0zJlEmpCicf043N/IUyP8K7L7cI2dPHRHsSeMLrt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769099028; c=relaxed/simple; bh=MkM0A/HsyN7aXTv8muMJJ3kq/6hFQVpMJ9om7R8iWDM=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qe853ym7lYzOsH11w6q+GURVl3/BtT1PILXPBm9m+IShn8eVpGROyy5TnkAtll69rae/Jwmjf8AMYQ2i9ZUehg6brOglwppqFvVRZR90ntCmDmP6UFYa8bZbnOJkhfk5YkyWU46YAwN/3pP3yGA6FTrEbqfMrufhRvce9j6lOQM= 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=EAH0f3ho; arc=none smtp.client-ip=209.85.128.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="EAH0f3ho" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4801eb2c0a5so12144185e9.3 for ; Thu, 22 Jan 2026 08:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1769099019; x=1769703819; 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=EAH0f3hoCmJ3qLW3HZyX21bK6V8dBE25jcvMv0ocLcyMDUvYkzlXEv3cYUlSfykMiL jSoUOmOriq4gcbpcx0EFS7PsHW9OxmuN9KKmmewayO3t9mYy5P5r5UvIbrukbGcn6LAj mjS7IVa/psdFqFFbZ7lN3q5zTBqHU8yqj51BckV5uCsz7+fEwPCRFaFanqoQtwqljqPN VYGQX6Qjzik78h/UuX5SMFBCeWSkVUOB5l+LlbtTozYh8BWi99qQGDGahWddf399Zn2n zbnIsEM4vFhZT3oUvM3GWy9uUgD3IAPs5xJQD59J5mudW2EG0ad0mY7xJ034Gw8s7cPX U8nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769099019; x=1769703819; 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=rMypQVmvzUHokOhjB4jISXlgaGE7p+qd+ImxLNjfW+G25zsAehAya8HVw/EpkdYQyA NyEXArb0Opotg+REkt4EVQzM6qbNKdhTHrfj9LG2T+rtGzioTK/L+Ujkn1GkrIS/uAjS Fx0Podi7jUhr0uy6q8XhRpdFixWZtBSRmmQGfC1SKr1d0SeZMsWv7poE4PD9IjuCb8z2 nba97B0Eq5Y3WXpx9DXP8IAqn3mjEI2Al0L0lhHZVMDHqj/Ke+kXFd35ABWO0csy3jf9 d5VDbcELrtGdBV4tJB5fWKLMIXJtRFi5uh9opQ7/xfnedDCPkaQBJqUoNgVSvgYfyHrK VkoA== X-Forwarded-Encrypted: i=1; AJvYcCW3IrcghFk5QEBt7K6FcgQFaJG9ZDccbFziswivDgepKOJvgYdnlpkTEauJfYLxqyXjITSdmi1jjb24gyw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/hrjCbSmPV1mCX5Tl4xqjbwLOEpPxP6ZLP5I/bPh8pYyoSkhL aCl8mUj2L0LP7szvmGNNirmMZUKnn4J6POBSco/7ux0SIJC6KKvs/7UgbdWrJt1haLk= X-Gm-Gg: AZuq6aKzxhoxBxjtq9XIzp1N5aw+whZ93I6jTppqStXf2hiMK0pEsvs4vgqiGKnUEoc V/YgRLLEd34DRSzKCqtXbqEIDohgAOa96pjibRQHN5p6ZStfq/NTaO5H8bbYkN5LDydB97kHwrE c3hPkD4DznDDZxUS6PCohT6lpXhHQ4wH3uvTuEu06WCNy8O7KMYzKYOEqQlK4tDNf+zmcH6KzWE /x57FOcgyLN/S7whMryMZNJKWATOE0nwyx8fB3TF3a1j9pFqeC039WvlDNn6WBXqb3JDy52F1f7 CUdj66gQj2q4cOZFvZJLLW6Ri9U72Mtb9qUyROtGXjFIQB6RmAPCcZSendbd2Dt0MCnmKmS8Mf3 f2CK5jVoyJ/3CRZA2rRZEbpeJOfiICBr0MibHp/ULvdLMt58xiEt9QWsClLmpJdQNw+xz X-Received: by 2002:a05:600c:19ca:b0:480:3b4e:41b8 with SMTP id 5b1f17b1804b1-4804c9db040mr2784365e9.33.1769099019276; Thu, 22 Jan 2026 08:23:39 -0800 (PST) Received: from localhost ([151.57.192.129]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43596291e0asm17268482f8f.15.2026.01.22.08.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 08:23:39 -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 v5 2/4] iio: imu: st_lsm6dsx: Set buffer sampling frequency for accelerometer only Date: Thu, 22 Jan 2026 17:23:33 +0100 Message-Id: <20260122162335.2020006-3-flavra@baylibre.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260122162335.2020006-1-flavra@baylibre.com> References: <20260122162335.2020006-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/pANAwAKAe3xO3POlDZfAcsmYgBpck7o8/bTUHWtdx2A2C6OfJtUtmuStD+mgbvOu BhcilH85FCJAbMEAAEKAB0WIQSGV4VPlTvcox7DFObt8TtzzpQ2XwUCaXJO6AAKCRDt8TtzzpQ2 X9FaC/9hVNScf0X4967gBKmXzMyIjnUD3tvR3u7sGNDAD1UEmydk9fQ/0mLaPjN9Q9PflDEq8Z7 ujhXCfRMcFbnR5RJ/0VcJ8BMdjK8GYG4iEAPauj6RhCUuLN8nJn9ORtTZzGnYm2p4H4sx0eIVEG 4u+a8vKFf7TOeMq0Do12SdNpr+nHTR1kgLNvsBhn1I3f7PiKJoFUpcG+zRFrceIWmUZJnCZ/tHo S7J+qT3/TFBzsOR32Fnx2dMobLAXfUI/SxemaRJXc+UeduWq6UaGKH3Yn3DLWhrM8DHVTS1Z2gU TeWfLKQD8xVper+z7cKKmZ6q6OQ4eCSVb2lBZ1UgeUNqVjngQTEukMwCJJjnCKJOuvrQo+NEOiq x/vgGtshNZ0kpI5TkL64E8syxQG6H3o2AyIHcZ/WUmE+FcziLsIi8wDYK6oHuQfgqTTactcaUC8 Hqqs2w1u8ios7gvgrBpaaIwWcZz+ECX1B6P8s/91G2RLn01wxpaDqWpg2iTmhQOP2sVsM= 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