hwmon: (aquacomputer_d5next) 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-09 05:54:26 -07:00
parent d4469d53a9
commit ca2363f8a2

View File

@@ -20,7 +20,6 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/ktime.h> #include <linux/ktime.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/unaligned.h> #include <linux/unaligned.h>
@@ -551,7 +550,6 @@ struct aqc_data {
struct hid_device *hdev; struct hid_device *hdev;
struct device *hwmon_dev; struct device *hwmon_dev;
struct dentry *debugfs; struct dentry *debugfs;
struct mutex mutex; /* Used for locking access when reading and writing PWM values */
enum kinds kind; enum kinds kind;
const char *name; const char *name;
@@ -662,7 +660,6 @@ static void aqc_delay_ctrl_report(struct aqc_data *priv)
} }
} }
/* Expects the mutex to be locked */
static int aqc_get_ctrl_data(struct aqc_data *priv) static int aqc_get_ctrl_data(struct aqc_data *priv)
{ {
int ret; int ret;
@@ -680,7 +677,6 @@ static int aqc_get_ctrl_data(struct aqc_data *priv)
return ret; return ret;
} }
/* Expects the mutex to be locked */
static int aqc_send_ctrl_data(struct aqc_data *priv) static int aqc_send_ctrl_data(struct aqc_data *priv)
{ {
int ret; int ret;
@@ -721,11 +717,9 @@ static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val, int ty
{ {
int ret; int ret;
mutex_lock(&priv->mutex);
ret = aqc_get_ctrl_data(priv); ret = aqc_get_ctrl_data(priv);
if (ret < 0) if (ret < 0)
goto unlock_and_return; return ret;
switch (type) { switch (type) {
case AQC_BE16: case AQC_BE16:
@@ -737,9 +731,6 @@ static int aqc_get_ctrl_val(struct aqc_data *priv, int offset, long *val, int ty
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
unlock_and_return:
mutex_unlock(&priv->mutex);
return ret; return ret;
} }
@@ -747,11 +738,9 @@ static int aqc_set_ctrl_vals(struct aqc_data *priv, int *offsets, long *vals, in
{ {
int ret, i; int ret, i;
mutex_lock(&priv->mutex);
ret = aqc_get_ctrl_data(priv); ret = aqc_get_ctrl_data(priv);
if (ret < 0) if (ret < 0)
goto unlock_and_return; return ret;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
switch (types[i]) { switch (types[i]) {
@@ -762,18 +751,11 @@ static int aqc_set_ctrl_vals(struct aqc_data *priv, int *offsets, long *vals, in
priv->buffer[offsets[i]] = (u8)vals[i]; priv->buffer[offsets[i]] = (u8)vals[i];
break; break;
default: default:
ret = -EINVAL; return -EINVAL;
} }
} }
if (ret < 0) return aqc_send_ctrl_data(priv);
goto unlock_and_return;
ret = aqc_send_ctrl_data(priv);
unlock_and_return:
mutex_unlock(&priv->mutex);
return ret;
} }
static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type) static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type)
@@ -953,13 +935,11 @@ static int aqc_legacy_read(struct aqc_data *priv)
{ {
int ret, i, sensor_value; int ret, i, sensor_value;
mutex_lock(&priv->mutex);
memset(priv->buffer, 0x00, priv->buffer_size); memset(priv->buffer, 0x00, priv->buffer_size);
ret = hid_hw_raw_request(priv->hdev, priv->status_report_id, priv->buffer, ret = hid_hw_raw_request(priv->hdev, priv->status_report_id, priv->buffer,
priv->buffer_size, HID_FEATURE_REPORT, HID_REQ_GET_REPORT); priv->buffer_size, HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
if (ret < 0) if (ret < 0)
goto unlock_and_return; return ret;
/* Temperature sensor readings */ /* Temperature sensor readings */
for (i = 0; i < priv->num_temp_sensors; i++) { for (i = 0; i < priv->num_temp_sensors; i++) {
@@ -1020,10 +1000,7 @@ static int aqc_legacy_read(struct aqc_data *priv)
} }
priv->updated = jiffies; priv->updated = jiffies;
return 0;
unlock_and_return:
mutex_unlock(&priv->mutex);
return ret;
} }
static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
@@ -1870,8 +1847,6 @@ static int aqc_probe(struct hid_device *hdev, const struct hid_device_id *id)
goto fail_and_close; goto fail_and_close;
} }
mutex_init(&priv->mutex);
priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, priv->name, priv, priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, priv->name, priv,
&aqc_chip_info, NULL); &aqc_chip_info, NULL);