Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Murad Masimov <m.masimov@maxima.ru>
Cc: Eric Tremblay <etremblay@distech-controls.com>,
	Jean Delvare <jdelvare@suse.com>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH 2/3] hwmon: (tmp513) Fix Current Register value interpretation
Date: Mon, 16 Dec 2024 15:55:29 -0800	[thread overview]
Message-ID: <b2168d93-12c1-443b-bb5c-bfe6df71fd8f@roeck-us.net> (raw)
In-Reply-To: <20241216173648.526-3-m.masimov@maxima.ru>

On Mon, Dec 16, 2024 at 08:36:47PM +0300, Murad Masimov wrote:
> The value returned by the driver after processing the contents of the Current
> Register does not correspond to the TMP512/TMP513 specifications. A raw
> register value is converted to a signed integer value by a sign extension in
> accordance with the algorithm provided in the specification, but due to the
> off-by-one error in the sign bit index, the result is incorrect. Moreover,
> negative values will be reported as large positive due to missing sign
> extension from u32 to long.
> 
> According to the TMP512 and TMP513 datasheets, the Current Register (07h) is a
> 16-bit two's complement integer value. E.g., if regval = 1000 0011 0000 0000,
> then the value must be (-32000 * lsb), but the driver will return (33536 * lsb).
> 
> Fix off-by-one bug, and also cast data->curr_lsb_ua (which is of type u32) to
> long to prevent incorrect cast for negative values.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 59dfa75e5d82 ("hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.")
> Signed-off-by: Murad Masimov <m.masimov@maxima.ru>

Applied, after fixing checkpatch complaints.

Guenter

  reply	other threads:[~2024-12-16 23:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16 17:36 [PATCH 0/3] hwmon: (tmp513) Fix interpretation of values of TMP513 registers Murad Masimov
2024-12-16 17:36 ` [PATCH 1/3] hwmon: (tmp513) Fix interpretation of values of Shunt Voltage and Limit Registers Murad Masimov
2024-12-16 23:53   ` Guenter Roeck
2024-12-16 17:36 ` [PATCH 2/3] hwmon: (tmp513) Fix Current Register value interpretation Murad Masimov
2024-12-16 23:55   ` Guenter Roeck [this message]
2024-12-16 17:36 ` [PATCH 3/3] hwmon: (tmp513) Fix interpretation of values of Temperature Result and Limit Registers Murad Masimov

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=b2168d93-12c1-443b-bb5c-bfe6df71fd8f@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=etremblay@distech-controls.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=m.masimov@maxima.ru \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox