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

hwmon: (powr1220) 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>

+4 -13
+4 -13
drivers/hwmon/powr1220.c
··· 16 16 #include <linux/hwmon.h> 17 17 #include <linux/hwmon-sysfs.h> 18 18 #include <linux/err.h> 19 - #include <linux/mutex.h> 20 19 #include <linux/delay.h> 21 20 22 21 #define ADC_STEP_MV 2 ··· 74 75 75 76 struct powr1220_data { 76 77 struct i2c_client *client; 77 - struct mutex update_lock; 78 78 u8 max_channels; 79 79 bool adc_valid[MAX_POWR1220_ADC_VALUES]; 80 80 /* the next value is in jiffies */ ··· 109 111 int result; 110 112 int adc_range = 0; 111 113 112 - mutex_lock(&data->update_lock); 113 - 114 114 if (time_after(jiffies, data->adc_last_updated[ch_num] + HZ) || 115 115 !data->adc_valid[ch_num]) { 116 116 /* ··· 124 128 /* set the attenuator and mux */ 125 129 result = i2c_smbus_write_byte_data(data->client, ADC_MUX, 126 130 adc_range | ch_num); 127 - if (result) 128 - goto exit; 131 + if (result < 0) 132 + return result; 129 133 130 134 /* 131 135 * wait at least Tconvert time (200 us) for the ··· 136 140 /* get the ADC reading */ 137 141 result = i2c_smbus_read_byte_data(data->client, ADC_VALUE_LOW); 138 142 if (result < 0) 139 - goto exit; 143 + return result; 140 144 141 145 reading = result >> 4; 142 146 143 147 /* get the upper half of the reading */ 144 148 result = i2c_smbus_read_byte_data(data->client, ADC_VALUE_HIGH); 145 149 if (result < 0) 146 - goto exit; 150 + return result; 147 151 148 152 reading |= result << 4; 149 153 ··· 159 163 } else { 160 164 result = data->adc_values[ch_num]; 161 165 } 162 - 163 - exit: 164 - mutex_unlock(&data->update_lock); 165 - 166 166 return result; 167 167 } 168 168 ··· 294 302 break; 295 303 } 296 304 297 - mutex_init(&data->update_lock); 298 305 data->client = client; 299 306 300 307 hwmon_dev = devm_hwmon_device_register_with_info(&client->dev,