]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (aht10) Rely on subsystem locking
authorGuenter Roeck <linux@roeck-us.net>
Mon, 8 Sep 2025 04:38:32 +0000 (21:38 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 17 Oct 2025 12:59:13 +0000 (05:59 -0700)
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>
drivers/hwmon/aht10.c

index d1c55e2eb47998c9a235b9d773ea173943398f57..8b90b661c393e5788e9e1da27ef43453705e91e3 100644 (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;