Re: [PATCH 2/6] hwmon: (lm95234) Use find_closest to find matching update interval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/18/24 10:48, Guenter Roeck wrote:
On 7/18/24 09:39, Tzung-Bi Shih wrote:
On Wed, Jul 17, 2024 at 08:39:31PM -0700, Guenter Roeck wrote:
@@ -471,10 +472,7 @@ static ssize_t update_interval_store(struct device *dev,
      if (ret < 0)
          return ret;
-    for (regval = 0; regval < 3; regval++) {
-        if (val <= update_intervals[regval])
-            break;
-    }
+    regval = find_closest(val, update_intervals, ARRAY_SIZE(update_intervals));

The behavior changed.

static u16 update_intervals[] = { 143, 364, 1000, 2500 };

If val = 144,
* Originally, regval = 1.
* After applying the patch, regval = 0.



Yes, find_closest() rounds the value instead of using the lower match.
That was intentional. I'll add an explicit note to the commit message.


I added this to the commit message:

    Since find_closest() uses rounding to find the best match, the resulting
    update interval will now reflect the update interval that is closest to
    the requested value, not the value that is lower or equal to the requested
    value.

Thanks,
Guenter





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux