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=1796385764; b=HKWI+Ah4ywkGdqvnCQ8DfjgQTY3w/sN79Ri/JkbbYbSYu+awkoWWP/RjdneAmf8xrRsA OqrU4QBj7zhuPGeo4zfaon8mLKjhGmAOj2vFgsK4j+ixYxIV5vBRx+RmRLiV+BsC5FsTF +fcBjk37PebbRvoP45qGApFPdwWIt4NZnQxX3X+1XT6pgF0P5WspibnBGJQMYJMTRTK+0 0gQ1jPz5ZtVAApLEaxXRLgcS3ebsTFLVjQq+h8QjlZVtgB4ENtGQ9zTOCF7J0UOXuKCrl 4PHZo7wU0qy/sECxfm9nGkztWqK7AZfEDVSDhcMssGEjAkQidKUrowpXDthrGokQn2A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385764; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=1G5FmRcwQxggnqeGQGtEbrbvcvB1XFqUcZse6NRShX4=; b=zRX9/KNZe3YfG0M0rDoZdwtMga10MvaYRfAoBN4uukitYy2orzE/1iXYgq1fkyYz2UrR A31Uv9M4JMJFz/QjlVb1sVmquiCMHN1/1J6u1LacMBg3tHebNl/iujNJD7AlPqDGhfaO2 2HyIGQAxsHoRL3ca7cj7zSDKi1q0pduvIF6Vvuvo92hzCJ/XHFq0ebVLVnK+jIRxrnCLR FWljv2iAXUTTCP1CwHXPgkM5jP6wuDK68tgvd2CzbTCs421H+cEUFYRfj1XlZx1Q0D0Cm 8QG620l53s0IxILGoEaKUfYSB0XnJrWoneqeNMpJ5aJL1XYDt11MGtZ/rTuKhx5JE6w== 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=cRKBl8rI; 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 DE2AE606A322; Fri, 4 Dec 2026 12:02:44 +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=cRKBl8rI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57CA41F000C2; Fri, 4 Dec 2026 12:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385764; bh=1G5FmRcwQxggnqeGQGtEbrbvcvB1XFqUcZse6NRShX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cRKBl8rICygf8dFo0RGFP+kpyvYAnBMSM4ZNfAvTxMkkK15W4avaRIJZPVOPNtGg+ S6eOPZ1FvzV8CBxP7EIoRnchRZp0KT+eYF6neXgAX0uEh4ArOkzS7a0yQ+Woze4I3l 0wroLl/SRKD+56YBXmr/uYd284rvev2jfSMNUfCc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Srinivas Pandruvada , Semyon Maryasin , Jonathan Cameron Subject: [PATCH 6.6 0686/1167] iio: hid-sensors: fix fractional part for unit exponents -7 and -8 Date: Fri, 4 Dec 2026 19:01:53 +0900 Message-ID: <20261204100719.933828019@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Pandruvada commit 79c8dffd84e9784ec05bea68dbe5e71f7ec9941a upstream. split_micro_fraction() scales the remainder to micro units by multiplying it by 10^(6 - exp). The unit exponent of a HID field goes down to -8, so exp can be 7 or 8 here. Then the argument of int_pow() is negative, which the unsigned parameter turns into a huge power of ten: 0 modulo 2^64. As a result, the fractional part of a value read from the hysteresis attributes is always reported as 0. Divide by 10^(exp - 6) in these two cases. This matches the reverse conversion in convert_to_vtf_format(). Fixes: 73c6768b710a ("iio: hid-sensors: Common attribute and trigger") Cc: stable@vger.kernel.org Signed-off-by: Srinivas Pandruvada Tested-by: Semyon Maryasin Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -95,9 +95,14 @@ static void simple_div(int dividend, int static void split_micro_fraction(unsigned int no, int exp, int *val1, int *val2) { int divisor = int_pow(10, exp); + unsigned int rem; *val1 = no / divisor; - *val2 = no % divisor * int_pow(10, 6 - exp); + rem = no % divisor; + if (exp > 6) + *val2 = rem / (unsigned int)int_pow(10, exp - 6); + else + *val2 = rem * int_pow(10, 6 - exp); } /*