From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 2/6] hwmon: (lm95234) Use find_closest to find matching update interval
Date: Wed, 17 Jul 2024 20:39:31 -0700 [thread overview]
Message-ID: <20240718033935.205185-3-linux@roeck-us.net> (raw)
In-Reply-To: <20240718033935.205185-1-linux@roeck-us.net>
Use find_closest() instead of manually coding it to find best update
interval.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/lm95234.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/lm95234.c b/drivers/hwmon/lm95234.c
index 0c509eed6a01..a36fa7824da8 100644
--- a/drivers/hwmon/lm95234.c
+++ b/drivers/hwmon/lm95234.c
@@ -18,6 +18,7 @@
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
+#include <linux/util_macros.h>
#define DRVNAME "lm95234"
@@ -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));
mutex_lock(&data->update_lock);
data->interval = msecs_to_jiffies(update_intervals[regval]);
--
2.39.2
next prev parent reply other threads:[~2024-07-18 3:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 3:39 [PATCH 0/6] hwmon: (lm9534) Various improvements Guenter Roeck
2024-07-18 3:39 ` [PATCH 1/6] hwmon: (lm95234) Reorder include files to be in alphabetic order Guenter Roeck
2024-07-18 16:39 ` Tzung-Bi Shih
2024-07-18 3:39 ` Guenter Roeck [this message]
2024-07-18 16:39 ` [PATCH 2/6] hwmon: (lm95234) Use find_closest to find matching update interval Tzung-Bi Shih
2024-07-18 17:48 ` Guenter Roeck
2024-07-18 17:53 ` Guenter Roeck
2024-07-19 0:52 ` Tzung-Bi Shih
2024-07-18 3:39 ` [PATCH 3/6] hwmon: (lm95234) Convert to use regmap Guenter Roeck
2024-07-18 16:40 ` Tzung-Bi Shih
2024-07-18 3:39 ` [PATCH 4/6] hwmon: (lm95234) Convert to with_info hwmon API Guenter Roeck
2024-07-18 16:40 ` Tzung-Bi Shih
2024-07-18 17:47 ` Guenter Roeck
2024-07-19 0:52 ` Tzung-Bi Shih
2024-07-19 1:55 ` Guenter Roeck
2024-07-18 3:39 ` [PATCH 5/6] hwmon: (lm95234) Add support for tempX_enable attribute Guenter Roeck
2024-07-18 16:40 ` Tzung-Bi Shih
2024-07-18 3:39 ` [PATCH 6/6] hwmon: (lm95234) Use multi-byte regmap operations Guenter Roeck
2024-07-18 16:40 ` Tzung-Bi Shih
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=20240718033935.205185-3-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=linux-hwmon@vger.kernel.org \
/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