From patchwork Sat Sep 4 17:56:41 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: 12475763 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 DB942C433EF for ; Sat, 4 Sep 2021 17:56:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE5A060F51 for ; Sat, 4 Sep 2021 17:56:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237340AbhIDR5t (ORCPT ); Sat, 4 Sep 2021 13:57:49 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:59889 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR5t (ORCPT ); Sat, 4 Sep 2021 13:57:49 -0400 Date: Sat, 04 Sep 2021 17:56:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778205; bh=cuST5sTp/SZSZalJB73tl09tIZsJXooY0G+gDmGBhSE=; h=Date:To:From:Reply-To:Subject:From; b=PcdjEuN1emrHaiNUf/Wu8pNSS0uvDu/Mmjm7RBr2BC7izOtK7Gs/qbd8sTVh9BG9z ydRzs5PwrgjtmUCw9UpPgBiRyUPa+2rsNwyC/q8Lc8wOh32ZIvoaBEtPbX7yNrjqX8 dzcJTjTzxhBOm38zheVMY2aBiO2kbof+fOpBnDuA= 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 29/30] platform/x86: wmi: introduce helper to retrieve event data Message-ID: <20210904175450.156801-30-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Previously, `acpi_wmi_notify_handler()` and `wmi_get_event_data()` shared more or less the exact same code to query the data for a particular event. Introduce a function to get rid of the duplication, and use it from `acpi_wmi_notify_handler()` and `wmi_get_event_data()`. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 42 ++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 22 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 830f09c2afe9..cd274de78ab4 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -219,6 +219,22 @@ static inline acpi_object_type get_param_acpi_type(const struct wmi_block *wbloc return ACPI_TYPE_BUFFER; } +static acpi_status get_event_data(const struct wmi_block *wblock, struct acpi_buffer *out) +{ + union acpi_object param = { + .integer = { + .type = ACPI_TYPE_INTEGER, + .value = wblock->gblock.notify_id, + } + }; + struct acpi_object_list input = { + .count = 1, + .pointer = ¶m, + }; + + return acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, out); +} + /* * Exported WMI functions */ @@ -623,22 +639,13 @@ EXPORT_SYMBOL_GPL(wmi_remove_notify_handler); */ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) { - struct acpi_object_list input; - union acpi_object params[1]; struct wmi_block *wblock; - input.count = 1; - input.pointer = params; - params[0].type = ACPI_TYPE_INTEGER; - params[0].integer.value = event; - list_for_each_entry(wblock, &wmi_block_list, list) { struct guid_block *gblock = &wblock->gblock; - if ((gblock->flags & ACPI_WMI_EVENT) && - (gblock->notify_id == event)) - return acpi_evaluate_object(wblock->acpi_device->handle, - "_WED", &input, out); + if ((gblock->flags & ACPI_WMI_EVENT) && gblock->notify_id == event) + return get_event_data(wblock, out); } return AE_NOT_FOUND; @@ -1303,21 +1310,12 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, /* If a driver is bound, then notify the driver. */ if (wblock->dev.dev.driver) { struct wmi_driver *driver = drv_to_wdrv(wblock->dev.dev.driver); - struct acpi_object_list input; - union acpi_object params[1]; struct acpi_buffer evdata = { ACPI_ALLOCATE_BUFFER, NULL }; acpi_status status; - input.count = 1; - input.pointer = params; - params[0].type = ACPI_TYPE_INTEGER; - params[0].integer.value = event; - - status = acpi_evaluate_object(wblock->acpi_device->handle, - "_WED", &input, &evdata); + status = get_event_data(wblock, &evdata); if (ACPI_FAILURE(status)) { - dev_warn(&wblock->dev.dev, - "failed to get event data\n"); + dev_warn(&wblock->dev.dev, "failed to get event data\n"); return; }