From: Daniel Matyas <daniel.matyas@analog.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Daniel Matyas <daniel.matyas@analog.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>, <linux-hwmon@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v6 3/5] hwmon: max31827: Update bits with shutdown_write()
Date: Tue, 31 Oct 2023 20:21:55 +0200 [thread overview]
Message-ID: <20231031182158.124608-3-daniel.matyas@analog.com> (raw)
In-Reply-To: <20231031182158.124608-1-daniel.matyas@analog.com>
Added 'mask' parameter to the shutdown_write() function. Now it can
either write or update bits, depending on the value of mask. This is
needed, because for alarms a write is necessary, but for resolution only
the resolution bits should be updated.
Signed-off-by: Daniel Matyas <daniel.matyas@analog.com>
---
v4 -> v6: No change.
v4: Added patch.
drivers/hwmon/max31827.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c
index 738ce5ca6e39..41e4f716605a 100644
--- a/drivers/hwmon/max31827.c
+++ b/drivers/hwmon/max31827.c
@@ -80,7 +80,7 @@ static const struct regmap_config max31827_regmap = {
};
static int shutdown_write(struct max31827_state *st, unsigned int reg,
- unsigned int val)
+ unsigned int mask, unsigned int val)
{
unsigned int cfg;
unsigned int cnv_rate;
@@ -97,7 +97,10 @@ static int shutdown_write(struct max31827_state *st, unsigned int reg,
mutex_lock(&st->lock);
if (!st->enable) {
- ret = regmap_write(st->regmap, reg, val);
+ if (!mask)
+ ret = regmap_write(st->regmap, reg, val);
+ else
+ ret = regmap_update_bits(st->regmap, reg, mask, val);
goto unlock;
}
@@ -112,7 +115,11 @@ static int shutdown_write(struct max31827_state *st, unsigned int reg,
if (ret)
goto unlock;
- ret = regmap_write(st->regmap, reg, val);
+ if (!mask)
+ ret = regmap_write(st->regmap, reg, val);
+ else
+ ret = regmap_update_bits(st->regmap, reg, mask, val);
+
if (ret)
goto unlock;
@@ -130,7 +137,7 @@ static int write_alarm_val(struct max31827_state *st, unsigned int reg,
{
val = MAX31827_M_DGR_TO_16_BIT(val);
- return shutdown_write(st, reg, val);
+ return shutdown_write(st, reg, 0, val);
}
static umode_t max31827_is_visible(const void *state,
--
2.34.1
next prev parent reply other threads:[~2023-10-31 22:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-31 18:21 [PATCH v6 1/5] hwmon: max31827: Handle new properties from the devicetree Daniel Matyas
2023-10-31 18:21 ` [PATCH v6 2/5] hwmon: max31827: Add support for max31828 and max31829 Daniel Matyas
2023-10-31 18:21 ` Daniel Matyas [this message]
2023-10-31 18:21 ` [PATCH v6 4/5] hwmon: max31827: Return closest value in update_interval Daniel Matyas
2023-10-31 18:21 ` [PATCH v6 5/5] hwmon: max31827: Add custom attribute for resolution Daniel Matyas
2023-12-11 14:15 ` 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=20231031182158.124608-3-daniel.matyas@analog.com \
--to=daniel.matyas@analog.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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