Message ID | 20240103192707.115512-2-W_Armin@gmx.de (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | platform/x86: wmi: Event handling fixes | expand |
On Wed, 3 Jan 2024, Armin Wolf wrote: > When wmi_install_notify_handler()/wmi_remove_notify_handler() are > unable to enable/disable the WMI device, they unconditionally return > an error to the caller. > When registering legacy WMI notify handlers, this means that the > callback remains registered despite wmi_install_notify_handler() > having returned an error. > When removing legacy WMI notify handlers, this means that the > callback is removed despite wmi_remove_notify_handler() having > returned an error. > > Fix this by only warning when the WMI device could not be enabled. > This behaviour matches the bus-based WMI interface. > > Tested on a Dell Inspiron 3505 and a Acer Aspire E1-731. > > Fixes: 58f6425eb92f ("WMI: Cater for multiple events with same GUID") > Signed-off-by: Armin Wolf <W_Armin@gmx.de> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index a7cfcbf92432..3899a5e3fca7 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -592,9 +592,10 @@ acpi_status wmi_install_notify_handler(const char *guid, block->handler_data = data; wmi_status = wmi_method_enable(block, true); - if ((wmi_status != AE_OK) || - ((wmi_status == AE_OK) && (status == AE_NOT_EXIST))) - status = wmi_status; + if (ACPI_FAILURE(wmi_status)) + dev_warn(&block->dev.dev, "Failed to enable device\n"); + + status = AE_OK; } } @@ -630,10 +631,13 @@ acpi_status wmi_remove_notify_handler(const char *guid) return AE_NULL_ENTRY; wmi_status = wmi_method_enable(block, false); + if (ACPI_FAILURE(wmi_status)) + dev_warn(&block->dev.dev, "Failed to disable device\n"); + block->handler = NULL; block->handler_data = NULL; - if (wmi_status != AE_OK || (wmi_status == AE_OK && status == AE_NOT_EXIST)) - status = wmi_status; + + status = AE_OK; } }
When wmi_install_notify_handler()/wmi_remove_notify_handler() are unable to enable/disable the WMI device, they unconditionally return an error to the caller. When registering legacy WMI notify handlers, this means that the callback remains registered despite wmi_install_notify_handler() having returned an error. When removing legacy WMI notify handlers, this means that the callback is removed despite wmi_remove_notify_handler() having returned an error. Fix this by only warning when the WMI device could not be enabled. This behaviour matches the bus-based WMI interface. Tested on a Dell Inspiron 3505 and a Acer Aspire E1-731. Fixes: 58f6425eb92f ("WMI: Cater for multiple events with same GUID") Signed-off-by: Armin Wolf <W_Armin@gmx.de> --- drivers/platform/x86/wmi.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 2.39.2