mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: hdegoede@redhat.com
Cc: jdelvare@suse.com, linux@roeck-us.net,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/5] hwmon: (sch5627) Disallow write access if virtual registers are locked
Date: Thu,  7 Sep 2023 07:26:36 +0200	[thread overview]
Message-ID: <20230907052639.16491-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20230907052639.16491-1-W_Armin@gmx.de>

When the lock bit inside SCH5627_REG_CTRL is set, then the virtual
registers become read-only until the next power cycle.
Disallow write access to those registers in such a case.

Tested on a Fujitsu Esprimo P720.

Fixes: aa9f833dfc12 ("hwmon: (sch5627) Add pwmX_auto_channels_temp support")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/sch5627.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c
index 0eefb8c0aef2..bf408e35e2c3 100644
--- a/drivers/hwmon/sch5627.c
+++ b/drivers/hwmon/sch5627.c
@@ -34,6 +34,7 @@
 #define SCH5627_REG_CTRL		0x40

 #define SCH5627_CTRL_START		BIT(0)
+#define SCH5627_CTRL_LOCK		BIT(1)
 #define SCH5627_CTRL_VBAT		BIT(4)

 #define SCH5627_NO_TEMPS		8
@@ -231,6 +232,14 @@ static int reg_to_rpm(u16 reg)
 static umode_t sch5627_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr,
 				  int channel)
 {
+	const struct sch5627_data *data = drvdata;
+
+	/* Once the lock bit is set, the virtual registers become read-only
+	 * until the next power cycle.
+	 */
+	if (data->control & SCH5627_CTRL_LOCK)
+		return 0444;
+
 	if (type == hwmon_pwm && attr == hwmon_pwm_auto_channels_temp)
 		return 0644;

--
2.39.2


  parent reply	other threads:[~2023-09-07  5:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-07  5:26 [PATCH v2 0/5] hwmon: (sch5627) Make limit registers writable Armin Wolf
2023-09-07  5:26 ` [PATCH v2 1/5] hwmon: (sch5627) Use bit macros when accessing the control register Armin Wolf
2023-09-11  0:48   ` Guenter Roeck
2023-09-07  5:26 ` Armin Wolf [this message]
2023-09-11  0:49   ` [PATCH v2 2/5] hwmon: (sch5627) Disallow write access if virtual registers are locked Guenter Roeck
2023-09-07  5:26 ` [PATCH v2 3/5] hwmon: (sch5627) Use regmap for pwm map register caching Armin Wolf
2023-09-11  0:52   ` Guenter Roeck
2023-09-07  5:26 ` [PATCH v2 4/5] hwmon: (sch5627) Add support for writing limit registers Armin Wolf
2023-09-11  0:54   ` Guenter Roeck
2023-09-07  5:26 ` [PATCH v2 5/5] hwmon: (sch5627) Document behaviour of " Armin Wolf
2023-09-11  0:54   ` 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=20230907052639.16491-3-W_Armin@gmx.de \
    --to=w_armin@gmx.de \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --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

all inboxes | Powered by JetHome®