Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -28
+8 -28
drivers/hwmon/sfctemp.c
··· 10 10 #include <linux/hwmon.h> 11 11 #include <linux/io.h> 12 12 #include <linux/module.h> 13 - #include <linux/mutex.h> 14 13 #include <linux/of.h> 15 14 #include <linux/platform_device.h> 16 15 #include <linux/reset.h> ··· 48 49 #define SFCTEMP_K1000 81100L 49 50 50 51 struct sfctemp { 51 - /* serialize access to hardware register and enabled below */ 52 - struct mutex lock; 53 52 void __iomem *regs; 54 53 struct clk *clk_sense; 55 54 struct clk *clk_bus; ··· 89 92 90 93 static int sfctemp_enable(struct sfctemp *sfctemp) 91 94 { 92 - int ret = 0; 95 + int ret; 93 96 94 - mutex_lock(&sfctemp->lock); 95 97 if (sfctemp->enabled) 96 - goto done; 98 + return 0; 97 99 98 100 ret = clk_prepare_enable(sfctemp->clk_bus); 99 101 if (ret) 100 - goto err; 102 + return ret; 101 103 ret = reset_control_deassert(sfctemp->rst_bus); 102 104 if (ret) 103 105 goto err_disable_bus; ··· 111 115 sfctemp_power_up(sfctemp); 112 116 sfctemp_run(sfctemp); 113 117 sfctemp->enabled = true; 114 - done: 115 - mutex_unlock(&sfctemp->lock); 116 - return ret; 118 + return 0; 117 119 118 120 err_disable_sense: 119 121 clk_disable_unprepare(sfctemp->clk_sense); ··· 119 125 reset_control_assert(sfctemp->rst_bus); 120 126 err_disable_bus: 121 127 clk_disable_unprepare(sfctemp->clk_bus); 122 - err: 123 - mutex_unlock(&sfctemp->lock); 124 128 return ret; 125 129 } 126 130 127 131 static int sfctemp_disable(struct sfctemp *sfctemp) 128 132 { 129 - mutex_lock(&sfctemp->lock); 130 133 if (!sfctemp->enabled) 131 - goto done; 134 + return 0; 132 135 133 136 sfctemp_stop(sfctemp); 134 137 sfctemp_power_down(sfctemp); ··· 134 143 reset_control_assert(sfctemp->rst_bus); 135 144 clk_disable_unprepare(sfctemp->clk_bus); 136 145 sfctemp->enabled = false; 137 - done: 138 - mutex_unlock(&sfctemp->lock); 139 146 return 0; 140 147 } 141 148 ··· 144 155 145 156 static int sfctemp_convert(struct sfctemp *sfctemp, long *val) 146 157 { 147 - int ret; 148 - 149 - mutex_lock(&sfctemp->lock); 150 - if (!sfctemp->enabled) { 151 - ret = -ENODATA; 152 - goto out; 153 - } 158 + if (!sfctemp->enabled) 159 + return -ENODATA; 154 160 155 161 /* calculate temperature in milli Celcius */ 156 162 *val = (long)((readl(sfctemp->regs) & SFCTEMP_DOUT_MSK) >> SFCTEMP_DOUT_POS) 157 163 * SFCTEMP_Y1000 / SFCTEMP_Z - SFCTEMP_K1000; 158 164 159 - ret = 0; 160 - out: 161 - mutex_unlock(&sfctemp->lock); 162 - return ret; 165 + return 0; 163 166 } 164 167 165 168 static umode_t sfctemp_is_visible(const void *data, enum hwmon_sensor_types type, ··· 244 263 return -ENOMEM; 245 264 246 265 dev_set_drvdata(dev, sfctemp); 247 - mutex_init(&sfctemp->lock); 248 266 249 267 sfctemp->regs = devm_platform_ioremap_resource(pdev, 0); 250 268 if (IS_ERR(sfctemp->regs))