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=1796446126; b=PbEFpIsfw2IeZSvMmbzGLhRAdWM+cK1AgZc5mCh2yMWVJUXSooDedmnCmNyt2PtQ/tyC iu6mIGsp85JwjR/LxSIo7PLjO1QESqtzwderp+CYY0SJqfloNEioNTG74JQupIetJvOD5 +B3LqyK0CNR0tR+1SvCTnS51muZDpNn9s5SHw5fTqZ2wh2FydYtq2lwNfrCm9NpkcfEwS WGFD5TWWgW4uzH37Jo0t58CClFV8BQ7OIA1hbctgOpdiH54MRh+B6eyyD6HfniIlrL432 rwfBJRxs7pX4XM20zLJGWQpmDjhjR8SOE8VG5F7gwPdhAgIigKWZaryS7EDZG81SzMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796446126; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=IzXIOnB0yNtZW2jBvP1TPsHjOMqvWcGXc0gHbNgY+vU=; b=Gdl81/XHSzaDSCHEhCW6j2qDtA36DagACl9keRERt7vxO/mtAr/erswKtZNqzhlbloE4 PvAtLw0lriGr8imIq/dOHc7Y++HSTTmWmslm2+N0YIX0kwwRRQF6E/n+gemkmy4AGi64I +MOA6YbINweMkdN9iNEIkGW3YZx0nFzg9uGl5425W9nRhwH55n2obdZUoCS27Xm5GxNp/ QNhhlVONf9HovBs07wG4mBEtLZmH+aEyc8Bhhlf1VWlXrxPbOI/nV/mPrT2xidbFKQZtJ Myu8obz+3QZX3g92ecxAjhZHoWbR9RR0lL+4yxtBLJjUUrot8bPfizf1rDWHzOC6jQA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iiYlhXp8; 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 275D7606A322 for ; Sat, 5 Dec 2026 04:48:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iiYlhXp8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F11E1F0092B; Sat, 5 Dec 2026 04:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796446125; bh=IzXIOnB0yNtZW2jBvP1TPsHjOMqvWcGXc0gHbNgY+vU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=iiYlhXp8cLG0lrsewujLsQvlYsNwYC5+Z8C7VCJYiP46RWtgNRfdH2pJTHBywnlN0 oTiOGn85GXC6d1ceqvr8Z759bjxuV+f9N0BHv5zb6twMm5YYD+MEiMyHMTHofV07O6 h8/igYgq1c8cZ7kKWqP7oGit4g+mISHRXBNxYGp2D5JD3Lr/vYFSB+UyZj0a8dgKPp F4fJF8Kacv5X5F09GKdqQzSMsuLAxVNvw15Xahd3CQ3WU/Oi42bIdkWu1UEQ2IoUNk NV0oKDSGoazszvZgGDOPvlYwERi9M6jrYkIw0H2nGaFqM2jCA47Jra0A4nXWT4NpKZ FC7fEFBN8Up4w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3] hwmon: (tmp513) avoid divide by zero from rounded-down current LSB Reply-To: sashiko-reviews@lists.linux.dev To: "Shirong Zhao" Cc: linux-hwmon@vger.kernel.org In-Reply-To: <20261205043727.18-1-shxzhaosr@163.com> References: <20261205014552.39-1-shxzhaosr@163.com> <20261205043727.18-1-shxzhaosr@163.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 04:48:45 +0000 X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list > tmp51x_calibrate() computes the current LSB as >=20 > curr_lsb_ua =3D DIV_ROUND_CLOSEST_ULL(max_curr_ma * MILLI, 32767); >=20 > and then derives pwr_lsb_uw =3D 20 * curr_lsb_ua and >=20 > div =3D DIV_ROUND_CLOSEST_ULL(curr_lsb_ua * shunt_uohms, MICRO); >=20 > so the calibration register write is DIV_ROUND_CLOSEST(40960, div). > curr_lsb_ua decreasing with a larger shunt means that for large shunt > resistors DIV_ROUND_CLOSEST_ULL() rounds it to 0. Both div and > pwr_lsb_uw then become 0: the calibration division traps, and a later > write to power1_crit (tmp51x_set_value(), DIV_ROUND_CLOSEST(val, > pwr_lsb_uw)) traps as well, because tmp51x_is_visible() only hides the > attributes when shunt_uohms is exactly 0. >=20 > curr_lsb_ua is a minimum resolution that only needs to be >=3D 1 uA; round > it up with DIV_ROUND_UP_ULL() instead of to the nearest. This keeps > curr_lsb_ua, pwr_lsb_uw and div >=3D 1 for the entire valid shunt range a= nd > lets large (but valid) shunts calibrate normally instead of being > disabled. >=20 > Fixes: 59dfa75e5d82 ("hwmon: Add driver for Texas Instruments TMP512/513 = sensor chips.") > Cc: stable@vger.kernel.org > Signed-off-by: Shirong Zhao Sashiko has reviewed this patch and found no issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205043727.18-1= -shxzhaosr@163.com?part=3D1