diff options
author | Barnabás Pőcze <pobrn@protonmail.com> | 2021-09-04 20:56:44 +0300 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2021-09-14 13:26:03 +0300 |
commit | b0179b805eed104eb3b2319c23ccbfa717c18897 (patch) | |
tree | 4574f37d8697cacb11a55084a941466c21e4cdee /drivers/platform/x86/wmi.c | |
parent | 25be44f6e2fc9dd117ba6e18fa58317a2015af17 (diff) | |
download | linux-b0179b805eed104eb3b2319c23ccbfa717c18897.tar.xz |
platform/x86: wmi: more detailed error reporting in find_guid()
Make `find_guid()` return an acpi_status, and make it handle NULL
pointer GUID strings; and adapt users accordingly.
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Link: https://lore.kernel.org/r/20210904175450.156801-31-pobrn@protonmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/wmi.c')
-rw-r--r-- | drivers/platform/x86/wmi.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 441d4ddd6fbf..e6997be206f1 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -114,22 +114,27 @@ static struct platform_driver acpi_wmi_driver = { * GUID parsing functions */ -static bool find_guid(const char *guid_string, struct wmi_block **out) +static acpi_status find_guid(const char *guid_string, struct wmi_block **out) { guid_t guid_input; struct wmi_block *wblock; + if (!guid_string) + return AE_BAD_PARAMETER; + if (guid_parse(guid_string, &guid_input)) - return false; + return AE_BAD_PARAMETER; list_for_each_entry(wblock, &wmi_block_list, list) { if (guid_equal(&wblock->gblock.guid, &guid_input)) { if (out) *out = wblock; - return true; + + return AE_OK; } } - return false; + + return AE_NOT_FOUND; } static const void *find_guid_context(struct wmi_block *wblock, @@ -271,9 +276,12 @@ acpi_status wmi_evaluate_method(const char *guid_string, u8 instance, u32 method const struct acpi_buffer *in, struct acpi_buffer *out) { struct wmi_block *wblock = NULL; + acpi_status status; + + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) + return status; - if (!find_guid(guid_string, &wblock)) - return AE_ERROR; return wmidev_evaluate_method(&wblock->dev, instance, method_id, in, out); } @@ -410,12 +418,11 @@ acpi_status wmi_query_block(const char *guid_string, u8 instance, struct acpi_buffer *out) { struct wmi_block *wblock; + acpi_status status; - if (!guid_string) - return AE_BAD_PARAMETER; - - if (!find_guid(guid_string, &wblock)) - return AE_ERROR; + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) + return status; return __query_block(wblock, instance, out); } @@ -450,12 +457,14 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, struct acpi_object_list input; union acpi_object params[2]; char method[WMI_ACPI_METHOD_NAME_SIZE]; + acpi_status status; - if (!guid_string || !in) + if (!in) return AE_BAD_DATA; - if (!find_guid(guid_string, &wblock)) - return AE_ERROR; + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) + return status; block = &wblock->gblock; handle = wblock->acpi_device->handle; @@ -660,7 +669,7 @@ EXPORT_SYMBOL_GPL(wmi_get_event_data); */ bool wmi_has_guid(const char *guid_string) { - return find_guid(guid_string, NULL); + return ACPI_SUCCESS(find_guid(guid_string, NULL)); } EXPORT_SYMBOL_GPL(wmi_has_guid); @@ -675,8 +684,10 @@ EXPORT_SYMBOL_GPL(wmi_has_guid); char *wmi_get_acpi_device_uid(const char *guid_string) { struct wmi_block *wblock = NULL; + acpi_status status; - if (!find_guid(guid_string, &wblock)) + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) return NULL; return acpi_device_uid(wblock->acpi_device); |