From: "lihuisong (C)" <lihuisong@huawei.com>
To: Guenter Roeck <linux@roeck-us.net>, <linux-hwmon@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <jdelvare@suse.com>, <liuyonglong@huawei.com>,
<zhanjie9@hisilicon.com>, <zhenglifeng1@huawei.com>
Subject: Re: [PATCH v1 2/4] hwmon: (acpi_power_meter) Fix update the power trip points on failure
Date: Tue, 26 Nov 2024 09:59:51 +0800 [thread overview]
Message-ID: <4a1ff82f-f79c-6b3d-975f-4bd0cff5c42d@huawei.com> (raw)
In-Reply-To: <7acbc41a-f822-4464-8bcb-b7379fa78a86@roeck-us.net>
在 2024/11/25 23:22, Guenter Roeck 写道:
> On 11/25/24 01:34, Huisong Li wrote:
>> The power trip points maintained in local should not be updated when
>> '_PTP'
>> method fails to evaluate.
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> ---
>> drivers/hwmon/acpi_power_meter.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwmon/acpi_power_meter.c
>> b/drivers/hwmon/acpi_power_meter.c
>> index 4c3314e35d30..95da73858a0b 100644
>> --- a/drivers/hwmon/acpi_power_meter.c
>> +++ b/drivers/hwmon/acpi_power_meter.c
>> @@ -292,8 +292,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,8 +302,11 @@ static ssize_t set_trip(struct device *dev,
>> struct device_attribute *devattr,
>> temp = DIV_ROUND_CLOSEST(temp, 1000);
>> mutex_lock(&resource->lock);
>> + trip_bk = resource->trip[attr->index - 7];
>> resource->trip[attr->index - 7] = temp;
>> res = set_acpi_trip(resource);
>> + if (!res)
>> + resource->trip[attr->index - 7] = trip_bk;
>
> Unless I am missing something, this restores the old value if setting
> the new value succeeded. Please explain.
>
Yes, you are right.
Restore the old value on faiure. will fix it.
>
>> mutex_unlock(&resource->lock);
>> if (res)
>
> .
next prev parent reply other threads:[~2024-11-26 1:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 9:34 [PATCH v1 0/4] hwmon: (acpi_power_meter) Some trival optimizations Huisong Li
2024-11-25 9:34 ` [PATCH v1 1/4] hwmon: (acpi_power_meter) Fix using uninitialized variables Huisong Li
2024-11-25 16:03 ` Guenter Roeck
2024-11-26 1:56 ` lihuisong (C)
2024-11-26 4:04 ` Guenter Roeck
2024-11-26 7:03 ` lihuisong (C)
2024-11-26 16:19 ` Guenter Roeck
2024-11-27 2:29 ` lihuisong (C)
2024-11-27 3:43 ` lihuisong (C)
2024-12-11 7:41 ` lihuisong (C)
2024-12-12 1:51 ` Guenter Roeck
2024-12-12 3:00 ` lihuisong (C)
2024-12-19 3:45 ` lihuisong (C)
2024-12-19 3:50 ` Guenter Roeck
2024-12-20 6:00 ` lihuisong (C)
2024-11-25 9:34 ` [PATCH v1 2/4] hwmon: (acpi_power_meter) Fix update the power trip points on failure Huisong Li
2024-11-25 15:22 ` Guenter Roeck
2024-11-26 1:59 ` lihuisong (C) [this message]
2024-11-25 9:34 ` [PATCH v1 3/4] hwmon: (acpi_power_meter) Remove redundant 'sensors_valid' variable Huisong Li
2024-11-25 15:38 ` Guenter Roeck
2024-11-26 2:25 ` lihuisong (C)
2024-11-25 9:34 ` [PATCH v1 4/4] hwmon: (acpi_power_meter) Add the print of no notification that hardware limit is enforced Huisong Li
2024-11-25 16:13 ` Guenter Roeck
2024-11-26 3:15 ` lihuisong (C)
2024-11-26 4:06 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4a1ff82f-f79c-6b3d-975f-4bd0cff5c42d@huawei.com \
--to=lihuisong@huawei.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=liuyonglong@huawei.com \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®