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=1796385767; b=LzEbR694bAFpzninKvo0j1xVQdB5dWEbVO7qm5jYuJ10+YxNa89W3Vr6o8Q+n/JE32L3 627dj5/PouJ6fQLChjxIYnFkfTXiPV0ziVT8IQSEXZf5yHiWmOSVS1F3dz1hOFZ51/KYu 3TQP7CVABFW757MjGuFkD44/4gcv2deTYQMGkcAS/TpqUOXXKT5Z7ML4vLpep0hcSLw9H yEwWZzYtDzfbbrNyUgF3f+JBeliriTx2MNtTT8y5lbjU5t6DYh/0apnAICngIpJkWINLn rcorHe8Fh/7JJKqMrc7Tp2Z8NzPKt9EPahZXQjzZt09778kc5gSFurGASJcSE5o5EAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385767; 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=fEq9U50hVuxAjCXo8NRU7uc0bDlKp0hLc7LsW3CsHRU=; b=5iJSxg7Cdajnzw/vl8qi6RpM6PEHveiY/V9SuVdOCJ9QHRxQcaD889DSstFgu/ZdNcM0 Ohe3S+Mm6YlPFHbUpD+sEgiYD9Q9n+yyoFAiyRkhyMg840Xw5x/o7Iek8+TrqHWtlx6aj dN3mHxC/CSxaRI93irVxaj1s7Njp5M2xE1MvmZALQBd3ZEMuKUQJ8VmsjjIz8Pnc7dBYP n//o+Koje+uJ57l/4Gll3pM7bUdkf5QoCft/oR4xH8in/n1DNtLGvIPUiSzwKinl82PRm +vIPQ7ayrpd/pwuxlZuiSkH7D7lKHvr0tlMMa/ae6S0g5m3BxjVZtjn2GAwJDpqPCFg== 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=yYWh6Hfh; 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 5BA40606A32D; Fri, 4 Dec 2026 12:02:47 +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=yYWh6Hfh Received: by smtp.kernel.org (Postfix) with ESMTPSA id D16B91F000C2; Fri, 4 Dec 2026 12:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385767; bh=fEq9U50hVuxAjCXo8NRU7uc0bDlKp0hLc7LsW3CsHRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yYWh6HfhrGyE/Zisk1qXuUtibnKtJ54gKoG7GaNDosxg/37ov9MzRdTBOdyLbO2yO TXQgxD3mZuM9Oj785c2ygoZ5fUN640/ZTFQGwPEQNW4dAZklw8RUkPX9IunMXAFssd BESRBzEQqjdZ+Q3d0h8Beq5x60JYjiag/xn30RHM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vidhu Sarwal , Jonathan Cameron Subject: [PATCH 6.6 0687/1167] iio: humidity: am2315: fix negative temperature decoding Date: Fri, 4 Dec 2026 19:01:54 +0900 Message-ID: <20261204100719.961651179@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: Vidhu Sarwal commit 0a570feeca37d85fbfd6b4f6e3d9f33e1461c634 upstream. The AM2315/AM2320 report temperature as a sign-magnitude value, with bit 15 as the sign and bits 14-0 as the magnitude. am2315_read_data() stores the raw value directly in an s16, causing negative temperatures to be interpreted as two's complement. Both the read_raw and the triggered buffer paths are affected. Decode the sign bit before storing the temperature value. Positive readings are unaffected. Fixes: 366a3270c1c5 ("iio: humidity: Add support for AM2315") Signed-off-by: Vidhu Sarwal Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/humidity/am2315.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c @@ -113,6 +113,7 @@ static int am2315_read_data(struct am231 */ u8 rx_buf[8]; u16 crc; + u16 temp_raw; /* First wake up the device. */ am2315_ping(data->client); @@ -144,8 +145,15 @@ static int am2315_read_data(struct am231 sensor_data->hum_data = (rx_buf[AM2315_HUM_OFFSET] << 8) | rx_buf[AM2315_HUM_OFFSET + 1]; - sensor_data->temp_data = (rx_buf[AM2315_TEMP_OFFSET] << 8) | - rx_buf[AM2315_TEMP_OFFSET + 1]; + + /* + * Temperature is sign-magnitude, not two's complement: + * bit 15 is the sign, bits 14-0 are the magnitude (x0.1 degC). + */ + temp_raw = (rx_buf[AM2315_TEMP_OFFSET] << 8) | + rx_buf[AM2315_TEMP_OFFSET + 1]; + sensor_data->temp_data = (temp_raw & 0x8000) ? + -(temp_raw & 0x7fff) : temp_raw; return ret;