Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1400536pxj; Fri, 21 May 2021 13:19:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybaGq+WmNvWqYVbZHHvk++NBNYVIAT+wbQeCjc67c/ZCOofxzgUw7FTvTDxrghN9tRDMnu X-Received: by 2002:a05:6402:845:: with SMTP id b5mr12633042edz.9.1621628398625; Fri, 21 May 2021 13:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628398; cv=none; d=google.com; s=arc-20160816; b=qnkovGHxxKs3eQCoBcnQ8sZgEV8Nqr5NbgKskimcfkG8DpQ96SjhS3ZnobTVIpsqkk zRfQfYWiX9757V8N1H6K8MZOcetIE9pSK0zdeN2xJWsIYHQDUcRXkG1PUkdnDUtb9oIQ Xy3Yt4lKvLFSd7s879Cr6YWdqPZRAL0LwWm3MJgFyzpO5cYw3KcOrkjAMjw4oNWkqNf/ xnrd6Ba5ivLoc7mAOFz7V2EglBr5VXWJ/yy38KNN27WemVSOPAkimfqZNE8P+8WXmzUj SipOur+ozaUH7/tC8Ky2ji1A6GQ8nCDhuM6n4e/d7msi2Bm31HKzn1uO736qBdKJmgyl j2HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:sender:dkim-signature; bh=G+WxE/QQt2V+YAcRvnHfLdrfp3Eo0XxASxmLklJ1y4Y=; b=zz11j4tjt65P87q6lU9rX7LJTOZnrz8FL70ccXbZJ3xBEc9P9ju1YKVluq0E8PiCZx CuAg0ivamjlfkYLTKwUvNxHwTTF08T7OkZnMGs75kd6UG5nQDy0r9s/yK//z+BvzkUFh ucUY+G0UYX/SBhq7+fGnLPhjVq1ozB5QdQqluhj7aHlVkk7xf01A12Zyo+eFPyEDcUdk kurVY9r5JS/MHKik56nwBB1qOkJ7LFFiAqIG9pdNc27liXRWK6t8NbDXqR5hfENLE9yD WiPqxeBi8pBSqykZsoWWFh04j+qX7gsL2ckv45V4UF5h+XQpFJBQIhjLuSSOfPKVqSj4 MlTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lhosTF+p; 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 c13si4796211ede.455.2021.05.21.13.19.35; Fri, 21 May 2021 13:19:58 -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=@gmail.com header.s=20161025 header.b=lhosTF+p; 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 S233969AbhEUOq2 (ORCPT + 99 others); Fri, 21 May 2021 10:46:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236890AbhEUOpM (ORCPT ); Fri, 21 May 2021 10:45:12 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A878C06138A; Fri, 21 May 2021 07:43:44 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id r26-20020a056830121ab02902a5ff1c9b81so18209981otp.11; Fri, 21 May 2021 07:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=G+WxE/QQt2V+YAcRvnHfLdrfp3Eo0XxASxmLklJ1y4Y=; b=lhosTF+pBzuhNLcZGPfkWm14Lb22NgCSw1xtrKf1fYqhfJ1t28z29FgfJsi6rL6+Fc 79ZtUa2msCRpRstvUQrDoXaK0ThqUJqERNCQJaSzMUiwVoUPL2pV4Df/agvDbXj2cKSI Cmo6Q+eHiXuksWTxa1cRK9EOGvfa+zGIQPivxNplsCSsokYG8XTuoveEKsgt8XoHyE+k Cn7TZ+UeFuz4ouUjhBs9Fog75ccyojF2lHYycJXZq/rsFfvzd97VuNaEyL6NCPpzkNvq pi1MWoAobQrfTAG3mXYGO4iqwrJKyWvhCThvV8uRMKbN6LgTMCO6XnAixEBBArBLqK9X THhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:cc:references:from:subject:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=G+WxE/QQt2V+YAcRvnHfLdrfp3Eo0XxASxmLklJ1y4Y=; b=Vd9OxDYgGXBdn5YJc0aUjYyPow1791g/bLx2joQL+4vPn6lvq+IBVi9nU3ZLclCITF x/eUvB6RVMFeBjePus1Gu9BiGqrFxAk8p1lgBMu/TQVz+GLgRUJCs1zc8BkmGigDush0 Jo/x61ZQo8P7Hkk/LYSP0MJUvKsLsq8K8HnhxUiBs1ed2uXUUJ0JxWzLOXkYaqWYP2XD AkqZfvTSP5dIKomfxDeCvOiyLWXpBbS5F03AU6ABWcVbdHI/iluu/IYl+6Ic4LVg6/9J mmTKlTpGxlr54qdlxvUFALLG+cSdfmOu+EEbrhfZzu3LjQuyGsaElAhE7WSLmEPt3Qfw mRAg== X-Gm-Message-State: AOAM531EZth/QFwQHybFxkedBSXNWNVcgE9TfIKqs0dIsBwyipQ1Rh0/ rSBu8Jim+4N1kOc4pzkyZ6XcaZWIjeo= X-Received: by 2002:a05:6830:1ac7:: with SMTP id r7mr8535189otc.167.1621608223879; Fri, 21 May 2021 07:43:43 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b18sm1340566otk.62.2021.05.21.07.43.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 May 2021 07:43:43 -0700 (PDT) Sender: Guenter Roeck To: Riwen Lu , jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Xin Chen References: <20210521124204.22263-1-luriwen@kylinos.cn> From: Guenter Roeck Subject: Re: [PATCH v1] hwmon: (scpi-hwmon) shows the negative temperature properly Message-ID: <3e6f68d1-c8f6-8521-833f-a4652ef8236a@roeck-us.net> Date: Fri, 21 May 2021 07:43:41 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210521124204.22263-1-luriwen@kylinos.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/21/21 5:42 AM, Riwen Lu wrote: > 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 What did you test ? Did you really manage to run the system in such an environment ? > --- > drivers/hwmon/scpi-hwmon.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c > index 25aac40f2764..583a600bc82d 100644 > --- a/drivers/hwmon/scpi-hwmon.c > +++ b/drivers/hwmon/scpi-hwmon.c > @@ -99,7 +99,7 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) > > scpi_scale_reading(&value, sensor); > > - return sprintf(buf, "%llu\n", value); > + return sprintf(buf, "%lld\n", value); 'value' is declared as u64, not as s64. I can not evaluate what the firmware actually reports. The API reports an u64. Do you have any evidence for your claim that it returns a signed value under any circumstances ? On top of that, your change affects not only temperature values, but all attributes. It is highly unlikely that the firmware would report negative power or energy values. It is, however, possible that energy values have the upper bit of an u64 set after a long runtime. Your change would result in a negative energy value if that is ever the case. Guenter