From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795610777; b=B83/0RH/AtzdmLBRxwl66kx9sanqzMxLQIjAb7wVi1BAq+rdeXeffwd4co7DYZElxJTA OZY0eyBHdYf/mW/bOikA7NycjeVUPsNFIEvscjS9d4b5K8H87MiLNyAheV33RvOfoMWa5 OZ4TK0SoNrDABfmVpGS6kjktPi30q4Dh/4g6HkA3FwwcB9J+khrZVySnU9cINyAQEVw6h vbDU6dl5G7Q4yTQjg8ZGGISy/hyIhz29t0A41KHbgaGW03UQE9qJZ9QROtCNh0ckSz5g7 pUpEcUVmF2LGuE4rHUQR4n0L7BgM0rtlXKS1/PFt2EpGz3ZzaHDpinEkK3IxHcf4uUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795610777; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=cUmWdK6dQFTl2iVjV70D8rBSDkgVWeWtirRsqyEX8ck=; b=f0XwrrNujCuH1ZfEK1whRKYkVuoVjZLs5E/msoCoMZZLC8os4XM58qJ5W488+B4tBrnK B1mkGlobjiK9WmsoWn7Cv6Qn6gTG4YpLSOoEqebdIy8o9icC9l/XD47zNTMfjfq2JIqQx 9LD8mK+O4e6B11Ku/uTRzCETydL8q7LIdyKiP0g/gY2WKmeCh5o2Ql6JDWKXXS/r+oQqS bRhZhX45IL6guo9Ri91agB/dN9P+3Zu0GA9UGS24JqiWzasim/goEICOsW5uaUmVgAqrw URJAMeUxZPUkmBC40Hfv+6aQGF826xAWtd8yvV+veoB02gpPQfzLcNiX+TMz9JDOWaA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=KmNCd0vL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B861F606A31E for ; Wed, 25 Nov 2026 12:46:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=KmNCd0vL Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6DC11F000C6; Wed, 25 Nov 2026 12:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795610777; bh=cUmWdK6dQFTl2iVjV70D8rBSDkgVWeWtirRsqyEX8ck=; h=Subject:To:Cc:From:Date; b=KmNCd0vLvgS8wFcOJLd7svfb7KpnlKe+ryU+XN8tkpYD0Awx3WIVSaGf4ViNZGkc8 JsxfSanBaLcbcZA3igU+N8bmLERzoXRrcjpjxhp1W7htP9k205ZdrIL7NBvU9lFtcK hmNjI4Du96XddthWqtHuld9e5+KImqCgri577ppY= Subject: FAILED: patch "[PATCH] iio: proximity: sx9360: fix sampling frequency write and" failed to apply to 6.12-stable tree To: kapoorarnav43@gmail.com,jonathan.cameron@oss.qualcomm.com Cc: From: Date: Wed, 25 Nov 2026 13:44:28 +0100 Message-ID: <2026112528-drastic-whiny-c11c@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x d252425c1533bfacd5940faa3371af82196bff5b # git commit -s git send-email --to '' --in-reply-to '2026112528-drastic-whiny-c11c@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From d252425c1533bfacd5940faa3371af82196bff5b Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Mon, 26 Oct 2026 03:42:38 +0530 Subject: [PATCH] iio: proximity: sx9360: fix sampling frequency write and available range GNRL_CTRL1/2 hold the scan period in units of 8192 / FOSC, but sx9360_set_samp_freq() computes freq * 8192 / FOSC and mis-scales val2, which is in micro units. Any integer frequency then programs a period of 0, and fractional parts above ~0.26 Hz overflow the int, writing 0x10 to GNRL_CTRL1 outside the SCANPERIOD field. Compute FOSC / (freq * 8192), rounded to the closest value, and reject frequencies outside the 1..2047 period range. The available range doesn't match the limits in the comments next to it either: 4 MHz / 8192 is 488.28125 Hz, not 448.28125 Hz, 4 MHz / (8192 * 2047) is 0.238535 Hz, and (max - min) / 2047 is 0.238419 Hz. Use those values. Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support") Signed-off-by: Arnav Kapoor Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c index ed83d809ecf5..2a9b37df8f62 100644 --- a/drivers/iio/proximity/sx9360.c +++ b/drivers/iio/proximity/sx9360.c @@ -14,10 +14,12 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -43,6 +45,7 @@ #define SX9360_REG_GNRL_CTRL1_SCANPERIOD_MASK GENMASK(2, 0) #define SX9360_REG_GNRL_CTRL2 0x12 #define SX9360_REG_GNRL_CTRL2_PERIOD_102MS 0x32 +#define SX9360_REG_GNRL_SCANPERIOD_MAX GENMASK(10, 0) #define SX9360_REG_GNRL_REG_2_PERIOD_MS(_r) \ (((_r) * 8192) / (SX9360_FOSC_HZ / 1000)) #define SX9360_REG_GNRL_FREQ_2_REG(_f) (((_f) * 8192) / SX9360_FOSC_HZ) @@ -182,9 +185,9 @@ static const struct { int val; int val2; } sx9360_samp_freq_interval[] = { - { 0, 281250 }, /* 4MHz / (8192 * 2047) */ - { 0, 281250 }, - { 448, 281250 }, /* 4MHz / 8192 */ + { 0, 238535 }, /* 4MHz / (8192 * 2047) */ + { 0, 238419 }, + { 488, 281250 }, /* 4MHz / 8192 */ }; static const struct regmap_range sx9360_writable_reg_ranges[] = { @@ -383,11 +386,25 @@ static int sx9360_read_avail(struct iio_dev *indio_dev, static int sx9360_set_samp_freq(struct sx_common_data *data, int val, int val2) { - int reg; + unsigned int period_ticks; + u64 freq_uHz; __be16 buf; - reg = val * 8192 / SX9360_FOSC_HZ + val2 * 8192 / (SX9360_FOSC_MHZ); - buf = cpu_to_be16(reg); + if (val < 0 || val2 < 0) + return -EINVAL; + + freq_uHz = (u64)val * MICROHZ_PER_HZ + val2; + if (!freq_uHz) + return -EINVAL; + + /* The register holds the scan period in ticks of 8192 FOSC cycles. */ + period_ticks = DIV64_U64_ROUND_CLOSEST((u64)SX9360_FOSC_HZ * MICROHZ_PER_HZ, + freq_uHz * 8192); + if (!period_ticks || period_ticks > SX9360_REG_GNRL_SCANPERIOD_MAX) + return -EINVAL; + + buf = cpu_to_be16(period_ticks); + guard(mutex)(&data->mutex); return regmap_bulk_write(data->regmap, SX9360_REG_GNRL_CTRL1, &buf,