From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 17/29] hwmon: (ltc2947-core) Rely on subsystem locking
Date: Fri, 17 Oct 2025 06:02:09 -0700 [thread overview]
Message-ID: <20251017130221.1823453-18-linux@roeck-us.net> (raw)
In-Reply-To: <20251017130221.1823453-1-linux@roeck-us.net>
Attribute access is now serialized in the hardware monitoring core,
so locking in the driver code is no longer necessary. Drop it.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/hwmon/ltc2947-core.c | 32 +++++---------------------------
1 file changed, 5 insertions(+), 27 deletions(-)
diff --git a/drivers/hwmon/ltc2947-core.c b/drivers/hwmon/ltc2947-core.c
index 90f70f732b41..ad7120d1e469 100644
--- a/drivers/hwmon/ltc2947-core.c
+++ b/drivers/hwmon/ltc2947-core.c
@@ -120,12 +120,6 @@
struct ltc2947_data {
struct regmap *map;
struct device *dev;
- /*
- * The mutex is needed because the device has 2 memory pages. When
- * reading/writing the correct page needs to be set so that, the
- * complete sequence select_page->read/write needs to be protected.
- */
- struct mutex lock;
u32 lsb_energy;
bool gpio_out;
};
@@ -181,13 +175,9 @@ static int ltc2947_val_read(struct ltc2947_data *st, const u8 reg,
int ret;
u64 __val = 0;
- mutex_lock(&st->lock);
-
ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page);
- if (ret) {
- mutex_unlock(&st->lock);
+ if (ret)
return ret;
- }
dev_dbg(st->dev, "Read val, reg:%02X, p:%d sz:%zu\n", reg, page,
size);
@@ -207,8 +197,6 @@ static int ltc2947_val_read(struct ltc2947_data *st, const u8 reg,
break;
}
- mutex_unlock(&st->lock);
-
if (ret)
return ret;
@@ -242,13 +230,10 @@ static int ltc2947_val_write(struct ltc2947_data *st, const u8 reg,
{
int ret;
- mutex_lock(&st->lock);
/* set device on correct page */
ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page);
- if (ret) {
- mutex_unlock(&st->lock);
+ if (ret)
return ret;
- }
dev_dbg(st->dev, "Write val, r:%02X, p:%d, sz:%zu, val:%016llX\n",
reg, page, size, val);
@@ -265,8 +250,6 @@ static int ltc2947_val_write(struct ltc2947_data *st, const u8 reg,
break;
}
- mutex_unlock(&st->lock);
-
return ret;
}
@@ -295,11 +278,9 @@ static int ltc2947_alarm_read(struct ltc2947_data *st, const u8 reg,
memset(alarms, 0, sizeof(alarms));
- mutex_lock(&st->lock);
-
ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, LTC2947_PAGE0);
if (ret)
- goto unlock;
+ return ret;
dev_dbg(st->dev, "Read alarm, reg:%02X, mask:%02X\n", reg, mask);
/*
@@ -310,13 +291,11 @@ static int ltc2947_alarm_read(struct ltc2947_data *st, const u8 reg,
ret = regmap_bulk_read(st->map, LTC2947_REG_STATUS, alarms,
sizeof(alarms));
if (ret)
- goto unlock;
+ return ret;
/* get the alarm */
*val = !!(alarms[offset] & mask);
-unlock:
- mutex_unlock(&st->lock);
- return ret;
+ return 0;
}
static int ltc2947_read_temp(struct device *dev, const u32 attr, long *val,
@@ -1100,7 +1079,6 @@ int ltc2947_core_probe(struct regmap *map, const char *name)
st->map = map;
st->dev = dev;
dev_set_drvdata(dev, st);
- mutex_init(&st->lock);
ret = ltc2947_setup(st);
if (ret)
--
2.45.2
next prev parent reply other threads:[~2025-10-17 13:03 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 13:01 [PATCH 00/29] hwmon: Rely on subsystem locking [set 2] Guenter Roeck
2025-10-17 13:01 ` [PATCH 01/29] hwmon: (max127) Rely on subsystem locking Guenter Roeck
2025-10-17 13:01 ` [PATCH 02/29] hwmon: (lm95234) " Guenter Roeck
2025-10-17 13:01 ` [PATCH 03/29] hwmon: (lm92) " Guenter Roeck
2025-10-17 13:01 ` [PATCH 04/29] hwmon: (hs3001) " Guenter Roeck
2025-10-17 13:01 ` [PATCH 05/29] hwmon: (sbtsi_temp) " Guenter Roeck
2025-10-17 13:01 ` [PATCH 06/29] hwmon: (ina2xx) " Guenter Roeck
2025-10-17 13:01 ` [PATCH 07/29] hwmon: (sht4x) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 08/29] hwmon: (ina3221) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 09/29] hwmon: (k10temp) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 10/29] hwmon: (mr75203) Drop unnecessary include file Guenter Roeck
2025-10-17 13:02 ` [PATCH 11/29] hwmon: (powr1220) Rely on subsystem locking Guenter Roeck
2025-10-17 13:02 ` [PATCH 12/29] hwmon: (ftsteutates) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 13/29] hwmon: (ina238) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 14/29] hwmon: (lm95241) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 15/29] hwmon: (aht10) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 16/29] hwmon: (adt7411) " Guenter Roeck
2025-10-17 14:10 ` Nuno Sá
2025-10-17 13:02 ` Guenter Roeck [this message]
2025-10-17 14:11 ` [PATCH 17/29] hwmon: (ltc2947-core) " Nuno Sá
2025-10-17 13:02 ` [PATCH 18/29] hwmon: (peci) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 19/29] hwmon: (adt7x10) " Guenter Roeck
2025-10-17 14:08 ` Nuno Sá
2025-10-17 13:02 ` [PATCH 20/29] hwmon: (sfctemp) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 21/29] hwmon: (lochnagar-hwmon) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 22/29] hwmon: (ltc4282) " Guenter Roeck
2025-10-17 14:07 ` Nuno Sá
2025-10-17 13:02 ` [PATCH 23/29] hwmon: (aquacomputer_d5next) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 24/29] hwmon: (gpd-fan) " Guenter Roeck
2025-10-17 13:02 ` [PATCH 25/29] hwmon: (i5500_temp) Drop unnecessary include files Guenter Roeck
2025-10-17 13:02 ` [PATCH 26/29] hwmon: (asus_rog_ryujin) Rely on subsystem locking Guenter Roeck
2025-10-17 13:02 ` [PATCH 27/29] hwmon: (chipcap2) Drop unnecessary include files Guenter Roeck
2025-10-17 13:02 ` [PATCH 28/29] hwmon: (corsair-psu) Rely on subsystem locking Guenter Roeck
2025-10-17 13:02 ` [PATCH 29/29] " 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=20251017130221.1823453-18-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