All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>,
	Ji-Ze Hong <hpeter+linux_kernel@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Sasha Levin <sashal@kernel.org>,
	jdelvare@suse.com, linux-hwmon@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 01/19] hwmon: (f71882fg) Fix negative temperature
Date: Tue, 10 May 2022 11:44:11 -0400	[thread overview]
Message-ID: <20220510154429.153677-1-sashal@kernel.org> (raw)

From: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>

[ 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) <hpeter+linux_kernel@gmail.com>
Link: https://lore.kernel.org/r/20220418090706.6339-1-hpeter+linux_kernel@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 4dec793fd07d..94b35723ee7a 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


             reply	other threads:[~2022-05-10 15:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 15:44 Sasha Levin [this message]
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 02/19] RDMA/irdma: Fix deadlock in irdma_cleanup_cm_core() Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 03/19] iommu: arm-smmu: disable large page mappings for Nvidia arm-smmu Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 04/19] ASoC: max98090: Reject invalid values in custom control put() Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 05/19] ASoC: max98090: Generate notifications on changes for custom control Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 06/19] ASoC: ops: Validate input values in snd_soc_put_volsw_range() Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 07/19] s390: disable -Warray-bounds Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 08/19] ASoC: SOF: Fix NULL pointer exception in sof_pci_probe callback Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 09/19] io_uring: assign non-fixed early for async work Sasha Levin
2022-05-10 15:47   ` Jens Axboe
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 10/19] net: emaclite: Don't advertise 1000BASE-T and do auto negotiation Sasha Levin
2022-05-10 15:44   ` Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 11/19] net: sfp: Add tx-fault workaround for Huawei MA5671A SFP ONT Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 12/19] secure_seq: use the 64 bits of the siphash for port offset calculation Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 13/19] tcp: use different parts of the port_offset for index and offset Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 14/19] tcp: resalt the secret every 10 seconds Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 15/19] tcp: add small random increments to the source port Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 16/19] tcp: dynamically allocate the perturb table used by source ports Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 17/19] tcp: increase source port perturb table to 2^16 Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 18/19] tcp: drop the hash_32() part from the index calculation Sasha Levin
2022-05-10 15:44 ` [PATCH AUTOSEL 5.15 19/19] Revert "parisc: Fix patch code locking and flushing" Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220510154429.153677-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hpeter+linux_kernel@gmail.com \
    --cc=hpeter@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.