Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3919034pxj; Mon, 21 Jun 2021 09:21:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzffu1FEKTHF+YZsDmmN6X6CsdyPnh2LS/AOLiGMGtv7UJg4rxNtWEHA23DhT5e8u9cWkYH X-Received: by 2002:a05:6402:1450:: with SMTP id d16mr10240490edx.274.1624292515053; Mon, 21 Jun 2021 09:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292515; cv=none; d=google.com; s=arc-20160816; b=cu6N0Jn8p1KTOXMYaRei4+cYN8PZt0XP67bxmZ2vLHS+5M6M/QC/ZRN+UMqM5eHl+Z efwgjKL5xK9glv06MlvLu1kABXz8zaX3d6t8BHbit8T/fbh7SsmBLoeoiQEYdnnRtiIU YhsvSeQ0taIHgYILu4eTHv93DCT+WSVvvWk2rGy+oAmtj27srDEXSxNPkO83cCTCFSu4 yXb20P3a51YonGWZdVOfb+rsEJrFRuxjnPSroWqqkGY+nSAWJqkImEhKK4hhAGCiPM8n fMO2ntBOf4NTuY5hlTikv9SEb8vydg+LRMQxXbXRbHUbAlpht7bZYTW5lL5mrork6DPL HtCw== 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=pVEwijRy0WdP7gAATWE0qaYo0u88g8U3DFMNT3VZmmEuK9hjIsne6xnTaKfFLq3tRs qR5wQzmT3R59eWYuopzeufa4ix0o4pTW2dtMV95qyofgLgk+aK78QSsRsiBXHXx7QoMr B3zYNAf5f4s+On7oCQAHc4EVL63UmY6cnEMB55xw0r6KkVCpuuN3gwK0XE5Arghfkbqd 5qKstNyazo5HU5NuXfqdofrfEbf5NcImkHIolJawSDE0zYjULwM17/Qn//+AkOUKgzbH qFSY8rsTCvmpTN7fhxKU1HB171E/pbuKEGK3UmL+bjoCnDG75APugX6zKlB0gbHEz1j/ FY0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u1Q5tE8R; 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 w7si3313470edv.250.2021.06.21.09.21.32; Mon, 21 Jun 2021 09:21:55 -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=u1Q5tE8R; 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 S231260AbhFUQWC (ORCPT + 99 others); Mon, 21 Jun 2021 12:22:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41850 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhFUQUz (ORCPT ); Mon, 21 Jun 2021 12:20:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84FC361206; Mon, 21 Jun 2021 16:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292321; bh=4N5XB1kMClR4uHWK6xi+bP3P4je3OwE/wcElNSnGzR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1Q5tE8Rv+n8/pTHSpDehC04Z1PPb6Pny/b6lThHh9D9BVYAGsrcx3HLPtYmWo90+ 9NVVUnFXUI3nwP66gb9+rZ9M6MdkkvamsvA7WHxGXwdaJ+dpzk0Qr08pDLI0pGe4yX eUgRYHKNjqbKuOvmpMu7PdPWsaAfaORKmjNLCzCk= 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.4 48/90] hwmon: (scpi-hwmon) shows the negative temperature properly Date: Mon, 21 Jun 2021 18:15:23 +0200 Message-Id: <20210621154905.760406513@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@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