From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 111663EE1FD; Wed, 20 May 2026 17:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296854; cv=none; b=AUxwYAt/QlRJ1apVSz5XhCNvGry3WDE3ZDfGnBy4fj9+Vq/FHVTQ5oYrvXbM5WuDcajTIbzz5E4hMct3CTfhiUnlCCvqH5SnKZbJ8BEPMHHWMAce41uE2f4X1hK3q1Utu+8lWsjwX8bbIycQXesKntMH7uJnsmGiPGy+5dcJgtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296854; c=relaxed/simple; bh=hk97Lh0wcHT2olwhiF+zu1Zkez6883/5Pn+SV4nzmAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dDM9i22kK+C8P4A8B6gVHoS5LrtBH6OtPTLk4PWJD7Tqisvf4M/Q6OWffN8xXm01shGSVbfSx5gLyIa+h6snN2mDJRYd59O52FoDXpGIlv1xeLyt8oHoXHztCFL03wWHjmKu+qCkD1lw17d0Zp+BcEKlggx/Swb0oW4+6DB7H9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Da42b/My; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Da42b/My" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C84E91F00897; Wed, 20 May 2026 17:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779296851; bh=cTENyQ2kOJVV1cagl7dWGgy848qJXND6aUZ4hDd/sao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Da42b/My3B2rzFgcxV5OC4H+D/EqqZZavD4BPbV2VUmz9Q5dO8r0oCZzmOGWKok1b hq6i76xXG+Me5WgSYgOT5bVK9Oc/sdkMKZum/UC9ozAsjbnjrMiXRjvmUMUeibZ5Jk 1LoOCs4kLfYOPRwAK5GLPetw61JkuaOIsPKLRtTU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, James Calligeros , Mark Brown , Sasha Levin Subject: [PATCH 7.0 0915/1146] ASoC: tas2770: Fix order of operations for temperature calculation Date: Wed, 20 May 2026 18:19:25 +0200 Message-ID: <20260520162208.947466989@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162148.390695140@linuxfoundation.org> References: <20260520162148.390695140@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: James Calligeros [ Upstream commit c7ecb6a61908c2604dda6e42da66724d256de7b9 ] The order of operations to derive the temperature from the temp register values was wrong, since 1000 / 16 is not an integer. This resulted in the calculated temperature value deviating from the value represented by the registers slightly, which was most obvious when the registers were zeroed (-92.265 *C vs the expected -93.000 *C). Scale the reading before dividing the whole thing by 16 to correct this. Fixes: ff73e2780169 ("ASoC: tas2770: expose die temp to hwmon") Signed-off-by: James Calligeros Link: https://patch.msgid.link/20260425-tas27xx-hwmon-fixes-v1-3-83c13b8e8f54@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/tas2770.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/tas2770.c b/sound/soc/codecs/tas2770.c index 6f878b01716f7..2ce3011119bdb 100644 --- a/sound/soc/codecs/tas2770.c +++ b/sound/soc/codecs/tas2770.c @@ -549,7 +549,7 @@ static int tas2770_read_die_temp(struct tas2770_priv *tas2770, long *result) /* * As per datasheet: divide register by 16 and subtract 93 to get * degrees Celsius. hwmon requires millidegrees. Let's avoid rounding - * errors by subtracting 93 * 16 then multiplying by 1000 / 16. + * errors by subtracting 93 * 16 and scaling before dividing. * * NOTE: The ADC registers are initialised to 0 on reset. This means * that the temperature will read -93 *C until the chip is brought out @@ -558,7 +558,7 @@ static int tas2770_read_die_temp(struct tas2770_priv *tas2770, long *result) * value read back from its registers will be the last value sampled * before entering software shutdown. */ - *result = (reading - (93 * 16)) * (1000 / 16); + *result = (reading - (93 * 16)) * 1000 / 16; return 0; } -- 2.53.0