mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>
Cc: jic23@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
	crofts@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio: temperature: mcp9600: Bound thresholds before scaling
Date: Thu, 12 Nov 2026 18:06:11 +0200	[thread overview]
Message-ID: <avXj8xuuITKgjbd6@ashevche-desk.local> (raw)
In-Reply-To: <20261112015738.115833-1-zhujun2@cmss.chinamobile.com>

On Thu, Nov 12, 2026 at 09:57:38AM +0800, Zhu Jun wrote:
> mcp9600_write_thresh() multiplies the integer part by 1000000 before
> clamping to the supported temperature range. The multiplication can
> overflow int, so a request such as 3000 degrees can select the lower
> threshold instead of the upper threshold.
> 
> Clamp the integer part to the hot-junction range before scaling. Keep
> the existing final clamp for fractional values and the narrower cold-
> junction range.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

...

> +		val = clamp(val, MCP9600_MIN_TEMP_HOT_JUNCTION_MICRO / (int)MICRO,
> +			    MCP9600_MAX_TEMP_HOT_JUNCTION_MICRO / (int)MICRO);

In such a case I would wrap on a logical boundaries:

		val = clamp(val,
			    MCP9600_MIN_TEMP_HOT_JUNCTION_MICRO / (int)MICRO,
			    MCP9600_MAX_TEMP_HOT_JUNCTION_MICRO / (int)MICRO);

(but no need to resend, let Jonathan to decide).

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2026-11-12 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  1:57 Zhu Jun
2026-11-12 16:06 ` Andy Shevchenko [this message]

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=avXj8xuuITKgjbd6@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=crofts@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=zhujun2@cmss.chinamobile.com \
    /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

all inboxes | Powered by JetHome®