From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Iker Perez del Palomar <iker.perez@codethink.co.uk>,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 2/4] hwmon: (lm75) Move updating the sample interval to its own function
Date: Tue, 3 Sep 2019 07:03:07 -0700 [thread overview]
Message-ID: <1567519389-16561-2-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1567519389-16561-1-git-send-email-linux@roeck-us.net>
We'll need per-chip handling for updating the sample interval.
To prepare for it, separate the code implementing it into its own
function.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/lm75.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 6474b8f21981..644da2620a26 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -388,27 +388,32 @@ static int lm75_write_temp(struct device *dev, u32 attr, long temp)
return regmap_write(data->regmap, reg, (u16)temp);
}
-static int lm75_write_chip(struct device *dev, u32 attr, long val)
+static int lm75_update_interval(struct device *dev, long val)
{
struct lm75_data *data = dev_get_drvdata(dev);
u8 index;
s32 err;
- switch (attr) {
- case hwmon_chip_update_interval:
- index = find_closest(val, data->params->sample_times,
- (int)data->params->num_sample_times);
+ index = find_closest(val, data->params->sample_times,
+ (int)data->params->num_sample_times);
- err = lm75_write_config(data,
- lm75_sample_set_masks[index],
- LM75_SAMPLE_CLEAR_MASK);
- if (err)
- return err;
- data->sample_time = data->params->sample_times[index];
+ err = lm75_write_config(data, lm75_sample_set_masks[index],
+ LM75_SAMPLE_CLEAR_MASK);
+ if (err)
+ return err;
- if (data->params->resolutions)
- data->resolution = data->params->resolutions[index];
- break;
+ data->sample_time = data->params->sample_times[index];
+ if (data->params->resolutions)
+ data->resolution = data->params->resolutions[index];
+
+ return 0;
+}
+
+static int lm75_write_chip(struct device *dev, u32 attr, long val)
+{
+ switch (attr) {
+ case hwmon_chip_update_interval:
+ return lm75_update_interval(dev, val);
default:
return -EINVAL;
}
--
2.7.4
next prev parent reply other threads:[~2019-09-03 14:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-03 14:03 [PATCH 1/4] hwmon: (lm75) Support configuring the sample time for various chips Guenter Roeck
2019-09-03 14:03 ` Guenter Roeck [this message]
2019-09-03 14:03 ` [PATCH 3/4] hwmon: (lm75) Add support for writing conversion time for TMP112 Guenter Roeck
2019-09-03 14:03 ` [PATCH 4/4] hwmon: (lm75) Add support for writing sampling period on PCT2075 Guenter Roeck
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=1567519389-16561-2-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=iker.perez@codethink.co.uk \
--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;
as well as URLs for NNTP newsgroup(s).