From patchwork Sat Sep 4 17:56:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 12475759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE05EC433F5 for ; Sat, 4 Sep 2021 17:56:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5D2960F51 for ; Sat, 4 Sep 2021 17:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237330AbhIDR5q (ORCPT ); Sat, 4 Sep 2021 13:57:46 -0400 Received: from mail-4317.protonmail.ch ([185.70.43.17]:41524 "EHLO mail-4317.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237334AbhIDR5q (ORCPT ); Sat, 4 Sep 2021 13:57:46 -0400 Date: Sat, 04 Sep 2021 17:56:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778203; bh=+DvUJAYWDwRMILzIJ0/SkLFVT28LPTstM4xb1uh5Xdo=; h=Date:To:From:Reply-To:Subject:From; b=nvKqcd4nyFQ6cjrb40mz5gZMB0DZXIPfED0yFOnwMGrA4nv3ARWn2jI8hqzkOWo+M JH/8Oq6GO/9jdmJFug3q4LiTeuLV6gm/OoTDV1ZY1grwGIqWcRFpv0wZ/qn4TppZAe uQehcMH9qa7jNJXApeas8UQ05RPF8ervy0+UG2VI= To: Hans de Goede , Mark Gross , platform-driver-x86@vger.kernel.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Reply-To: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v1 28/30] platform/x86: wmi: introduce helper to determine type Message-ID: <20210904175450.156801-29-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org 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 --- drivers/platform/x86/wmi.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 4f484677759b..830f09c2afe9 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;