[PATCH 2/6] iio: adc: versal-sysmon: validate temperature hysteresis
Mahapatra, Amit Kumar
amit.kumar-mahapatra at amd.com
Sun Nov 15 20:19:46 PST 2026
AMD General
Hello Andy,
> -----Original Message-----
> From: Andy Shevchenko <andriy.shevchenko at intel.com>
> Sent: Tuesday, November 10, 2026 1:16 AM
> To: Mahapatra, Amit Kumar <amit.kumar-mahapatra at amd.com>
> Cc: Jonathan Cameron <jic23 at kernel.org>; Simek, Michal
> <michal.simek at amd.com>; Potthuri, Sai Krishna <sai.krishna.potthuri at amd.com>;
> David Lechner <dlechner at baylibre.com>; Nuno Sá <nuno.sa at analog.com>; Andy
> Shevchenko <andy at kernel.org>; Rob Herring <robh at kernel.org>; Krzysztof
> Kozlowski <krzk+dt at kernel.org>; Conor Dooley <conor+dt at kernel.org>; linux-
> iio at vger.kernel.org; devicetree at vger.kernel.org; linux-arm-
> kernel at lists.infradead.org; linux-kernel at vger.kernel.org;
> amitrkcian2002 at gmail.com
> Subject: Re: [PATCH 2/6] iio: adc: versal-sysmon: validate temperature hysteresis
>
> On Fri, Nov 06, 2026 at 11:35:00AM +0000, Mahapatra, Amit Kumar wrote:
> > > -----Original Message-----
> > > From: Andy Shevchenko <andriy.shevchenko at intel.com>
> > > Sent: Tuesday, November 3, 2026 3:39 PM On Mon, Nov 02, 2026 at
> > > 05:51:08PM +0530, Amit Kumar Mahapatra wrote:
>
> ...
>
> > > > sysmon_q8p7_to_millicelsius(upper_reg, &upper_mc);
> > > > sysmon_q8p7_to_millicelsius(lower_reg, &lower_mc);
> > > > - *hysteresis = upper_mc - lower_mc;
> > > > + *hysteresis = max(upper_mc - lower_mc, 0);
> > >
> > > But you can use abs_diff() and let it make the problem of the supplier.
> >
> > I went with max() because an inverted pair (lower above upper) doesn't
> > really describe a hysteresis, so treating it as zero seemed the safest
> > reading. With abs_diff(), an inverted 80/90 pair would be read as
> > 10 degrees, and the next threshold write would then set the lower
> > threshold to 70.
>
> Bu where did it come from? HW or DT? If the latter, we may just reject the wrong
> values at probe time, no?
It comes from the hardware, not DT. sysmon_init_hysteresis() reads the two
threshold registers. There is no DT property for them, so there's nothing to reject
when parsing DT.
Regards,
Amit
>
> --
> With Best Regards,
> Andy Shevchenko
>
More information about the linux-arm-kernel
mailing list