Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp97734pxj; Thu, 3 Jun 2021 01:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgc3QaWvhpoQmRujXi+6gi7xt5NYCqCTZBrMUk54fMpwko6wp8xmFmRwtMc8knNTnXaa2L X-Received: by 2002:a17:907:9e1:: with SMTP id ce1mr25064399ejc.104.1622709670460; Thu, 03 Jun 2021 01:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622709670; cv=none; d=google.com; s=arc-20160816; b=o6QCSo4n60yTOmM1JxhE+WdZziTyOMNysFrW48gu075BmJszbU2hil5F7OElVmMUnT OWc3O6r+H50LfnaWObLRTyIUQ9RRez9ysrBFkcjV98mbKneLGjzg1XQZHNwg4B0CElec voM1J+CzITOVxqryCv28FdvtcOfm2yqTnui+Jk2HsZynNDw6s9nXTasNL7YNHX2eLrw8 7obb3BOsfYtaUqH+1877ptKvBV6Z4XDfWFMQMMZnbU2NO6kY3XziOWZ0qGCHGYfyEwlR /wpbT7S2BMLh9GksCyEfvNwblKLfyfcAgaSjcrnshV/bKnzfE4kEs0qzzpu9vt2cMnn3 6r2Q== 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 :message-id:date:subject:cc:to:from; bh=IZ2qcmvyOe5jbt1cD9WKAuNsVaVUADfefLClBFZg6bI=; b=zM1VuNsXquL9+rq1hZHOVK8B+9gK6O1GxsSzkZ6c2wUyu05AQPCVEd9ZIMfuxsc1DH HSrX+kFadZGYJ2o6r/QsIABqaKC2Dl7yUfZT0dnfXtk6MiVcqVJO9YQeopkcq53pZivz AWgfZiKUUgXgXyxDKS/rFGYKQBfhukN/T5G6THNwDEEYNbE82iYHzbhd9qsLmHRLDoW1 hM9AByEfGMjMWu1xFlzMDzL4/O4zjqKpD16g9eXZ0XfQdv1rp9JZyeP32BiQmfOf99vO BZw36TRQTp8E3X8DwaOwhN+A7j1pT9lyM6wmYCLZC3oXWTWI9K0ejI57p1XeCJu2xE2M IQ5g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m22si821947ejn.250.2021.06.03.01.40.47; Thu, 03 Jun 2021 01:41:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbhFCIkm (ORCPT + 99 others); Thu, 3 Jun 2021 04:40:42 -0400 Received: from mailgw.kylinos.cn ([123.150.8.42]:45531 "EHLO nksmu.kylinos.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229611AbhFCIkm (ORCPT ); Thu, 3 Jun 2021 04:40:42 -0400 X-UUID: 0c957269bb9e4c01b82befbc6c67934a-20210603 X-UUID: 0c957269bb9e4c01b82befbc6c67934a-20210603 X-User: luriwen@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by nksmu.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 133540621; Thu, 03 Jun 2021 16:38:38 +0800 From: Riwen Lu To: jdelvare@suse.com, linux@roeck-us.net Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Riwen Lu , Xin Chen Subject: [PATCH v2] hwmon: (scpi-hwmon) shows the negative temperature properly Date: Thu, 3 Jun 2021 16:38:45 +0800 Message-Id: <20210603083845.569751-1-luriwen@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes since v1: - Add judgment for sensor->info.class. If it is TEMPERATURE situation, return the sensor value as a signed value, otherwise return it as a unsigned value. --- drivers/hwmon/scpi-hwmon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c index 25aac40f2764..45a7e319143d 100644 --- a/drivers/hwmon/scpi-hwmon.c +++ b/drivers/hwmon/scpi-hwmon.c @@ -99,7 +99,10 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) scpi_scale_reading(&value, sensor); - return sprintf(buf, "%llu\n", value); + if (sensor->info.class == TEMPERATURE) + return sprintf(buf, "%lld\n", value); + else + return sprintf(buf, "%llu\n", value); } static ssize_t -- 2.25.1 No virus found Checked by Hillstone Network AntiVirus