hwmon: (sfctemp) Rely on subsystem locking

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>
This commit is contained in:
Guenter Roeck 2025-09-08 16:29:03 -07:00
parent c3fc3c63c9
commit 00148a0a23
1 changed files with 8 additions and 28 deletions

View File

@ -10,7 +10,6 @@
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reset.h> #include <linux/reset.h>
@ -49,8 +48,6 @@
#define SFCTEMP_K1000 81100L #define SFCTEMP_K1000 81100L
struct sfctemp { struct sfctemp {
/* serialize access to hardware register and enabled below */
struct mutex lock;
void __iomem *regs; void __iomem *regs;
struct clk *clk_sense; struct clk *clk_sense;
struct clk *clk_bus; struct clk *clk_bus;
@ -92,15 +89,14 @@ static void sfctemp_stop(struct sfctemp *sfctemp)
static int sfctemp_enable(struct sfctemp *sfctemp) static int sfctemp_enable(struct sfctemp *sfctemp)
{ {
int ret = 0; int ret;
mutex_lock(&sfctemp->lock);
if (sfctemp->enabled) if (sfctemp->enabled)
goto done; return 0;
ret = clk_prepare_enable(sfctemp->clk_bus); ret = clk_prepare_enable(sfctemp->clk_bus);
if (ret) if (ret)
goto err; return ret;
ret = reset_control_deassert(sfctemp->rst_bus); ret = reset_control_deassert(sfctemp->rst_bus);
if (ret) if (ret)
goto err_disable_bus; goto err_disable_bus;
@ -115,9 +111,7 @@ static int sfctemp_enable(struct sfctemp *sfctemp)
sfctemp_power_up(sfctemp); sfctemp_power_up(sfctemp);
sfctemp_run(sfctemp); sfctemp_run(sfctemp);
sfctemp->enabled = true; sfctemp->enabled = true;
done: return 0;
mutex_unlock(&sfctemp->lock);
return ret;
err_disable_sense: err_disable_sense:
clk_disable_unprepare(sfctemp->clk_sense); clk_disable_unprepare(sfctemp->clk_sense);
@ -125,16 +119,13 @@ static int sfctemp_enable(struct sfctemp *sfctemp)
reset_control_assert(sfctemp->rst_bus); reset_control_assert(sfctemp->rst_bus);
err_disable_bus: err_disable_bus:
clk_disable_unprepare(sfctemp->clk_bus); clk_disable_unprepare(sfctemp->clk_bus);
err:
mutex_unlock(&sfctemp->lock);
return ret; return ret;
} }
static int sfctemp_disable(struct sfctemp *sfctemp) static int sfctemp_disable(struct sfctemp *sfctemp)
{ {
mutex_lock(&sfctemp->lock);
if (!sfctemp->enabled) if (!sfctemp->enabled)
goto done; return 0;
sfctemp_stop(sfctemp); sfctemp_stop(sfctemp);
sfctemp_power_down(sfctemp); sfctemp_power_down(sfctemp);
@ -143,8 +134,6 @@ static int sfctemp_disable(struct sfctemp *sfctemp)
reset_control_assert(sfctemp->rst_bus); reset_control_assert(sfctemp->rst_bus);
clk_disable_unprepare(sfctemp->clk_bus); clk_disable_unprepare(sfctemp->clk_bus);
sfctemp->enabled = false; sfctemp->enabled = false;
done:
mutex_unlock(&sfctemp->lock);
return 0; return 0;
} }
@ -155,22 +144,14 @@ static void sfctemp_disable_action(void *data)
static int sfctemp_convert(struct sfctemp *sfctemp, long *val) static int sfctemp_convert(struct sfctemp *sfctemp, long *val)
{ {
int ret; if (!sfctemp->enabled)
return -ENODATA;
mutex_lock(&sfctemp->lock);
if (!sfctemp->enabled) {
ret = -ENODATA;
goto out;
}
/* calculate temperature in milli Celcius */ /* calculate temperature in milli Celcius */
*val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS) *val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS)
* SFCTEMP_Y1000 / SFCTEMP_Z - SFCTEMP_K1000; * SFCTEMP_Y1000 / SFCTEMP_Z - SFCTEMP_K1000;
ret = 0; return 0;
out:
mutex_unlock(&sfctemp->lock);
return ret;
} }
static umode_t sfctemp_is_visible(const void *data, enum hwmon_sensor_types type, 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; return -ENOMEM;
dev_set_drvdata(dev, sfctemp); dev_set_drvdata(dev, sfctemp);
mutex_init(&sfctemp->lock);
sfctemp->regs = devm_platform_ioremap_resource(pdev, 0); sfctemp->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(sfctemp->regs)) if (IS_ERR(sfctemp->regs))