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>
This commit is contained in:
Guenter Roeck 2025-09-07 21:38:32 -07:00
parent a640a80bf0
commit 1cfad0931e
1 changed files with 3 additions and 21 deletions

View File

@ -60,8 +60,6 @@ MODULE_DEVICE_TABLE(i2c, aht10_id);
/**
* struct aht10_data - All the data required to operate an AHT10/AHT20 chip
* @client: the i2c client associated with the AHT10/AHT20
* @lock: a mutex that is used to prevent parallel access to the
* i2c client
* @min_poll_interval: the minimum poll interval
* While the poll rate limit is not 100% necessary,
* the datasheet recommends that a measurement
@ -81,11 +79,6 @@ MODULE_DEVICE_TABLE(i2c, aht10_id);
struct aht10_data {
struct i2c_client *client;
/*
* Prevent simultaneous access to the i2c
* client and previous_poll_time
*/
struct mutex lock;
ktime_t min_poll_interval;
ktime_t previous_poll_time;
int temperature;
@ -168,32 +161,24 @@ static int aht10_read_values(struct aht10_data *data)
u8 raw_data[AHT20_MEAS_SIZE];
struct i2c_client *client = data->client;
mutex_lock(&data->lock);
if (!aht10_polltime_expired(data)) {
mutex_unlock(&data->lock);
if (!aht10_polltime_expired(data))
return 0;
}
res = i2c_master_send(client, cmd_meas, sizeof(cmd_meas));
if (res < 0) {
mutex_unlock(&data->lock);
if (res < 0)
return res;
}
usleep_range(AHT10_MEAS_DELAY, AHT10_MEAS_DELAY + AHT10_DELAY_EXTRA);
res = i2c_master_recv(client, raw_data, data->meas_size);
if (res != data->meas_size) {
mutex_unlock(&data->lock);
if (res >= 0)
return -ENODATA;
return res;
}
if (data->crc8 && crc8_check(raw_data, data->meas_size)) {
mutex_unlock(&data->lock);
if (data->crc8 && crc8_check(raw_data, data->meas_size))
return -EIO;
}
hum = ((u32)raw_data[1] << 12u) |
((u32)raw_data[2] << 4u) |
@ -210,7 +195,6 @@ static int aht10_read_values(struct aht10_data *data)
data->humidity = hum;
data->previous_poll_time = ktime_get_boottime();
mutex_unlock(&data->lock);
return 0;
}
@ -358,8 +342,6 @@ static int aht10_probe(struct i2c_client *client)
break;
}
mutex_init(&data->lock);
res = aht10_init(data);
if (res < 0)
return res;