[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250107113330.7970-3-lihuisong@huawei.com>
Date: Tue, 7 Jan 2025 19:33:29 +0800
From: Huisong Li <lihuisong@...wei.com>
To: <linux-hwmon@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>, <linux@...ck-us.net>, <jdelvare@...e.com>,
<liuyonglong@...wei.com>, <zhanjie9@...ilicon.com>,
<zhenglifeng1@...wei.com>, <lihuisong@...wei.com>
Subject: [PATCH v2 2/3] hwmon: (acpi_power_meter) Fix update the power trip points on failure
The power trip points maintained in local should not be updated when '_PTP'
method fails to evaluate.
Signed-off-by: Huisong Li <lihuisong@...wei.com>
---
drivers/hwmon/acpi_power_meter.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
index 0b337d4fb212..594f7681d523 100644
--- a/drivers/hwmon/acpi_power_meter.c
+++ b/drivers/hwmon/acpi_power_meter.c
@@ -293,8 +293,8 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct acpi_device *acpi_dev = to_acpi_device(dev);
struct acpi_power_meter_resource *resource = acpi_dev->driver_data;
+ unsigned long temp, trip_bk;
int res;
- unsigned long temp;
res = kstrtoul(buf, 10, &temp);
if (res)
@@ -302,13 +302,15 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
temp = DIV_ROUND_CLOSEST(temp, 1000);
- mutex_lock(&resource->lock);
+ guard(mutex)(&resource->lock);
+
+ trip_bk = resource->trip[attr->index - 7];
resource->trip[attr->index - 7] = temp;
res = set_acpi_trip(resource);
- mutex_unlock(&resource->lock);
-
- if (res)
+ if (res) {
+ resource->trip[attr->index - 7] = trip_bk;
return res;
+ }
return count;
}
--
2.22.0
Powered by blists - more mailing lists