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

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>

+6 -31
+6 -31
drivers/hwmon/aquacomputer_d5next.c
··· 20 20 #include <linux/jiffies.h> 21 21 #include <linux/ktime.h> 22 22 #include <linux/module.h> 23 - #include <linux/mutex.h> 24 23 #include <linux/seq_file.h> 25 24 #include <linux/unaligned.h> 26 25 ··· 550 551 struct hid_device *hdev; 551 552 struct device *hwmon_dev; 552 553 struct dentry *debugfs; 553 - struct mutex mutex; /* Used for locking access when reading and writing PWM values */ 554 554 enum kinds kind; 555 555 const char *name; 556 556 ··· 660 662 } 661 663 } 662 664 663 - /* Expects the mutex to be locked */ 664 665 static int aqc_get_ctrl_data(struct aqc_data *priv) 665 666 { 666 667 int ret; ··· 677 680 return ret; 678 681 } 679 682 680 - /* Expects the mutex to be locked */ 681 683 static int aqc_send_ctrl_data(struct aqc_data *priv) 682 684 { 683 685 int ret; ··· 717 721 { 718 722 int ret; 719 723 720 - mutex_lock(&priv->mutex); 721 - 722 724 ret = aqc_get_ctrl_data(priv); 723 725 if (ret < 0) 724 - goto unlock_and_return; 726 + return ret; 725 727 726 728 switch (type) { 727 729 case AQC_BE16: ··· 731 737 default: 732 738 ret = -EINVAL; 733 739 } 734 - 735 - unlock_and_return: 736 - mutex_unlock(&priv->mutex); 737 740 return ret; 738 741 } 739 742 ··· 738 747 { 739 748 int ret, i; 740 749 741 - mutex_lock(&priv->mutex); 742 - 743 750 ret = aqc_get_ctrl_data(priv); 744 751 if (ret < 0) 745 - goto unlock_and_return; 752 + return ret; 746 753 747 754 for (i = 0; i < len; i++) { 748 755 switch (types[i]) { ··· 751 762 priv->buffer[offsets[i]] = (u8)vals[i]; 752 763 break; 753 764 default: 754 - ret = -EINVAL; 765 + return -EINVAL; 755 766 } 756 767 } 757 768 758 - if (ret < 0) 759 - goto unlock_and_return; 760 - 761 - ret = aqc_send_ctrl_data(priv); 762 - 763 - unlock_and_return: 764 - mutex_unlock(&priv->mutex); 765 - return ret; 769 + return aqc_send_ctrl_data(priv); 766 770 } 767 771 768 772 static int aqc_set_ctrl_val(struct aqc_data *priv, int offset, long val, int type) ··· 935 953 { 936 954 int ret, i, sensor_value; 937 955 938 - mutex_lock(&priv->mutex); 939 - 940 956 memset(priv->buffer, 0x00, priv->buffer_size); 941 957 ret = hid_hw_raw_request(priv->hdev, priv->status_report_id, priv->buffer, 942 958 priv->buffer_size, HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 943 959 if (ret < 0) 944 - goto unlock_and_return; 960 + return ret; 945 961 946 962 /* Temperature sensor readings */ 947 963 for (i = 0; i < priv->num_temp_sensors; i++) { ··· 1000 1020 } 1001 1021 1002 1022 priv->updated = jiffies; 1003 - 1004 - unlock_and_return: 1005 - mutex_unlock(&priv->mutex); 1006 - return ret; 1023 + return 0; 1007 1024 } 1008 1025 1009 1026 static int aqc_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, ··· 1846 1869 ret = -ENOMEM; 1847 1870 goto fail_and_close; 1848 1871 } 1849 - 1850 - mutex_init(&priv->mutex); 1851 1872 1852 1873 priv->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, priv->name, priv, 1853 1874 &aqc_chip_info, NULL);