Re: [PATCH v4 2/2] iio: temperature: add driver support for ti tmp117
From: Andy Shevchenko <hidden>
Date: 2021-04-11 18:07:46
Also in:
linux-iio, lkml
From: Andy Shevchenko <hidden>
Date: 2021-04-11 18:07:46
Also in:
linux-iio, lkml
On Sun, Apr 11, 2021 at 5:53 PM Jonathan Cameron [off-list ref] wrote:
On Wed, 7 Apr 2021 23:51:47 +0530 Puranjay Mohan [off-list ref] wrote:quoted
TMP117 is a Digital temperature sensor with integrated Non-Volatile memory. Add support for tmp117 driver in iio subsystem.
...
quoted
+ off = clamp(val, S16_MIN, S16_MAX);With a C=1 W=1 build (sparse an lots of warnings) this causes problems because the S16_MIN and S16_MAX are as you might imagine s16 values whereas val is an int. I've added casts to force S16_MIN and S16_MAX to ints as well.
Good point, but better is to use clamp_t(s16, ...) rather than explicit casting. I always consider explicit casting in C (and esp. in Linux kernel) is a red flag. Should be really rarely needed.
quoted
+ if (off == data->calibbias) + return 0;
-- With Best Regards, Andy Shevchenko