Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3813059pxv; Mon, 28 Jun 2021 13:34:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLAUqixmjautne5z3UGJEzOLSf9AeBkE2fx9s6qm/GpntFSS1y1K5RjQWNrYFBm86P8U2G X-Received: by 2002:a05:6e02:ee2:: with SMTP id j2mr13150339ilk.63.1624912488823; Mon, 28 Jun 2021 13:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624912488; cv=none; d=google.com; s=arc-20160816; b=vLTN/cOo7ETaS5sj35Q1R8BV8UGgdhb2G5xqsg5vYZeIv075ySgGzGT1MxGRatr0JQ +YbrfwiOH8exOFMZaR2ZllqhxByRk+Y9ULByZEyLAFOjxDrrjJYz8dekuKkx/MMe58yZ eudl9YJ2vg/mnbbib8ClkVu0d8Ouiy4wOZFJ4Wa1YWhO+2VV8rLxPe6xDd6SmagapCui 2GrrQigKFRKuzdn2xqOK35heVhPEslh0/ucWAjGmA7JtI5+FVfkttYJFXjeQAnuBVY3y sgU6xq/xsM3o6K4yYDnchRILj4Pl5xvtFuFt1JTojDQ7rL/rIs3t5uK8F84EvBqX0sKK 87zg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=avzwShpZAAZKOXxElGYTtzLvc/2bsDDXf/cRq91JooE=; b=yml47S8hFtSCZsA3bSDnHs0z8Rlk+HcdUE5l3BQYJuoES5sewRDBADkrMZ5txp669z +GQ4qV63vtX6NvXr4xSfj2BdaXd9VylGjXQSMNj7iUooMIyHL7do8CM+VR7Vjs2S9wT4 E/wgPlkHMz1jtlPwd7Yl4KLcwhJWwjWyW+l7nxrngOMlfBO4Q+KN0XyEvVDWGWS0R3W+ ZVwSTPV6KxO0BcQ3VkiejOSFp17rjC+w2jcnuW/VWDJJMJNcIw+a9o/n8du+Zxz+B7bO ELG2XCA8D/g4Sn3Ylh7DeZdACHkW2YOGeljBs5oTSTOqaaIWboAYASHtUqIhwKloMEgz ABRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XooFiWyO; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si19800660jal.25.2021.06.28.13.34.33; Mon, 28 Jun 2021 13:34:48 -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=@kernel.org header.s=k20201202 header.b=XooFiWyO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235781AbhF1PLi (ORCPT + 99 others); Mon, 28 Jun 2021 11:11:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235553AbhF1OvC (ORCPT ); Mon, 28 Jun 2021 10:51:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F6AE61D2D; Mon, 28 Jun 2021 14:37:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891027; bh=wRJuFAUKBN9IqlvNRNlL4iFilXRpZrVKLPOlZFTk0FE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XooFiWyOawnpIA9OuWFcZ29PCbLJBSOVn/JqHt7agriORWy3s5JzNOsbhNea8Wney Bqg3HIZg2FYajovckIXKGHX2kXRKf9pVF0qC4Tr6yrapMQDgCy6ApHVDa9UWiVZH0F 5iGI4LTHjjSBScrVXkyMho4AV6jjelsX6+Jsoo4MxlTDX0xWVJhgqqLeCqPIKbPTOe 1YOd1BLnGYUosVhC63G6r36xf7Yv4TWlBoEMHD5+bmAfXiYIK1drh45eCJeh6b1z8t iIL258Ky+sGg7M2yymnFyJ77NLc704Np/Nr3eR5FvkM0pZpk6yMYc5dNk8L8SMSQNq 6Y4xu0r9rK/kw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Riwen Lu , Xin Chen , Guenter Roeck , Sasha Levin Subject: [PATCH 4.14 42/88] hwmon: (scpi-hwmon) shows the negative temperature properly Date: Mon, 28 Jun 2021 10:35:42 -0400 Message-Id: <20210628143628.33342-43-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+00:00 X-stable: review X-Patchwork-Hint: Ignore 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 7e49da50bc69..562f3e287297 100644 --- a/drivers/hwmon/scpi-hwmon.c +++ b/drivers/hwmon/scpi-hwmon.c @@ -107,6 +107,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