devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Matyas <daniel.matyas@analog.com>
Cc: Daniel Matyas <daniel.matyas@analog.com>,
	Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>, <linux-hwmon@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-doc@vger.kernel.org>
Subject: [PATCH v4 6/7] hwmon: max31827: Update bits with shutdown_write()
Date: Tue, 19 Sep 2023 12:34:54 +0300	[thread overview]
Message-ID: <20230919093456.10592-6-daniel.matyas@analog.com> (raw)
In-Reply-To: <20230919093456.10592-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: 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 d4127440ee32..957d898978fb 100644
--- a/drivers/hwmon/max31827.c
+++ b/drivers/hwmon/max31827.c
@@ -94,7 +94,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;
@@ -111,7 +111,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;
 	}
 
@@ -126,7 +129,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;
 
@@ -144,7 +151,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


  parent reply	other threads:[~2023-09-19  9:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19  9:34 [PATCH v4 1/7] hwmon: max31827: Make code cleaner Daniel Matyas
2023-09-19  9:34 ` [PATCH v4 2/7] hwmon: max31827: Modify conversion wait time Daniel Matyas
2023-10-25 21:44   ` Guenter Roeck
2023-09-19  9:34 ` [PATCH v4 3/7] dt-bindings: hwmon: Add possible new properties to max31827 bindings Daniel Matyas
2023-09-19 11:00   ` Conor Dooley
2023-10-25 21:44   ` Guenter Roeck
2023-09-19  9:34 ` [PATCH v4 4/7] hwmon: max31827: Handle new properties from the devicetree Daniel Matyas
2023-10-25 22:01   ` Guenter Roeck
2023-10-26  0:45   ` Guenter Roeck
2023-09-19  9:34 ` [PATCH v4 5/7] hwmon: max31827: Add support for max31828 and max31829 Daniel Matyas
2023-09-19  9:34 ` Daniel Matyas [this message]
2023-09-19  9:34 ` [PATCH v4 7/7] hwmon: max31827: Add custom attribute for resolution Daniel Matyas
2023-10-25 21:43 ` [PATCH v4 1/7] hwmon: max31827: Make code cleaner 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=20230919093456.10592-6-daniel.matyas@analog.com \
    --to=daniel.matyas@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh+dt@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).