Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3941022pxj; Mon, 21 Jun 2021 09:50:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTdwQ/tybsBBSh3a4+GQjtj65P3pyW5Hn1/TsiJXRON7kUo0nEhiIaWBik0B7vCA9G+4oJ X-Received: by 2002:aa7:c40a:: with SMTP id j10mr22550728edq.59.1624294224342; Mon, 21 Jun 2021 09:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624294224; cv=none; d=google.com; s=arc-20160816; b=dtedBcY/cbbr5Sqneflo8ZOPev5wlg50vwVVYxbm/VFSr+Wkjn1YPxegqT3dWhq3fh c9cSVybGon7UoEWIy+Tz/ksNhP1rNj5C7Mjq8SlQcMYd68c8jUWplzqjsMFEj+0ZpUTp AdJnAnvkuLpRrVmAQcDvcVnayGfIbk/GC1qsOhAPriHw3DrHb/yJMCBEsR6QnPkPck6+ NLjXs6pux3lmZLFd4AxuYA4Ufv8M+fJLPfmJvy4PJeO3rLRqmG8v+sZh4fIDaBAkjrxf U70eU7BrfIjwzlri4Vv5Q/nNV3vqPkvUVW2hy93euj7U3GGVbNVue+Nqs5ILzMqThShW 5POQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QvdpfNqU0Kl0xjdz2LCp2tEGGBjEsHrjS6o6DnXLqE8=; b=XC63KNJ9zhbF2Wnhz50BXsGZ13GajFY+uvD55oeknoSmXXqWSZWInvEk3h2c+ty116 2nynB4InixYmtg/DQVVzild08teHJfQ1v+EHfTsgzmDIBQDTandPfFl4h8RHJ3t5YaUj 0CX4iwFxKLIFmLDxjxSqupKnC9iQHPxAtquYa5Cq4DsPspIlBSmLVFQ0bSMhKP5T8OOg CRx9k+1Ik4GZoZeiJAIlCzyMh4rDRPaSnCTaqD1NJfQg0HlCFXndxiahJKK8Zd3x/7VC aYjkw7XvDhd7alQILoA3tRp9gtd6xApoPOD2VvEEwuUFIptQHW6MJdbYYIgXLNnaE5xq hbDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="w9qudB/u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si3694563edq.273.2021.06.21.09.50.01; Mon, 21 Jun 2021 09:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="w9qudB/u"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232933AbhFUQsx (ORCPT + 99 others); Mon, 21 Jun 2021 12:48:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbhFUQn7 (ORCPT ); Mon, 21 Jun 2021 12:43:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D8EC6144C; Mon, 21 Jun 2021 16:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293124; bh=4N5XB1kMClR4uHWK6xi+bP3P4je3OwE/wcElNSnGzR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w9qudB/uVOTbKd0/9te9UP8FOfk2CjNaTP+ZD/v7eiKpm8k2GXuxmD8clellngQjE GkZ0NtjvdT/gNSQ7udkqFkXBKDjWRhXoJHQr95TzodARLQ9zXx7mrde6XM6ZWlubQi /z/iJY+0DRVPdcXSU6lGhoGE0G6+SSQaPmolmQd4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riwen Lu , Xin Chen , Guenter Roeck , Sasha Levin Subject: [PATCH 5.12 108/178] hwmon: (scpi-hwmon) shows the negative temperature properly Date: Mon, 21 Jun 2021 18:15:22 +0200 Message-Id: <20210621154926.448196186@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riwen Lu [ Upstream commit 78d13552346289bad4a9bf8eabb5eec5e5a321a5 ] The scpi hwmon shows the sub-zero temperature in an unsigned integer, which would confuse the users when the machine works in low temperature environment. This shows the sub-zero temperature in an signed value and users can get it properly from sensors. Signed-off-by: Riwen Lu Tested-by: Xin Chen Link: https://lore.kernel.org/r/20210604030959.736379-1-luriwen@kylinos.cn Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/scpi-hwmon.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c index 25aac40f2764..919877970ae3 100644 --- a/drivers/hwmon/scpi-hwmon.c +++ b/drivers/hwmon/scpi-hwmon.c @@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) scpi_scale_reading(&value, sensor); + /* + * Temperature sensor values are treated as signed values based on + * observation even though that is not explicitly specified, and + * because an unsigned u64 temperature does not really make practical + * sense especially when the temperature is below zero degrees Celsius. + */ + if (sensor->info.class == TEMPERATURE) + return sprintf(buf, "%lld\n", (s64)value); + return sprintf(buf, "%llu\n", value); } -- 2.30.2