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

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

+3 -21
+3 -21
drivers/hwmon/aht10.c
··· 60 60 /** 61 61 * struct aht10_data - All the data required to operate an AHT10/AHT20 chip 62 62 * @client: the i2c client associated with the AHT10/AHT20 63 - * @lock: a mutex that is used to prevent parallel access to the 64 - * i2c client 65 63 * @min_poll_interval: the minimum poll interval 66 64 * While the poll rate limit is not 100% necessary, 67 65 * the datasheet recommends that a measurement ··· 79 81 80 82 struct aht10_data { 81 83 struct i2c_client *client; 82 - /* 83 - * Prevent simultaneous access to the i2c 84 - * client and previous_poll_time 85 - */ 86 - struct mutex lock; 87 84 ktime_t min_poll_interval; 88 85 ktime_t previous_poll_time; 89 86 int temperature; ··· 161 168 u8 raw_data[AHT20_MEAS_SIZE]; 162 169 struct i2c_client *client = data->client; 163 170 164 - mutex_lock(&data->lock); 165 - if (!aht10_polltime_expired(data)) { 166 - mutex_unlock(&data->lock); 171 + if (!aht10_polltime_expired(data)) 167 172 return 0; 168 - } 169 173 170 174 res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas)); 171 - if (res < 0) { 172 - mutex_unlock(&data->lock); 175 + if (res < 0) 173 176 return res; 174 - } 175 177 176 178 usleep_range(AHT10_MEAS_DELAY, AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA); 177 179 178 180 res = i2c_master_recv(client, raw_data, data->meas_size); 179 181 if (res != data->meas_size) { 180 - mutex_unlock(&data->lock); 181 182 if (res >= 0) 182 183 return -ENODATA; 183 184 return res; 184 185 } 185 186 186 - if (data->crc8 && crc8_check(raw_data, data->meas_size)) { 187 - mutex_unlock(&data->lock); 187 + if (data->crc8 && crc8_check(raw_data, data->meas_size)) 188 188 return -EIO; 189 - } 190 189 191 190 hum = ((u32)raw_data[1] << 12u) | 192 191 ((u32)raw_data[2] << 4u) | ··· 195 210 data->humidity = hum; 196 211 data->previous_poll_time = ktime_get_boottime(); 197 212 198 - mutex_unlock(&data->lock); 199 213 return 0; 200 214 } 201 215 ··· 341 357 data->meas_size = AHT10_MEAS_SIZE; 342 358 break; 343 359 } 344 - 345 - mutex_init(&data->lock); 346 360 347 361 res = aht10_init(data); 348 362 if (res < 0)