]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (sfctemp) Rely on subsystem locking
authorGuenter Roeck <linux@roeck-us.net>
Mon, 8 Sep 2025 23:29:03 +0000 (16:29 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 17 Oct 2025 14:18:10 +0000 (07:18 -0700)
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

index fb1da93383d712d37741d1255e366c9a1c220cf4..b78b2c099a12a2a1cd73286402e70d87551a3459 100644 (file)
@@ -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 @@ err_assert_bus:
        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))