Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3456779iob; Mon, 16 May 2022 23:49:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztj4ANDJ9O2NAI44tJSRZDEz4UB+5M2omSz8yHVrVHaRb14LVzvEGfGvBGotD72LBKK4wJ X-Received: by 2002:aa7:cacb:0:b0:428:b435:dc43 with SMTP id l11-20020aa7cacb000000b00428b435dc43mr17009558edt.123.1652770177029; Mon, 16 May 2022 23:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652770177; cv=none; d=google.com; s=arc-20160816; b=AxHEjfs1fd4LRCfpRwi6hUDuLSWaqxjl5ULs/mLUKDgO8TDIa25C+4YSIHxwjz9ooN SENr6fhbwm0gOGpLh0CJvYaxpbr4W7vQZWIJJj8JoloiZ8Ji6UNs6J6/cJb0Db4auJLb jX1RHjhTmo+UnH4m6BuAybf5lL5vcMpEDXFNbAUGMIN0IU71WAzNH1Z1B1pZufAcDqJY /EHF0S3dX2g91aEmBWNHIXmLFk2w9BD2b3ceNQTvEmIFI826zGFisOpTvRWEOYGmVFSn tuFUIZcLylMl5LC8ixpeLNCE2ipruTWmRxW2Ka1/ge4oiO0tdqoFFs4HI+T/TyrurZm6 nJxQ== 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=ww7Xl5F4PHzDv26uporHTaohqWHUSMoAIOtAhfiPI0k=; b=AwOvGQro8aYHc2mFGONahhrqaeQV2CaPddWG2XMtob/Pf6c8Pnm5HSUMpy5HrkehGh 7jhALlBtXzfZAfSKx8AIwb6RkyEAXltgrPYACqnXeaXG8TQsE3oZ4Qsp4axSiJWRAUTt OkgOv7UwN9oMjBzJwzwETCqiUOd6yuTQdEswkHjGE3KMBdh7y0fjQGt1Gte5gZSN0ofg hCGzPX8Ubg0tgMH8Hk7JgZnqenNTTBQUzzq+Eold7C1CEbGhnDo+BCLmVk6/X1MAheku WC3wmp6f8tuabCXzKYmvrqR7qhnbyB3OOEFn7v1f8Lwj3hFUDwfLu/XhOXql/OQSsBHR mMGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w34ivAEy; 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 m6-20020a056402510600b00428a428c07dsi13711565edd.378.2022.05.16.23.49.12; Mon, 16 May 2022 23:49:37 -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=w34ivAEy; 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 S239188AbiEPTrz (ORCPT + 99 others); Mon, 16 May 2022 15:47:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345889AbiEPTnU (ORCPT ); Mon, 16 May 2022 15:43:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEACA3FD99; Mon, 16 May 2022 12:42:39 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7CA43614EF; Mon, 16 May 2022 19:42:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82E29C385AA; Mon, 16 May 2022 19:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730158; bh=RRCF+KKpYB5xi8XhLVMEzUaUyXNuzwP2U2RLxqznQDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w34ivAEyAvdDDT22rG7SUTeW8NHjlRw6IxDclJkgXb0X34rqyBrzr7fADXw+xOp6k WpJ9cXLGuviZsoh5mziRCRyyoq1rt8TgAMfMammx01CIT4Yh9N4ThL08LPaEnqiLZu MoKlX44dpGVlrRItk6VjV+SfZLWAGwxVumRRU+wA= 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 5.4 18/43] hwmon: (f71882fg) Fix negative temperature Date: Mon, 16 May 2022 21:36:29 +0200 Message-Id: <20220516193615.257016160@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193614.714657361@linuxfoundation.org> References: <20220516193614.714657361@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=unavailable 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 d09deb409de7..3336ff9e306b 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c @@ -1577,8 +1577,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