From: Guenter Roeck Date: Mon, 8 Sep 2025 04:38:32 +0000 (-0700) Subject: hwmon: (aht10) Rely on subsystem locking X-Git-Tag: v6.19-rc1~148^2~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cfad0931e7b495245fd5092fc95bc4cc0ea1b3f;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c index d1c55e2eb4799..8b90b661c393e 100644 --- a/drivers/hwmon/aht10.c +++ b/drivers/hwmon/aht10.c @@ -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;