From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 20/29] hwmon: (sfctemp) Rely on subsystem locking
Date: Fri, 17 Oct 2025 06:02:12 -0700 [thread overview]
Message-ID: <20251017130221.1823453-21-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/sfctemp.c | 36 ++++++++----------------------------
1 file changed, 8 insertions(+), 28 deletions(-)
diff --git a/drivers/hwmon/sfctemp.c b/drivers/hwmon/sfctemp.c
index fb1da93383d7..b78b2c099a12 100644
--- a/drivers/hwmon/sfctemp.c
+++ b/drivers/hwmon/sfctemp.c
@@ -10,7 +10,6 @@
#include <linux/hwmon.h>
#include <linux/io.h>
#include <linux/module.h>
-#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
@@ -49,8 +48,6 @@
#define SFCTEMP_K1000 81100L
struct sfctemp {
- /* serialize access to hardware register and enabled below */
- struct mutex lock;
void __iomem *regs;
struct clk *clk_sense;
struct clk *clk_bus;
@@ -92,15 +89,14 @@ static void sfctemp_stop(struct sfctemp *sfctemp)
static int sfctemp_enable(struct sfctemp *sfctemp)
{
- int ret = 0;
+ int ret;
- mutex_lock(&sfctemp->lock);
if (sfctemp->enabled)
- goto done;
+ return 0;
ret = clk_prepare_enable(sfctemp->clk_bus);
if (ret)
- goto err;
+ return ret;
ret = reset_control_deassert(sfctemp->rst_bus);
if (ret)
goto err_disable_bus;
@@ -115,9 +111,7 @@ static int sfctemp_enable(struct sfctemp *sfctemp)
sfctemp_power_up(sfctemp);
sfctemp_run(sfctemp);
sfctemp->enabled = true;
-done:
- mutex_unlock(&sfctemp->lock);
- return ret;
+ return 0;
err_disable_sense:
clk_disable_unprepare(sfctemp->clk_sense);
@@ -125,16 +119,13 @@ static int sfctemp_enable(struct sfctemp *sfctemp)
reset_control_assert(sfctemp->rst_bus);
err_disable_bus:
clk_disable_unprepare(sfctemp->clk_bus);
-err:
- mutex_unlock(&sfctemp->lock);
return ret;
}
static int sfctemp_disable(struct sfctemp *sfctemp)
{
- mutex_lock(&sfctemp->lock);
if (!sfctemp->enabled)
- goto done;
+ return 0;
sfctemp_stop(sfctemp);
sfctemp_power_down(sfctemp);
@@ -143,8 +134,6 @@ static int sfctemp_disable(struct sfctemp *sfctemp)
reset_control_assert(sfctemp->rst_bus);
clk_disable_unprepare(sfctemp->clk_bus);
sfctemp->enabled = false;
-done:
- mutex_unlock(&sfctemp->lock);
return 0;
}
@@ -155,22 +144,14 @@ static void sfctemp_disable_action(void *data)
static int sfctemp_convert(struct sfctemp *sfctemp, long *val)
{
- int ret;
-
- mutex_lock(&sfctemp->lock);
- if (!sfctemp->enabled) {
- ret = -ENODATA;
- goto out;
- }
+ if (!sfctemp->enabled)
+ return -ENODATA;
/* calculate temperature in milli Celcius */
*val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS)
* SFCTEMP_Y1000 / SFCTEMP_Z - SFCTEMP_K1000;
- ret = 0;
-out:
- mutex_unlock(&sfctemp->lock);
- return ret;
+ return 0;
}
static umode_t sfctemp_is_visible(const void *data, enum hwmon_sensor_types type,
@@ -263,7 +244,6 @@ static int sfctemp_probe(struct platform_device *pdev)
return -ENOMEM;
dev_set_drvdata(dev, sfctemp);
- mutex_init(&sfctemp->lock);
sfctemp->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(sfctemp->regs))
--
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 ` [PATCH 17/29] hwmon: (ltc2947-core) " Guenter Roeck
2025-10-17 14:11 ` 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 ` Guenter Roeck [this message]
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-21-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