From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796401698; b=Zf2SXRx7A3F9lY4ipXm+UOBMIistkTBT/LnrqunuP4R46LKj7UdxVmxjoT2y5kRTwVJZ 7zfxdWWPJ8x6Yxoc90vjtEJEV/RsgbPb3wUVXa16cXNvwdGkcJepyeMc3mp265mAcewP0 Qw8AeDwJDm5LkZu88h1Y4lKgMNBsf0f2Kf8K9UeG8VDKwMSCDMcHKhipmds+A0BMo/osZ UgdTw6qOtC9lZgm2AGQnVCQgLZWLwtrskr2mF0gwZVd6CbSe5lqZ4MkbYxlUkiTqzQ7JB H7MQr7B+ezWJVZUKSkn6mlkgK1gp4gYtW0TMP3iCKM+Oa7+E0oXU++FmquK/JHvB/uw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401698; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=VUUY+lMXw1vlO0+oRS+U3Ge8bPXP91hpE2bgOxkCczM=; b=CCPNM2pT4ovasQ0h1xLVQoKHgDAu8iUJJT2m6AwsGom3hk5RPuUO5vrA2kHJ2pOp9RQC Rvt0PH3yIjQsH8PqmXNGgd+ISrtOsNpZ7G7dx7+6aG+mnf2EEbH3z1ULErSvUEbboe8hi my9lAoKiT46tpuL+PbNXBORkMnpHz8+jVh9DEmU+wAjziy+zU+ZxnrSPbrOLv9lWIwUe1 D9siO1FycG2Bx1r3ngeItwL9y7LK2KkI/0JWK1nq/RcQOFV/bS7wX6nb+3sH9QAUckxYN PYxAj02G92uscV5yc2FBi4VckR3zguwStuMDBXBsRyxZ9vtIs2aPn8ZN35HMBGRY8fQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Mbu1K2ie; arc=none smtp.remote-ip=74.125.82.180 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78B64606A322 for ; Fri, 4 Dec 2026 16:28:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78B64606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Mbu1K2ie Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-386ab9ab619so1823070eec.1 for ; Fri, 04 Dec 2026 08:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796401698; x=1797006498; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=VUUY+lMXw1vlO0+oRS+U3Ge8bPXP91hpE2bgOxkCczM=; b=Mbu1K2ievm3wTAkQMrklJtiHZUyCXXbCj0AcgiXx88/Tizxk66jLs39ozjcQtqQ4Yt O6N5UCU1DNasOPqjQvaLy5AKcsPMURGhtfSmsZn8ROgAyeIj28PVXwL2kDyqnXj9p2P8 DhRPxZmcb+7CXCTzW0lrHsyZH1SSkvu2p8TqTX9WLdfVp9tix9pFcGp6jl/x43NA/i2z 9g+G//m8hLIw3rYu7UBh420iPdeDvjiH1+JFneHNTbFGH2txDnB/YV5jw7HUpoeOtD9q 9/eqSa/GJRzHROOydxZevzBp08yK4l8oNqmzR4Mk2uGhmevTo27SqLDgB+fb9DW5kWHD AQXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796401698; x=1797006498; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VUUY+lMXw1vlO0+oRS+U3Ge8bPXP91hpE2bgOxkCczM=; b=CMcderCbSOc2pd/FuCGueWMzL7VnoyyIztMy0kAzsm8SOfBjCG0Fgp+/FZ4KaplZSm h6v+5XvORIhumlTPECPr05+KsA20yEI6Ue78aZv0TOfviL6D8jMOV25HaTpS34TNYA9K hlHtckCPwknMJLkgvA19WHbM5VN+mshaI6hUXJhJXdPmesDVKAJOEiXyOUq7KeeNEEYU HUGvYJuEkzt+QBrihVEqNkKIIhR5fyzwSqK12MWf0SHYQQbaVuTbzauksj69DPwEQEIE p5BM6MID50oZnABkimnCiXKlvKtRTL/sfIL7FmRTW/0O4wzAbx33OKVx+W5WJx8k5vwF rJng== X-Forwarded-Encrypted: i=1; AL+hErGjg8r04XK+OtKTSGAfXaAUo9GvNVYxY8QvtKpdj9oOxliXwD2WDrwm38qGKfLo2ktTEuXvHOHG6IjDAjU=@vger.kernel.org X-Gm-Message-State: AB4q+uGF+oSm4hGxuPKJaMTg4OVgDGdlwVotvnL3x9IHR+q/xlzEG2VY j2A3JXnZyLFcubulYgGFCkWsRSZCkuZ3nFI3u+GuEJTge1nn+EzKT90+ X-Gm-Gg: AZFdTZdVc8outFb0OaycrcjlsS70KzyXwNQa/sp+8+8Izq9rd//Jj/kLtyIQdh4kwmK tXG7wlZBLqlbSIqI5CyJNvu1IV9E18+yqpUfQCzkhw/ZObA36vtefJYrAySUJqkejmY7mjkswoo wMfeeTteU6OtiloDQ7w8ooHkegZEFfPCjggSq3WgI6Dg6U2UdqU/xg3TrazaJz+NlY2jyBLHSFR LwhfEwfV37ghtUnDD7U7GQxB28HVZMQej+6uzoECMyXbIPGw+e0IX2coQeIedpfgIJnx5HhZVIA cdI1au53TCak/U5uNG5DeRvELGfmp6MEhhuEZ61w3MkLAMBFA/Y3b/d8QmwJHxZRT9v/ygIEInS r7QCEnm47d5HiyuAKtwQAAMp6bHOtseHV6j2eSFztMYl4UQU4UaPZmQlCRu4udLkUzaL3CaGZy/ LeFSMpMWOYNRRcK+pSd6UlhAkTJh7oEGnJYzgHTPMjff54c6444sCucEjP3xwa92iITMU4uCiCi JCWsW5+NPOPYIgXr3vWeu4xBOg0GW1eqDghPP1jHbJwBngi8OlOxNSs27218geiBidAjkwWJFPm W/MC17UWnOemxBJO2sw0SqimsPDibVOWpcMUID3eBZwIpAWqc0b6QvW1nCNMhZ8dTkfU9sx/JmD fBCGrmtMv3F48X42B6ROAKZP6CxZNKAfH4NSNhKbuOSj8wHgmLEOcgWg9pHcLPyBXDDGE12D6a+ EBOi9bZuyZz7tW5mTSyKpjaEqO+RLDCw3dic9AB1IR0A== X-Received: by 2002:a05:7300:cf0f:b0:387:44ca:2d6 with SMTP id 5a478bee46e88-387520af3bbmr2456157eec.8.1796401697284; Fri, 04 Dec 2026 08:28:17 -0800 (PST) Received: from kapoor.iiserb.ac.in ([203.18.51.239]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218bd23sm9815193eec.8.2026.12.04.08.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 08:28:16 -0800 (PST) From: Arnav Kapoor To: Jonathan Cameron Cc: David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Andy Shevchenko , Yasin Lee , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Arnav Kapoor Subject: [PATCH v3 0/6] iio: proximity: hx9023s: fix sampling frequency, resume and event value handling Date: Fri, 4 Dec 2026 21:57:57 +0530 Message-ID: <20261204162808.923774-1-kapoorarnav43@gmail.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Five fixes for the HX9023S capacitive proximity driver, and one cleanup. 1: writing 67108864 (or any value for which val * 10^6 + val2 is a multiple of 2^32) to sampling_frequency divides by zero: div_u64() takes a u32 divisor. The check added in a318cfc08537 only catches 0. 2: reading sampling_frequency indexes the 32-entry period table with the PRF_CFG register value unchecked; the configuration file loaded by hx9023s_bin_load() can put any 8-bit value there. 3: resume re-enables the chip interrupts only when the trigger is enabled, so threshold events stop after the first suspend. 4: out-of-range threshold values are masked into the 10-bit field instead of being rejected (-32 becomes the largest threshold). 5: same for the 4-bit debounce fields (16 becomes 0). 6: cleanup, no functional change: get_samp_freq() doesn't need a 64-bit division either. Changes in v3: - 1: compare with 1 * HZ_PER_KHZ, and write the division with named constants, MSEC_PER_SEC * MICRO / (val * MICRO + val2), with a comment on the units: val2 is in micro-units, so the frequency is counted in uHz (Andy). Same values as v2 for every input. - 4: reverse xmas tree order for the locals, and the comment moved to the line it describes (Andy) - Rebase on the current fixes-togreg v2: https://lore.kernel.org/all/20261126213710.1047676-1-kapoorarnav43@gmail.com/ v1: https://lore.kernel.org/all/20261123165255.239490-1-kapoorarnav43@gmail.com/ Yasin, if you could test these on hardware, Jonathan would like that before taking them; I don't have an HX9023S. Patch 2 assumes the whole PRF_CFG register is the period index, as the driver already does; I don't have the datasheet to check whether it has other fields. Applies to both fixes-togreg and testing. Compile-tested only (W=1 for every patch, checkpatch --strict clean). The checks in 1 and 4 were tested with a userspace copy on 32-bit and 64-bit: all 32 table periods are still accepted, and the threshold check matches the v1 one for every value. Arnav Kapoor (6): iio: proximity: hx9023s: fix division by zero in set_samp_freq iio: proximity: hx9023s: check the sampling frequency index iio: proximity: hx9023s: re-enable interrupts on resume for events iio: proximity: hx9023s: reject out-of-range threshold values iio: proximity: hx9023s: reject out-of-range debounce values iio: proximity: hx9023s: use plain division in get_samp_freq drivers/iio/proximity/hx9023s.c | 55 ++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 11 deletions(-) base-commit: 23c47e17ad8c18057f17be2a5beeccde9b5ca112 -- 2.53.0