Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3929063pxj; Mon, 21 Jun 2021 09:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2jqSwOyYPE8eiYPwJ1zz6+SA0mcxhXwmFtCvCPY5lr6ByIW9vR/OTp938MqN7Bv1wkZSK X-Received: by 2002:a05:6402:35c8:: with SMTP id z8mr22695315edc.348.1624293281520; Mon, 21 Jun 2021 09:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293281; cv=none; d=google.com; s=arc-20160816; b=Fs33L3p36CAe7SXQ0ui/QAXlJogLSMJlkMtpwXETnJyNFeKL2dQpIEWzZ8KoSLbz6M qJUTOczMPwGfZQcNA4gtR0WSWaggq2SEhOn1ZgXItWAIMQY01YIlL5qvOcGT+RK7GaKl DpH8ryJdZtczj5W+KptSmZS9K7FE97uDfyvzK5NY2y/g/TTBtGjnBf0K1oUbwbE2iVYB K42iSDtYhua1IATfCQiUF6lxgzUaTg+nb6DXh3UnWTgwUQTvWDt78wsxKPs7xKRvu+4h 3oO7YHkSdPRi4QMBBjza0d/OFzbkhJC/DtQ9jsW0jenzxGKx3Y4mZBsY0tQkQxZ3fWpM /GSw== 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=rcaQ/BhQByp9AL3VpXmdDWPLM19o58gB3q4yB6tf3DIKLFaj5cwSoVuQOKVuPHwJ4N rUfPu6iw9sH5OsmedefyT9YyPG7pJSiig1qZhM+X3LZOtQMFuTANL/fKeS5A9Z43IKby 4WUooLP8HtbnWiPBlLepwdTR1h57FsoBM1IfnRlU3WHFagncyYPtKNAAp3uacoxUKpWp 1k3MsjhXK+zbD9BqWPIpdAz5EPeuabpt4FKv91h7jl6X9eIJ1zaqhmcdnjU7erkuCtLi BuAaaTJZrEmv2tfWXykaCoaqS3IpqgST/DVi0G6HceQSitI8OUUda9g7wM2z2IMfinkX U6SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="p/qKNE2o"; 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 19si10632255ejx.529.2021.06.21.09.34.14; Mon, 21 Jun 2021 09:34:41 -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="p/qKNE2o"; 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 S231634AbhFUQct (ORCPT + 99 others); Mon, 21 Jun 2021 12:32:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232549AbhFUQ3n (ORCPT ); Mon, 21 Jun 2021 12:29:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 941646108E; Mon, 21 Jun 2021 16:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292684; bh=4N5XB1kMClR4uHWK6xi+bP3P4je3OwE/wcElNSnGzR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/qKNE2oWg41X9DUIpqwikGg0dLX4UQB+gQD8Hlon9TQpDTLv9DLBJO7VH2Y1+gSM UUSIycOx2KCVFaZbag/KLyxMNNPwAsU2GNMjQqtCqiUczxslSwgq0IFFOM2cPNYuRh 2oHy7abYHFGt9gRhrjiTV4sXQxykCL4P75Dtksgg= 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.10 092/146] hwmon: (scpi-hwmon) shows the negative temperature properly Date: Mon, 21 Jun 2021 18:15:22 +0200 Message-Id: <20210621154916.955420662@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@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