Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3334804iob; Mon, 16 May 2022 19:48:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGBArc7p8gSWjtFL8iotDqJ0OYhwhoGDoi4Bh2zAjUv7neQ7CEo9SomYrGb07HmkS8LBFk X-Received: by 2002:a17:906:60cd:b0:6fd:d95c:3e34 with SMTP id f13-20020a17090660cd00b006fdd95c3e34mr18093560ejk.250.1652755732176; Mon, 16 May 2022 19:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652755732; cv=none; d=google.com; s=arc-20160816; b=hjo/2eb9D1jF1I/68zQ0gJ7Vu6eOAyMuFUxL7R+gI4PyWWUjrrVd2qJTBxybExt4sH zGiS9WU8EKBcxAvoRjxiBH6Q+j13HHq3v94rxQdzMOm3yl95wlnsssAILfdRTbcJVs6n 47wkXUMCObydZi7FhdJ4B7z2L+Ma0KWLET26N/sz03ZLAjzfkd+xLPGkwQC/6sa9lcOw iqUVKNYRPMVAtJn1RdJTCocgCO5sLoTKE1AOgh8qsx4fxRPUrBXMVYptNzcpZxyBaQxa 5IFGNDzwnrnBhXL4/Ms3U85I78kBgnpX1oM8uN5ZmsV9tSKhuAwRF70O0CIcmPUrlQsM JGbA== 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=lyFl6LGuL0o9/hxVrllJGUrRNr48SR+jII6xbCJ1Nr4=; b=KNR9kph9bcveHEXSLbVLAjWNlsQ6PyET49K9BXYzQ0Z2+buei0LBxX6PD0037RGbci zk9kZKLjbANzjVHHCJN9Wa1lP+DxlloaZhsK9Bqhl/YZvkN4udpAPXlKDHwQvQKR1+qQ w9kOS2h2TbvVBT3R5iVmFg0DxuEM+y4weE9kKY+hg68x/Prse++SG9P81cCpqxGqfl1H 3LXjzHpezvei6kYEClfRb/f0SyYS3sLMjSYAMfao8ls0fhv7FNaPKuIzMS33nVi6wFEA WXArL0xgqdxdjmSfUcbp9MC7BrjHOos/aJM+HCQ9u7nv0y9bKxRDOj79FZ2MmUwvk6YB ccWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n0FNJkfi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv18-20020a17090760d200b006f3ad555460si1185394ejc.652.2022.05.16.19.48.26; Mon, 16 May 2022 19:48:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n0FNJkfi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345621AbiEPTjq (ORCPT + 99 others); Mon, 16 May 2022 15:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345579AbiEPTjZ (ORCPT ); Mon, 16 May 2022 15:39:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9872F3F31C; Mon, 16 May 2022 12:38:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1EEB5B81609; Mon, 16 May 2022 19:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F3C6C34115; Mon, 16 May 2022 19:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652729930; bh=X65NaARiVhWE3hBp8wrNL7JCiDF9IsgifmPUCvkdaR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0FNJkfiCqtJPkQivDwDr7jDmnx2Q3gPk/qqFSVE/MquC8V8sN0QCiH3GHjF509Lr D7bEPwQ6VkOsiOZPP7vTpRlNtaxfAe4z7lOyKwDMjHdwoSIFHIw7FfWhJ/REuh2ZSE nvzR8zGDVosOPZPhH4L3BaXNBMkFyWAb5rA0aGFQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Ji-Ze Hong (Peter Hong)" , Guenter Roeck , Sasha Levin Subject: [PATCH 4.9 09/19] hwmon: (f71882fg) Fix negative temperature Date: Mon, 16 May 2022 21:36:22 +0200 Message-Id: <20220516193613.777361444@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193613.497233635@linuxfoundation.org> References: <20220516193613.497233635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ji-Ze Hong (Peter Hong) [ Upstream commit 4aaaaf0f279836f06d3b9d0ffeec7a1e1a04ceef ] All temperature of Fintek superio hwmonitor that using 1-byte reg will use 2's complement. In show_temp() temp = data->temp[nr] * 1000; When data->temp[nr] read as 255, it indicate -1C, but this code will report 255C to userspace. It'll be ok when change to: temp = ((s8)data->temp[nr]) * 1000; Signed-off-by: Ji-Ze Hong (Peter Hong) Link: https://lore.kernel.org/r/20220418090706.6339-1-hpeter+linux_kernel@gmail.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/f71882fg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index cb28e4b4fb10..b87ca56fb774 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -1590,8 +1590,9 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, temp *= 125; if (sign) temp -= 128000; - } else - temp = data->temp[nr] * 1000; + } else { + temp = ((s8)data->temp[nr]) * 1000; + } return sprintf(buf, "%d\n", temp); } -- 2.35.1