Skip to content

Commit 33b3809

Browse files
Antheas KapenekakisKyleGospo
authored andcommitted
[FROM-ML] platform/x86: msi-wmi-platform: Add unlocked msi_wmi_platform_query
This driver requires to be able to handle transactions that perform multiple WMI actions at a time. Therefore, it needs to be able to lock the wmi_lock mutex for multiple operations. Add msi_wmi_platform_query_unlocked() to allow the caller to perform the WMI query without locking the wmi_lock mutex, by renaming the existing function and adding a new one that only locks the mutex. Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
1 parent 5014349 commit 33b3809

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

drivers/platform/x86/msi-wmi-platform.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int msi_wmi_platform_parse_buffer(union acpi_object *obj, u8 *output, siz
141141
return 0;
142142
}
143143

144-
static int msi_wmi_platform_query(struct msi_wmi_platform_data *data,
144+
static int msi_wmi_platform_query_unlocked(struct msi_wmi_platform_data *data,
145145
enum msi_wmi_platform_method method, u8 *buffer,
146146
size_t length)
147147
{
@@ -157,15 +157,9 @@ static int msi_wmi_platform_query(struct msi_wmi_platform_data *data,
157157
if (!length)
158158
return -EINVAL;
159159

160-
/*
161-
* The ACPI control method responsible for handling the WMI method calls
162-
* is not thread-safe. Because of this we have to do the locking ourself.
163-
*/
164-
scoped_guard(mutex, &data->wmi_lock) {
165-
status = wmidev_evaluate_method(data->wdev, 0x0, method, &in, &out);
166-
if (ACPI_FAILURE(status))
167-
return -EIO;
168-
}
160+
status = wmidev_evaluate_method(data->wdev, 0x0, method, &in, &out);
161+
if (ACPI_FAILURE(status))
162+
return -EIO;
169163

170164
obj = out.pointer;
171165
if (!obj)
@@ -177,6 +171,19 @@ static int msi_wmi_platform_query(struct msi_wmi_platform_data *data,
177171
return ret;
178172
}
179173

174+
static int msi_wmi_platform_query(struct msi_wmi_platform_data *data,
175+
enum msi_wmi_platform_method method, u8 *buffer,
176+
size_t length)
177+
{
178+
/*
179+
* The ACPI control method responsible for handling the WMI method calls
180+
* is not thread-safe. Because of this we have to do the locking ourself.
181+
*/
182+
scoped_guard(mutex, &data->wmi_lock) {
183+
return msi_wmi_platform_query_unlocked(data, method, buffer, length);
184+
}
185+
}
186+
180187
static umode_t msi_wmi_platform_is_visible(const void *drvdata, enum hwmon_sensor_types type,
181188
u32 attr, int channel)
182189
{

0 commit comments

Comments
 (0)