2024-02-06 22:05:32

by Armin Wolf

[permalink] [raw]
Subject: [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists

Some devices like the MSI GF63-12VF contain WMI method blocks
without providing the necessary WMxx ACPI control methods.
Avoid creating WMI devices for such WMI method blocks since
the resulting WMI device is going to be unusable.

Signed-off-by: Armin Wolf <[email protected]>
---
drivers/platform/x86/wmi.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 3c288e8f404b..9d544c85e5a8 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -990,6 +990,15 @@ static int wmi_create_device(struct device *wmi_bus_dev,
}

if (wblock->gblock.flags & ACPI_WMI_METHOD) {
+ get_acpi_method_name(wblock, 'M', method);
+ if (!acpi_has_method(device->handle, method)) {
+ dev_warn(wmi_bus_dev,
+ FW_BUG "%s method block execution control method not found\n",
+ method);
+
+ return -ENXIO;
+ }
+
wblock->dev.dev.type = &wmi_type_method;
goto out_init;
}
--
2.39.2



2024-02-06 22:05:38

by Armin Wolf

[permalink] [raw]
Subject: [PATCH 3/4] platform/x86: wmi: Remove unnecessary out-of-memory message

If kzalloc() fails, an out-of-memory message is already
printed. Remove the unnecessary second warning message.

Signed-off-by: Armin Wolf <[email protected]>
---
drivers/platform/x86/wmi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 545d6696d7cb..396344523bce 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -1127,10 +1127,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev)
continue;

wblock = kzalloc(sizeof(*wblock), GFP_KERNEL);
- if (!wblock) {
- dev_err(wmi_bus_dev, "Failed to allocate %pUL\n", &gblock[i].guid);
+ if (!wblock)
continue;
- }

wblock->acpi_device = device;
wblock->gblock = gblock[i];
--
2.39.2


2024-02-06 22:05:52

by Armin Wolf

[permalink] [raw]
Subject: [PATCH 4/4] platform/x86: wmi: Replace pr_err() with dev_err()

Using dev_err() allows users to find out from which
device the error message came from.

Signed-off-by: Armin Wolf <[email protected]>
---
drivers/platform/x86/wmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 396344523bce..63906fdd0abf 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -1339,7 +1339,7 @@ static int acpi_wmi_probe(struct platform_device *device)

error = parse_wdg(wmi_bus_dev, device);
if (error) {
- pr_err("Failed to parse WDG method\n");
+ dev_err(&device->dev, "Failed to parse _WDG method\n");
return error;
}

--
2.39.2


2024-02-07 13:52:58

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH 1/4] platform/x86: wmi: Check if WMxx control method exists

On Tue, 06 Feb 2024 23:04:44 +0100, Armin Wolf wrote:

> Some devices like the MSI GF63-12VF contain WMI method blocks
> without providing the necessary WMxx ACPI control methods.
> Avoid creating WMI devices for such WMI method blocks since
> the resulting WMI device is going to be unusable.
>
>


Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/4] platform/x86: wmi: Check if WMxx control method exists
commit: 7f1b998a9108f7fd465039323d5fc2599b8cae77
[2/4] platform/x86: wmi: Use FW_BUG when warning about missing control methods
commit: d0c595a11785573aad3b9e32ae293c48757eceff
[3/4] platform/x86: wmi: Remove unnecessary out-of-memory message
commit: 49c67cd5b6a4b611ac775de3831f5e739dd580f2
[4/4] platform/x86: wmi: Replace pr_err() with dev_err()
commit: fde7da1072f3c0239a80b590e7b75c9411e8b630

--
i.