diff options
author | Barnabás Pőcze <pobrn@protonmail.com> | 2021-09-04 17:56:38 +0000 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2021-09-14 12:26:02 +0200 |
commit | 51142a0886bd34ec3c6e478739484a85b3b81cec (patch) | |
tree | b178b47168da9d1c0e2e45eb2e7d276a105c4fbf /drivers/platform/x86/wmi.c | |
parent | 57f2ce89211383947cdf93502ad53cf0d18b65fe (diff) | |
download | lwn-51142a0886bd34ec3c6e478739484a85b3b81cec.tar.gz lwn-51142a0886bd34ec3c6e478739484a85b3b81cec.zip |
platform/x86: wmi: introduce helper to determine type
Introduce helper function to determine the appropriate
ACPI type for the input parameter.
This also fixes the following checkpatch warning:
"braces {} are not necessary for any arm of this statement".
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Link: https://lore.kernel.org/r/20210904175450.156801-29-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 | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 2bad1ff38291..a78b37cb8041 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -211,6 +211,14 @@ static inline void get_acpi_method_name(const struct wmi_block *wblock, buffer[4] = '\0'; } +static inline acpi_object_type get_param_acpi_type(const struct wmi_block *wblock) +{ + if (wblock->gblock.flags & ACPI_WMI_STRING) + return ACPI_TYPE_STRING; + else + return ACPI_TYPE_BUFFER; +} + /* * Exported WMI functions */ @@ -295,11 +303,7 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met if (in) { input.count = 3; - if (block->flags & ACPI_WMI_STRING) { - params[2].type = ACPI_TYPE_STRING; - } else { - params[2].type = ACPI_TYPE_BUFFER; - } + params[2].type = get_param_acpi_type(wblock); params[2].buffer.length = in->length; params[2].buffer.pointer = in->pointer; } @@ -451,12 +455,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, input.pointer = params; params[0].type = ACPI_TYPE_INTEGER; params[0].integer.value = instance; - - if (block->flags & ACPI_WMI_STRING) { - params[1].type = ACPI_TYPE_STRING; - } else { - params[1].type = ACPI_TYPE_BUFFER; - } + params[1].type = get_param_acpi_type(wblock); params[1].buffer.length = in->length; params[1].buffer.pointer = in->pointer; |