[1/4] platform/x86: wmi: Check if WMxx control method exists

Message ID 20240206220447.3102-1-W_Armin@gmx.de
State New
Headers
Series [1/4] platform/x86: wmi: Check if WMxx control method exists |

Commit Message

Armin Wolf Feb. 6, 2024, 10:04 p.m. UTC
  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 <W_Armin@gmx.de>
---
 drivers/platform/x86/wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

--
2.39.2
  

Comments

Ilpo Järvinen Feb. 7, 2024, 1:52 p.m. UTC | #1
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.
  

Patch

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;
 	}