From patchwork Sat Sep 4 17:54:57 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: 12475707 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 D99D4C433FE for ; Sat, 4 Sep 2021 17:55:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B247760F3A for ; Sat, 4 Sep 2021 17:55:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237260AbhIDR4I (ORCPT ); Sat, 4 Sep 2021 13:56:08 -0400 Received: from mail-4322.protonmail.ch ([185.70.43.22]:34321 "EHLO mail-4322.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR4H (ORCPT ); Sat, 4 Sep 2021 13:56:07 -0400 Date: Sat, 04 Sep 2021 17:54:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778104; bh=C+jpbm2TvlGkGChkqX7eTQhlM2Tx9ChZ6WVNZ5eQHts=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=eUhHkmyRryNjupBQPFP1U5jhXrNF6hlBaV43WV4jXcWdxLd6S1mCvV8xSNUSc4EV5 c4MCq1QrpoxTRU/tLauF1X6U1rDA4QdY2xE1ctKR0pBklHSVT6ngI7lB7C2MxAnzlU dhBnff9I8MRQWu+hxf5NTEJHuc46QKdXg9V5n54M= 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 01/30] platform/x86: wmi: fix kernel doc Message-ID: <20210904175450.156801-2-pobrn@protonmail.com> In-Reply-To: <20210904175450.156801-1-pobrn@protonmail.com> References: <20210904175450.156801-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The kernel doc erroneously specified `wmi_uninstall_notify_handler()` for the `wmi_remove_notify_handler()` function. Fix that. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index a76313006bdc..0b931629f0b0 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -551,7 +551,7 @@ wmi_notify_handler handler, void *data) EXPORT_SYMBOL_GPL(wmi_install_notify_handler); /** - * wmi_uninstall_notify_handler - Unregister handler for WMI events + * wmi_remove_notify_handler - Unregister handler for WMI events * @guid: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba * * Unregister handler for events sent to the ACPI-WMI mapper device. From patchwork Sat Sep 4 17:54:59 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: 12475711 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 BEC1CC433EF for ; Sat, 4 Sep 2021 17:55:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FC1560F3A for ; Sat, 4 Sep 2021 17:55:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237261AbhIDR4N (ORCPT ); Sat, 4 Sep 2021 13:56:13 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:43911 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237247AbhIDR4N (ORCPT ); Sat, 4 Sep 2021 13:56:13 -0400 Date: Sat, 04 Sep 2021 17:54:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778108; bh=0UnM6i/0AVHZD2smX1zPrlIi3uvf19Ea4BSEvI4Y+jU=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=NbJTpKIl+ebTv6BZ7k7n4YxbH9fC+tT67MMI2PSODbpqxswR6WxDvScygppz1y+Vg UD+ZV4K1G/vO2zosoiEhvw4CQaurgSv12WNNEUFJAeaDkV7AjaNgOx8uiGS+ICjlA5 AC8hzz2BBTdgWOomaBesO0qVK5MvNS779NmBeFWw= 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 02/30] platform/x86: wmi: fix checkpatch warnings Message-ID: <20210904175450.156801-3-pobrn@protonmail.com> In-Reply-To: <20210904175450.156801-1-pobrn@protonmail.com> References: <20210904175450.156801-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Fix the following two checkpatch warnings: * "space required before the open parenthesis '('" * "that open brace { should be on the previous line" Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 0b931629f0b0..73ed17a53af5 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -488,7 +488,7 @@ static void wmi_notify_debug(u32 value, void *context) return; pr_info("DEBUG Event "); - switch(obj->type) { + switch (obj->type) { case ACPI_TYPE_BUFFER: pr_cont("BUFFER_TYPE - length %d\n", obj->buffer.length); break; @@ -1277,8 +1277,7 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, if (wblock->acpi_device->handle == handle && (block->flags & ACPI_WMI_EVENT) && - (block->notify_id == event)) - { + (block->notify_id == event)) { found_it = true; break; } From patchwork Sat Sep 4 17:55:02 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: 12475709 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 606FEC433F5 for ; Sat, 4 Sep 2021 17:55:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4173860F38 for ; Sat, 4 Sep 2021 17:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231181AbhIDR4I (ORCPT ); Sat, 4 Sep 2021 13:56:08 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:39480 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237247AbhIDR4I (ORCPT ); Sat, 4 Sep 2021 13:56:08 -0400 Date: Sat, 04 Sep 2021 17:55:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778103; bh=5xz8REU2zTnPpbrXMnernHNASHyjzj6oSURQi478v00=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=UfVpXSj+lmFgqEr4GeaQhmln+lTV1tvz1GcgPNm5w8Jw9NvUXhY+tHRqVqO5FpMit r//M/ZC3jpCmwZYuXZAIzl+9LkylrVqAG6+tA0zi1bPXywmWIQEmj83s+BRmeB6CzV IjDH4gvYwuW0cCJT4Im2bdiW1JRS0Xj26h9tgSuw= 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 03/30] platform/x86: wmi: remove commas Message-ID: <20210904175450.156801-4-pobrn@protonmail.com> In-Reply-To: <20210904175450.156801-1-pobrn@protonmail.com> References: <20210904175450.156801-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Remove commas that are after terminating entries in arrays. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 73ed17a53af5..67c09d81a676 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -714,7 +714,7 @@ static struct attribute *wmi_attrs[] = { &dev_attr_guid.attr, &dev_attr_instance_count.attr, &dev_attr_expensive.attr, - NULL, + NULL }; ATTRIBUTE_GROUPS(wmi); @@ -729,7 +729,7 @@ static DEVICE_ATTR_RO(notify_id); static struct attribute *wmi_event_attrs[] = { &dev_attr_notify_id.attr, - NULL, + NULL }; ATTRIBUTE_GROUPS(wmi_event); @@ -755,13 +755,13 @@ static DEVICE_ATTR_RO(setable); static struct attribute *wmi_data_attrs[] = { &dev_attr_object_id.attr, &dev_attr_setable.attr, - NULL, + NULL }; ATTRIBUTE_GROUPS(wmi_data); static struct attribute *wmi_method_attrs[] = { &dev_attr_object_id.attr, - NULL, + NULL }; ATTRIBUTE_GROUPS(wmi_method); From patchwork Sat Sep 4 17:55:06 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: 12475713 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 A57F7C433EF for ; Sat, 4 Sep 2021 17:55:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8884660F3A for ; Sat, 4 Sep 2021 17:55:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237264AbhIDR4S (ORCPT ); Sat, 4 Sep 2021 13:56:18 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:59955 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237247AbhIDR4Q (ORCPT ); Sat, 4 Sep 2021 13:56:16 -0400 Date: Sat, 04 Sep 2021 17:55:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778113; bh=5YEAvyJ5CSho0v8E/Wba99Wq3UAHIt2MYUXfTEZSbXU=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=OhLZmDxhtfl0IZz6RkmERdsmFaI3Nxpw1JDybDJ3JQLornWE8m7c26l0Zo4uFjLSc BCep3s+5tDjIEuZhJf8ZXA7+TrVc/nG43GaqABOMN90N9ti2psuQTUR9kMXKlL0sVL pyxY7THgGSe/IeBcXgFAGHCmL/yl4laJZfdm/TfA= 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 04/30] platform/x86: wmi: remove unnecessary initialization Message-ID: <20210904175450.156801-5-pobrn@protonmail.com> In-Reply-To: <20210904175450.156801-1-pobrn@protonmail.com> References: <20210904175450.156801-1-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The empty initializer `{ }` is enough to properly initialize the terminating acpi_device_id entry in the device table, so use that. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 67c09d81a676..6ad5962da59b 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -91,7 +91,7 @@ static int acpi_wmi_probe(struct platform_device *device); static const struct acpi_device_id wmi_device_ids[] = { {"PNP0C14", 0}, {"pnp0c14", 0}, - {"", 0}, + { } }; MODULE_DEVICE_TABLE(acpi, wmi_device_ids); From patchwork Sat Sep 4 17:55:10 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: 12475715 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 452B7C433F5 for ; Sat, 4 Sep 2021 17:55:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F91760F38 for ; Sat, 4 Sep 2021 17:55:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237267AbhIDR4V (ORCPT ); Sat, 4 Sep 2021 13:56:21 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:21085 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237247AbhIDR4T (ORCPT ); Sat, 4 Sep 2021 13:56:19 -0400 Date: Sat, 04 Sep 2021 17:55:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778116; bh=jAKN2mV+JXICM9d6DRsLEwoqDgJspjAMnnEf2OJTwmI=; h=Date:To:From:Reply-To:Subject:From; b=TnVzSA6zfEWvqvMfd1pnhY0sBXFj8xl6lv5APy36YMLS7x29qrCHqKIrztMbdBgs+ W5JAUmV8m/gphg9udT+UtDZa/7XVJVyGFGbic7+LYb1UuG8QJdNWFBy8pbaHa1IyQl 57wr9IwOVYTfVUDtsMl4oKVDD5Yf1ufxoSZoQrtM= 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 05/30] platform/x86: wmi: remove unnecessary initializations Message-ID: <20210904175450.156801-6-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Some pointers are initialized when they are defined, but they are almost immediately reassigned in the following lines. Remove these superfluous assignments. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 6ad5962da59b..36890e301df5 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -177,7 +177,7 @@ static int get_subobj_info(acpi_handle handle, const char *pathname, static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) { - struct guid_block *block = NULL; + struct guid_block *block; char method[5]; acpi_status status; acpi_handle handle; @@ -229,7 +229,7 @@ EXPORT_SYMBOL_GPL(set_required_buffer_size); acpi_status wmi_evaluate_method(const char *guid_string, u8 instance, u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) { - struct wmi_block *wblock = NULL; + struct wmi_block *wblock; if (!find_guid(guid_string, &wblock)) return AE_ERROR; @@ -251,8 +251,8 @@ EXPORT_SYMBOL_GPL(wmi_evaluate_method); acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) { - struct guid_block *block = NULL; - struct wmi_block *wblock = NULL; + struct guid_block *block; + struct wmi_block *wblock; acpi_handle handle; acpi_status status; struct acpi_object_list input; @@ -299,7 +299,7 @@ EXPORT_SYMBOL_GPL(wmidev_evaluate_method); static acpi_status __query_block(struct wmi_block *wblock, u8 instance, struct acpi_buffer *out) { - struct guid_block *block = NULL; + struct guid_block *block; acpi_handle handle; acpi_status status, wc_status = AE_ERROR; struct acpi_object_list input; @@ -405,8 +405,8 @@ EXPORT_SYMBOL_GPL(wmidev_block_query); acpi_status wmi_set_block(const char *guid_string, u8 instance, const struct acpi_buffer *in) { - struct guid_block *block = NULL; - struct wmi_block *wblock = NULL; + struct guid_block *block; + struct wmi_block *wblock; acpi_handle handle; struct acpi_object_list input; union acpi_object params[2]; @@ -650,7 +650,7 @@ EXPORT_SYMBOL_GPL(wmi_has_guid); */ char *wmi_get_acpi_device_uid(const char *guid_string) { - struct wmi_block *wblock = NULL; + struct wmi_block *wblock; if (!find_guid(guid_string, &wblock)) return NULL; @@ -811,8 +811,8 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver) static int wmi_char_open(struct inode *inode, struct file *filp) { const char *driver_name = filp->f_path.dentry->d_iname; - struct wmi_block *wblock = NULL; - struct wmi_block *next = NULL; + struct wmi_block *wblock; + struct wmi_block *next; list_for_each_entry_safe(wblock, next, &wmi_block_list, list) { if (!wblock->dev.dev.driver) @@ -844,8 +844,8 @@ static long wmi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct wmi_ioctl_buffer __user *input = (struct wmi_ioctl_buffer __user *) arg; struct wmi_block *wblock = filp->private_data; - struct wmi_ioctl_buffer *buf = NULL; - struct wmi_driver *wdriver = NULL; + struct wmi_ioctl_buffer *buf; + struct wmi_driver *wdriver; int ret; if (_IOC_TYPE(cmd) != WMI_IOC) From patchwork Sat Sep 4 17:55:13 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: 12475717 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 11224C4332F for ; Sat, 4 Sep 2021 17:55:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E887960F3A for ; Sat, 4 Sep 2021 17:55:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237302AbhIDR4X (ORCPT ); Sat, 4 Sep 2021 13:56:23 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:55908 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237282AbhIDR4W (ORCPT ); Sat, 4 Sep 2021 13:56:22 -0400 Date: Sat, 04 Sep 2021 17:55:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778117; bh=Uaqd0jXLjtY3STuCp7rKf0fXMDLb+KTv9C74JFI4EmI=; h=Date:To:From:Reply-To:Subject:From; b=esS7Kru35VMit9A8IyUymB2q5h16wZ0qrfSTHR6FlaKGhAKLcrTwRn6YOis7w2gA7 SaY3puUSwHFVEWvCyExTz52VxJ7n9EXFpwVbdG4nlzoTHMXEYk4t1TcSCM/k9DFsyA WUD+OPMeSzmOucAnqBpeyUHGeSmIHbnfdbbJVSVo= 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 06/30] platform/x86: wmi: remove unnecessary variable Message-ID: <20210904175450.156801-7-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The `status` variable was assigned at the end, and then immediately returned. Remove it altogether, and return the previously assigned value directly. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 36890e301df5..dc31f81d83a7 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -254,7 +254,6 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, struct guid_block *block; struct wmi_block *wblock; acpi_handle handle; - acpi_status status; struct acpi_object_list input; union acpi_object params[3]; char method[5] = "WM"; @@ -290,9 +289,7 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, strncat(method, block->object_id, 2); - status = acpi_evaluate_object(handle, method, &input, out); - - return status; + return acpi_evaluate_object(handle, method, &input, out); } EXPORT_SYMBOL_GPL(wmidev_evaluate_method); From patchwork Sat Sep 4 17:55:16 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: 12475719 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 08ECAC433EF for ; Sat, 4 Sep 2021 17:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E454A60F38 for ; Sat, 4 Sep 2021 17:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237311AbhIDR4Y (ORCPT ); Sat, 4 Sep 2021 13:56:24 -0400 Received: from mail-4317.protonmail.ch ([185.70.43.17]:40664 "EHLO mail-4317.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237297AbhIDR4X (ORCPT ); Sat, 4 Sep 2021 13:56:23 -0400 Date: Sat, 04 Sep 2021 17:55:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778120; bh=LcLUFpeh/z/6S0WSjAWm7gFoW4KL6QLTFYAOkicZa08=; h=Date:To:From:Reply-To:Subject:From; b=Z/SK979sahfZBMFdHYknF8U4nfk6ECBhGp+jaxJhr67MvqlKjJbYH9cjktd/S6BN4 weO/frldIryIxTMbfIiQB93CRn672hrcrQEShxZigu0pgLsvecwiPubClQ/kYL0Y3Y 0t/8P/uL5S/F/4mOAeDlUUDzrIz2+i0H0aZhmrRQ= 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 07/30] platform/x86: wmi: remove unnecessary argument Message-ID: <20210904175450.156801-8-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The GUID block is available for `wmi_create_device()` through `wblock->gblock`. Use that consistently in the function instead of using a mix of `gblock` and `wblock->gblock`. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index dc31f81d83a7..6252e8d88680 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1028,7 +1028,6 @@ static const struct device_type wmi_type_data = { }; static int wmi_create_device(struct device *wmi_bus_dev, - const struct guid_block *gblock, struct wmi_block *wblock, struct acpi_device *device) { @@ -1036,12 +1035,12 @@ static int wmi_create_device(struct device *wmi_bus_dev, char method[5]; int result; - if (gblock->flags & ACPI_WMI_EVENT) { + if (wblock->gblock.flags & ACPI_WMI_EVENT) { wblock->dev.dev.type = &wmi_type_event; goto out_init; } - if (gblock->flags & ACPI_WMI_METHOD) { + if (wblock->gblock.flags & ACPI_WMI_METHOD) { wblock->dev.dev.type = &wmi_type_method; mutex_init(&wblock->char_mutex); goto out_init; @@ -1091,7 +1090,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, wblock->dev.dev.bus = &wmi_bus_type; wblock->dev.dev.parent = wmi_bus_dev; - dev_set_name(&wblock->dev.dev, "%pUL", gblock->guid); + dev_set_name(&wblock->dev.dev, "%pUL", wblock->gblock.guid); device_initialize(&wblock->dev.dev); @@ -1183,7 +1182,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) wblock->acpi_device = device; wblock->gblock = gblock[i]; - retval = wmi_create_device(wmi_bus_dev, &gblock[i], wblock, device); + retval = wmi_create_device(wmi_bus_dev, wblock, device); if (retval) { kfree(wblock); continue; From patchwork Sat Sep 4 17:55:20 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: 12475721 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 7FEA7C433F5 for ; Sat, 4 Sep 2021 17:55:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 689D260F38 for ; Sat, 4 Sep 2021 17:55:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237265AbhIDR43 (ORCPT ); Sat, 4 Sep 2021 13:56:29 -0400 Received: from mail-4317.protonmail.ch ([185.70.43.17]:53186 "EHLO mail-4317.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237297AbhIDR42 (ORCPT ); Sat, 4 Sep 2021 13:56:28 -0400 Date: Sat, 04 Sep 2021 17:55:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778125; bh=TgeM8TY1lGTJdNkviI824VEobz/nwKJ0OOVKCk4GoGA=; h=Date:To:From:Reply-To:Subject:From; b=REoyX/PRq4GEYr+bwDpRUOJ71Xe3T10wqIK0t4nofkojo97ay21ylXa/V2X8zNzfi bDttpFmsUS73mPZ/n6k3Q78McJflK3oAHqRL3/NQ3ENWnlIimmPn7FZ2WoCU6+162d ZJURF1INlNLW/PQioL3dYtWXwBwDnx1XoPZlFhX8= 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 08/30] platform/x86: wmi: remove unnecessary casts Message-ID: <20210904175450.156801-9-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Void pointers are implictly cast to arbitrary pointer types, so remove superfluous casts. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 6252e8d88680..c3ee64843731 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -387,7 +387,7 @@ union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance) if (ACPI_FAILURE(__query_block(wblock, instance, &out))) return NULL; - return (union acpi_object *)out.pointer; + return out.pointer; } EXPORT_SYMBOL_GPL(wmidev_block_query); @@ -479,8 +479,7 @@ static void wmi_notify_debug(u32 value, void *context) return; } - obj = (union acpi_object *)response.pointer; - + obj = response.pointer; if (!obj) return; @@ -1148,7 +1147,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) if (ACPI_FAILURE(status)) return -ENXIO; - obj = (union acpi_object *) out.pointer; + obj = out.pointer; if (!obj) return -ENXIO; @@ -1307,8 +1306,7 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, } if (driver->notify) - driver->notify(&wblock->dev, - (union acpi_object *)evdata.pointer); + driver->notify(&wblock->dev, evdata.pointer); kfree(evdata.pointer); } else if (wblock->handler) { @@ -1335,7 +1333,7 @@ static int acpi_wmi_remove(struct platform_device *device) acpi_remove_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler); wmi_free_devices(acpi_device); - device_unregister((struct device *)dev_get_drvdata(&device->dev)); + device_unregister(dev_get_drvdata(&device->dev)); return 0; } From patchwork Sat Sep 4 17:55:23 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: 12475725 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 A2006C433EF for ; Sat, 4 Sep 2021 17:55:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8731560F3A for ; Sat, 4 Sep 2021 17:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237317AbhIDR4h (ORCPT ); Sat, 4 Sep 2021 13:56:37 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:38104 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237282AbhIDR4h (ORCPT ); Sat, 4 Sep 2021 13:56:37 -0400 Date: Sat, 04 Sep 2021 17:55:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778133; bh=Ujb753o2jpL8FGy8OVxlFHKih2w3WtkbFVfryXun3z4=; h=Date:To:From:Reply-To:Subject:From; b=iphX+onY/T1opYf71moq+GyUSdp3WVQPVjffPXyFSutI37I7cMXvtdZHa2CTO7r5c UB9zjaMo/XfyFE1VdHHtvuoAd9OFFfMplqDwzDuUyMXjt5ARzls0oFm1C3vuPcGkGW Xtf0f7C80oUrtm7Dlneg38RkLBQd7hxCpbCRwfYI= 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 09/30] platform/x86: wmi: remove stray empty line Message-ID: <20210904175450.156801-10-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Remove an empty line after the last statement in `acpi_wmi_notify_handler()` which serves no purpose. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 1 - 1 file changed, 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index c3ee64843731..42cc83cf117f 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1321,7 +1321,6 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, wblock->acpi_device->pnp.device_class, dev_name(&wblock->dev.dev), event, 0); - } static int acpi_wmi_remove(struct platform_device *device) From patchwork Sat Sep 4 17:55:26 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: 12475723 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 8ECF2C433F5 for ; Sat, 4 Sep 2021 17:55:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78B5A60F38 for ; Sat, 4 Sep 2021 17:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbhIDR4f (ORCPT ); Sat, 4 Sep 2021 13:56:35 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:58304 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237282AbhIDR4f (ORCPT ); Sat, 4 Sep 2021 13:56:35 -0400 Date: Sat, 04 Sep 2021 17:55:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778131; bh=5h8z55lNsaA+ijdoGzRpnCzu0eDR/FDf6B9HgN5ftAY=; h=Date:To:From:Reply-To:Subject:From; b=L6q7qmmHlTsezpAemyYbxMCPRs7Jr5QVR9szw+qTiP/7CLn9YTNWwbx1Vo0Ln08UD e8HxhvOmTcmJe3iM8ADV4wMOjYj/5sKJ/dPnmTVmuOIyqRr5ru/xMwAtqxc1OcSp9u BB75De4lwLIC7Te+p2xop2u9EMRDe/qzxzK3vjPI= 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 10/30] platform/x86: wmi: remove unnecessary checks Message-ID: <20210904175450.156801-11-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The `find_guid_context()` is only called from one place, and `wblock` and `wdriver` cannot be NULL there. So remove the currently redundant checks. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 2 -- 1 file changed, 2 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 42cc83cf117f..46ebc4e421b4 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -135,8 +135,6 @@ static const void *find_guid_context(struct wmi_block *wblock, const struct wmi_device_id *id; guid_t guid_input; - if (wblock == NULL || wdriver == NULL) - return NULL; if (wdriver->id_table == NULL) return NULL; From patchwork Sat Sep 4 17:55:29 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: 12475727 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 27DAAC433FE for ; Sat, 4 Sep 2021 17:55:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1517D60F3A for ; Sat, 4 Sep 2021 17:55:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237282AbhIDR4i (ORCPT ); Sat, 4 Sep 2021 13:56:38 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:34873 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237315AbhIDR4h (ORCPT ); Sat, 4 Sep 2021 13:56:37 -0400 Date: Sat, 04 Sep 2021 17:55:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778134; bh=V3MUI41oPSiBTR7vqp7YpLb51SSbdHKCP40u45ED/Xg=; h=Date:To:From:Reply-To:Subject:From; b=MUlbNCW23WhzIGU6qJ9Etw70qiYrB9Sw3YxKyFMx0PGwMtUMaTp4uptRZruw7fLYg CX+VvbwsB4iFwXkbDTJN27+kIwTdZdHUXFwiBLpDVcYr+Fz2BCp0KVcyCkHoOkrY/w sbfmvTLhW5YBix+z7VKXfsxB5CplSndZyYlI7mCw= 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 11/30] platform/x86: wmi: use BIT() macro Message-ID: <20210904175450.156801-12-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Instead of manually creating the bit masks, use the `BIT()` macro to do it. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 46ebc4e421b4..029278775ebc 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -17,6 +17,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -70,10 +71,10 @@ struct wmi_block { * If the GUID data block is marked as expensive, we must enable and * explicitily disable data collection. */ -#define ACPI_WMI_EXPENSIVE 0x1 -#define ACPI_WMI_METHOD 0x2 /* GUID is a method */ -#define ACPI_WMI_STRING 0x4 /* GUID takes & returns a string */ -#define ACPI_WMI_EVENT 0x8 /* GUID is an event */ +#define ACPI_WMI_EXPENSIVE BIT(0) +#define ACPI_WMI_METHOD BIT(1) /* GUID is a method */ +#define ACPI_WMI_STRING BIT(2) /* GUID takes & returns a string */ +#define ACPI_WMI_EVENT BIT(3) /* GUID is an event */ static bool debug_event; module_param(debug_event, bool, 0444); From patchwork Sat Sep 4 17:55:32 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: 12475729 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 8AE0DC433F5 for ; Sat, 4 Sep 2021 17:55:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7141960F38 for ; Sat, 4 Sep 2021 17:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237322AbhIDR4s (ORCPT ); Sat, 4 Sep 2021 13:56:48 -0400 Received: from mail-40136.protonmail.ch ([185.70.40.136]:12440 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237253AbhIDR4p (ORCPT ); Sat, 4 Sep 2021 13:56:45 -0400 Date: Sat, 04 Sep 2021 17:55:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778142; bh=gbQJtDmvup2UmZbYwE4J43KC/phaPk3Ls8JxHWgP9DU=; h=Date:To:From:Reply-To:Subject:From; b=VHywgkXVNhhHJE9O676zsrYNIFCRD9VDBuU9Yd8Sr56gSW+zEJ4OQz4EXH0SK0udM v6SgHrfdHU8jM6GOU6EqTlze3EX+fqYv7z/FDiska1dETOkHnUH/cpzZhXhqtj3EIa EHYWcNR8cJL1i2DXuGR2G2O2kiu3JTT04czi6UYs= 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 12/30] platform/x86: wmi: use bool instead of int Message-ID: <20210904175450.156801-13-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The `bool` type is more expressive for a yes/no kind of value, so use that as the type of the `enable` parameter of `wmi_method_enable()`. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 029278775ebc..90ba75247d7f 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -174,7 +174,7 @@ static int get_subobj_info(acpi_handle handle, const char *pathname, return 0; } -static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable) +static acpi_status wmi_method_enable(struct wmi_block *wblock, bool enable) { struct guid_block *block; char method[5]; @@ -534,7 +534,7 @@ wmi_notify_handler handler, void *data) block->handler = handler; block->handler_data = data; - wmi_status = wmi_method_enable(block, 1); + wmi_status = wmi_method_enable(block, true); if ((wmi_status != AE_OK) || ((wmi_status == AE_OK) && (status == AE_NOT_EXIST))) status = wmi_status; @@ -575,7 +575,7 @@ acpi_status wmi_remove_notify_handler(const char *guid) block->handler = wmi_notify_debug; status = AE_OK; } else { - wmi_status = wmi_method_enable(block, 0); + wmi_status = wmi_method_enable(block, false); block->handler = NULL; block->handler_data = NULL; if ((wmi_status != AE_OK) || @@ -919,7 +919,7 @@ static int wmi_dev_probe(struct device *dev) int ret = 0; char *buf; - if (ACPI_FAILURE(wmi_method_enable(wblock, 1))) + if (ACPI_FAILURE(wmi_method_enable(wblock, true))) dev_warn(dev, "failed to enable device -- probing anyway\n"); if (wdriver->probe) { @@ -970,7 +970,7 @@ static int wmi_dev_probe(struct device *dev) probe_string_failure: kfree(wblock->handler_data); probe_failure: - if (ACPI_FAILURE(wmi_method_enable(wblock, 0))) + if (ACPI_FAILURE(wmi_method_enable(wblock, false))) dev_warn(dev, "failed to disable device\n"); return ret; } @@ -990,7 +990,7 @@ static void wmi_dev_remove(struct device *dev) if (wdriver->remove) wdriver->remove(dev_to_wdev(dev)); - if (ACPI_FAILURE(wmi_method_enable(wblock, 0))) + if (ACPI_FAILURE(wmi_method_enable(wblock, false))) dev_warn(dev, "failed to disable device\n"); } @@ -1190,7 +1190,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) if (debug_event) { wblock->handler = wmi_notify_debug; - wmi_method_enable(wblock, 1); + wmi_method_enable(wblock, true); } } @@ -1207,7 +1207,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) dev_err(wmi_bus_dev, "failed to register %pUL\n", wblock->gblock.guid); if (debug_event) - wmi_method_enable(wblock, 0); + wmi_method_enable(wblock, false); list_del(&wblock->list); put_device(&wblock->dev.dev); } From patchwork Sat Sep 4 17:55:35 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: 12475731 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 EBDB4C433EF for ; Sat, 4 Sep 2021 17:55:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7F1A60F38 for ; Sat, 4 Sep 2021 17:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237253AbhIDR4u (ORCPT ); Sat, 4 Sep 2021 13:56:50 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:34241 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237315AbhIDR4s (ORCPT ); Sat, 4 Sep 2021 13:56:48 -0400 Date: Sat, 04 Sep 2021 17:55:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778143; bh=P9LM12VlE5+I4+Kz2fFAoC2lPJYbzC2QNFMra66jBh8=; h=Date:To:From:Reply-To:Subject:From; b=YiHMxiK3/LDi3w/NbwIm3HxktBWBYK7hx3LULtWvlZ6SFXmypSAviiLhfcfLCCuq3 HvTliPVVo4UHSxq39sBIPrFjPGmCKjwup0BimMKVQLt5mfF02kcG69+wnh2xOUuayR +lyq3uWZrML+BjBz3NmLGVH4DlQuRmC6YOrAOK/4= 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 13/30] platform/x86: wmi: use dynamic debug to print data about events Message-ID: <20210904175450.156801-14-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The dynamic debug framework provides a more flexible way to configure debugging messages emitted by the kernel than module options. Use `dev_dbg()` in `acpi_wmi_notify_handler()` to print the event identifier and device name (which is the GUID). Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 90ba75247d7f..8aad8f080c64 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1313,8 +1313,7 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, wblock->handler(event, wblock->handler_data); } - if (debug_event) - pr_info("DEBUG Event GUID: %pUL\n", wblock->gblock.guid); + dev_dbg(&wblock->dev.dev, "event 0x%02X\n", event); acpi_bus_generate_netlink_event( wblock->acpi_device->pnp.device_class, From patchwork Sat Sep 4 17:55:39 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: 12475733 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 A1363C433F5 for ; Sat, 4 Sep 2021 17:55:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8ACDD60F3A for ; Sat, 4 Sep 2021 17:55:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237260AbhIDR4w (ORCPT ); Sat, 4 Sep 2021 13:56:52 -0400 Received: from mail-4317.protonmail.ch ([185.70.43.17]:11456 "EHLO mail-4317.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR4w (ORCPT ); Sat, 4 Sep 2021 13:56:52 -0400 Date: Sat, 04 Sep 2021 17:55:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778148; bh=ApKq5+czdPUQtABPdY+uGtbr6quDEGzNzXjW9XnNbPo=; h=Date:To:From:Reply-To:Subject:From; b=ELpxtY4eunvgh6+SYe0CmOZs35PDhSeaPXdlgVJ6xLOoS/TRspx5sQOsiyqVd8McH hLCd6zrKH3Zn+uQ4SvksYv6s3cK7EOMHDKt1y3ZNssxZGWolU/Rz6dBhHLQapxXSRw ha46LXbvNdqqQzJ/vSV1N1r0sAYIMhQRj2YwxTh0= 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 14/30] platform/x86: wmi: use guid_t and guid_equal() Message-ID: <20210904175450.156801-15-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Instead of hard-coding a 16 long byte array, use the available `guid_t` type and related methods. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 8aad8f080c64..28e5825cba8b 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -40,7 +40,7 @@ MODULE_LICENSE("GPL"); static LIST_HEAD(wmi_block_list); struct guid_block { - char guid[16]; + guid_t guid; union { char object_id[2]; struct { @@ -121,7 +121,7 @@ static bool find_guid(const char *guid_string, struct wmi_block **out) list_for_each_entry(wblock, &wmi_block_list, list) { block = &wblock->gblock; - if (memcmp(block->guid, &guid_input, 16) == 0) { + if (guid_equal(&block->guid, &guid_input)) { if (out) *out = wblock; return true; @@ -143,7 +143,7 @@ static const void *find_guid_context(struct wmi_block *wblock, while (*id->guid_string) { if (guid_parse(id->guid_string, &guid_input)) continue; - if (!memcmp(wblock->gblock.guid, &guid_input, 16)) + if (guid_equal(&wblock->gblock.guid, &guid_input)) return id->context; id++; } @@ -445,7 +445,7 @@ EXPORT_SYMBOL_GPL(wmi_set_block); static void wmi_dump_wdg(const struct guid_block *g) { - pr_info("%pUL:\n", g->guid); + pr_info("%pUL:\n", &g->guid); if (g->flags & ACPI_WMI_EVENT) pr_info("\tnotify_id: 0x%02X\n", g->notify_id); else @@ -526,7 +526,7 @@ wmi_notify_handler handler, void *data) list_for_each_entry(block, &wmi_block_list, list) { acpi_status wmi_status; - if (memcmp(block->gblock.guid, &guid_input, 16) == 0) { + if (guid_equal(&block->gblock.guid, &guid_input)) { if (block->handler && block->handler != wmi_notify_debug) return AE_ALREADY_ACQUIRED; @@ -566,7 +566,7 @@ acpi_status wmi_remove_notify_handler(const char *guid) list_for_each_entry(block, &wmi_block_list, list) { acpi_status wmi_status; - if (memcmp(block->gblock.guid, &guid_input, 16) == 0) { + if (guid_equal(&block->gblock.guid, &guid_input)) { if (!block->handler || block->handler == wmi_notify_debug) return AE_NULL_ENTRY; @@ -672,7 +672,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "wmi:%pUL\n", wblock->gblock.guid); + return sprintf(buf, "wmi:%pUL\n", &wblock->gblock.guid); } static DEVICE_ATTR_RO(modalias); @@ -681,7 +681,7 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "%pUL\n", wblock->gblock.guid); + return sprintf(buf, "%pUL\n", &wblock->gblock.guid); } static DEVICE_ATTR_RO(guid); @@ -764,10 +764,10 @@ static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env) { struct wmi_block *wblock = dev_to_wblock(dev); - if (add_uevent_var(env, "MODALIAS=wmi:%pUL", wblock->gblock.guid)) + if (add_uevent_var(env, "MODALIAS=wmi:%pUL", &wblock->gblock.guid)) return -ENOMEM; - if (add_uevent_var(env, "WMI_GUID=%pUL", wblock->gblock.guid)) + if (add_uevent_var(env, "WMI_GUID=%pUL", &wblock->gblock.guid)) return -ENOMEM; return 0; @@ -795,7 +795,7 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver) if (WARN_ON(guid_parse(id->guid_string, &driver_guid))) continue; - if (!memcmp(&driver_guid, wblock->gblock.guid, 16)) + if (guid_equal(&driver_guid, &wblock->gblock.guid)) return 1; id++; @@ -1088,7 +1088,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, wblock->dev.dev.bus = &wmi_bus_type; wblock->dev.dev.parent = wmi_bus_dev; - dev_set_name(&wblock->dev.dev, "%pUL", wblock->gblock.guid); + dev_set_name(&wblock->dev.dev, "%pUL", &wblock->gblock.guid); device_initialize(&wblock->dev.dev); @@ -1108,12 +1108,12 @@ static void wmi_free_devices(struct acpi_device *device) } } -static bool guid_already_parsed(struct acpi_device *device, const u8 *guid) +static bool guid_already_parsed(struct acpi_device *device, const guid_t *guid) { struct wmi_block *wblock; list_for_each_entry(wblock, &wmi_block_list, list) { - if (memcmp(wblock->gblock.guid, guid, 16) == 0) { + if (guid_equal(&wblock->gblock.guid, guid)) { /* * Because we historically didn't track the relationship * between GUIDs and ACPI nodes, we don't know whether @@ -1168,7 +1168,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) * case yet, so for now, we'll just ignore the duplicate * for device creation. */ - if (guid_already_parsed(device, gblock[i].guid)) + if (guid_already_parsed(device, &gblock[i].guid)) continue; wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); @@ -1205,7 +1205,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) retval = device_add(&wblock->dev.dev); if (retval) { dev_err(wmi_bus_dev, "failed to register %pUL\n", - wblock->gblock.guid); + &wblock->gblock.guid); if (debug_event) wmi_method_enable(wblock, false); list_del(&wblock->list); From patchwork Sat Sep 4 17:55:42 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: 12475735 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 62BB6C433EF for ; Sat, 4 Sep 2021 17:55:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B5A960F3A for ; Sat, 4 Sep 2021 17:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237261AbhIDR4z (ORCPT ); Sat, 4 Sep 2021 13:56:55 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:50580 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR4z (ORCPT ); Sat, 4 Sep 2021 13:56:55 -0400 Date: Sat, 04 Sep 2021 17:55:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778150; bh=lREbwgd5tWBgTYiPbypGyk4DDt12HSCS8dEsEbVQOAA=; h=Date:To:From:Reply-To:Subject:From; b=G8/oZZSFcMZNcwdZqqtNwsUN+SMpB5EkpM/nqnFXGrdH4Dc9Hgioyib1CgCSomgB6 vBBksao+1epG0sy/xCjder2aGWXJp9pKeAPIO7TOMGha0S6eMycequp1rCAffPE46+ s9gTTPpPaR0vZHUA9VQ1cQ5jsq88MG+MszWrzNf8= 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 15/30] platform/x86: wmi: make GUID block packed Message-ID: <20210904175450.156801-16-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The `guid_block` struct is overlaid onto a buffer coming from the _WDG ACPI object of the device. For this reason mark the struct packed and add assertions about sizes. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 28e5825cba8b..7db85a15f5f6 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,10 @@ struct guid_block { }; u8 instance_count; u8 flags; -}; +} __packed; +static_assert(sizeof(typeof_member(struct guid_block, guid)) == 16); +static_assert(sizeof(struct guid_block) == 20); +static_assert(__alignof__(struct guid_block) == 1); struct wmi_block { struct wmi_device dev; From patchwork Sat Sep 4 17:55:45 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: 12475737 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 29DF5C433F5 for ; Sat, 4 Sep 2021 17:55:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1138960F38 for ; Sat, 4 Sep 2021 17:55:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237264AbhIDR45 (ORCPT ); Sat, 4 Sep 2021 13:56:57 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:19414 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR44 (ORCPT ); Sat, 4 Sep 2021 13:56:56 -0400 Date: Sat, 04 Sep 2021 17:55:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778153; bh=+M6jZyUvDs8D1HDsUDXsmgnavyLE7UIgqhM31Lni2z8=; h=Date:To:From:Reply-To:Subject:From; b=b5dJvNRpydFAIFaokwZrYZLUX/RykbPO6cGrsDq8u4fwoUUusmvTgmSAi5PEGTt0Y xqN96wgjV001bIdZ+4HRrrfjT4t+og8OVLUAaHT3NfIVopZ1i0aJCLol4EdyKg4rmF y91U0Ta4gWdSf/noHVmHntg3YLhEgJIy9Swsn33Y= 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 16/30] platform/x86: wmi: use sysfs_emit() Message-ID: <20210904175450.156801-17-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Instead of `sprintf()` use the new `sysfs_emit()` function. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 7db85a15f5f6..f05c89fd1f79 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -676,7 +677,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "wmi:%pUL\n", &wblock->gblock.guid); + return sysfs_emit(buf, "wmi:%pUL\n", &wblock->gblock.guid); } static DEVICE_ATTR_RO(modalias); @@ -685,7 +686,7 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "%pUL\n", &wblock->gblock.guid); + return sysfs_emit(buf, "%pUL\n", &wblock->gblock.guid); } static DEVICE_ATTR_RO(guid); @@ -694,7 +695,7 @@ static ssize_t instance_count_show(struct device *dev, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "%d\n", (int)wblock->gblock.instance_count); + return sysfs_emit(buf, "%d\n", (int)wblock->gblock.instance_count); } static DEVICE_ATTR_RO(instance_count); @@ -703,8 +704,8 @@ static ssize_t expensive_show(struct device *dev, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "%d\n", - (wblock->gblock.flags & ACPI_WMI_EXPENSIVE) != 0); + return sysfs_emit(buf, "%d\n", + (wblock->gblock.flags & ACPI_WMI_EXPENSIVE) != 0); } static DEVICE_ATTR_RO(expensive); @@ -722,7 +723,7 @@ static ssize_t notify_id_show(struct device *dev, struct device_attribute *attr, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "%02X\n", (unsigned int)wblock->gblock.notify_id); + return sysfs_emit(buf, "%02X\n", (unsigned int)wblock->gblock.notify_id); } static DEVICE_ATTR_RO(notify_id); @@ -737,8 +738,8 @@ static ssize_t object_id_show(struct device *dev, struct device_attribute *attr, { struct wmi_block *wblock = dev_to_wblock(dev); - return sprintf(buf, "%c%c\n", wblock->gblock.object_id[0], - wblock->gblock.object_id[1]); + return sysfs_emit(buf, "%c%c\n", wblock->gblock.object_id[0], + wblock->gblock.object_id[1]); } static DEVICE_ATTR_RO(object_id); @@ -747,7 +748,7 @@ static ssize_t setable_show(struct device *dev, struct device_attribute *attr, { struct wmi_device *wdev = dev_to_wdev(dev); - return sprintf(buf, "%d\n", (int)wdev->setable); + return sysfs_emit(buf, "%d\n", (int)wdev->setable); } static DEVICE_ATTR_RO(setable); From patchwork Sat Sep 4 17:55:48 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: 12475739 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 AA334C433EF for ; Sat, 4 Sep 2021 17:55:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97669603E7 for ; Sat, 4 Sep 2021 17:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237267AbhIDR47 (ORCPT ); Sat, 4 Sep 2021 13:56:59 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:36581 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR47 (ORCPT ); Sat, 4 Sep 2021 13:56:59 -0400 Date: Sat, 04 Sep 2021 17:55:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778155; bh=DCt0KJ8hjPB8FkCriJLTZ89ABmv8kzwN5WHB+pIjrDw=; h=Date:To:From:Reply-To:Subject:From; b=sxjeQ+JNrk/6435tC09eyiJGRBwpDGncsLRHcpitj+7NszXm9XmhG3BjboBu5TPuh C/WWHIZK9Wea19g9J+GK6xpfVgqmpoiJnDe54N9JIWnSmvhRV83Gs3Shdw9bewQAUF On4Qp4EWLMH/clMG2fC2SFRC0g5yCAqz2b5auaCE= 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 17/30] platform/x86: wmi: use sizeof() instead of hard-coding Message-ID: <20210904175450.156801-18-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Avoid hard-coding the buffer size in an `snprintf()` call by using `sizeof()` to retrieve the size. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index f05c89fd1f79..979135a678e0 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -189,7 +189,7 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, bool enable) block = &wblock->gblock; handle = wblock->acpi_device->handle; - snprintf(method, 5, "WE%02X", block->notify_id); + snprintf(method, sizeof(method), "WE%02X", block->notify_id); status = acpi_execute_simple_method(handle, method, enable); if (status != AE_OK && status != AE_NOT_FOUND) From patchwork Sat Sep 4 17:55:52 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: 12475741 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 04576C433FE for ; Sat, 4 Sep 2021 17:56:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E21A1603E7 for ; Sat, 4 Sep 2021 17:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbhIDR5B (ORCPT ); Sat, 4 Sep 2021 13:57:01 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:59987 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR5A (ORCPT ); Sat, 4 Sep 2021 13:57:00 -0400 Date: Sat, 04 Sep 2021 17:55:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778156; bh=ML+bFiDT8uKwEDgTby/Q6ZiVFNrU5Dm92qzCoSPh7Qg=; h=Date:To:From:Reply-To:Subject:From; b=uKn0qEKy4zAbEsrOvIfCIP91PTvd6R1DSE63BqGsTaM5kSsawnGRkA4Mq+5obJDVI XgNVbOugKK5mAHdMyYynzBvdJffal27psJ4YE0Pnhy4z2l9OAibBTZuBU2r+Y9HaxY PmmiTlubH13SPDKkLMDJ8b2rYtS2sdtJ6WYHVYgA= 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 18/30] platform/x86: wmi: use !p to check for NULL Message-ID: <20210904175450.156801-19-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Other parts of the code use the `!p` idiom to check for NULL pointers, convert `find_guid_context()` to do the same. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 979135a678e0..0e721d868bf7 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -141,10 +141,10 @@ static const void *find_guid_context(struct wmi_block *wblock, const struct wmi_device_id *id; guid_t guid_input; - if (wdriver->id_table == NULL) + id = wdriver->id_table; + if (!id) return NULL; - id = wdriver->id_table; while (*id->guid_string) { if (guid_parse(id->guid_string, &guid_input)) continue; From patchwork Sat Sep 4 17:56:03 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: 12475743 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 21375C433EF for ; Sat, 4 Sep 2021 17:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03B206056B for ; Sat, 4 Sep 2021 17:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237265AbhIDR5L (ORCPT ); Sat, 4 Sep 2021 13:57:11 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:59067 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhIDR5K (ORCPT ); Sat, 4 Sep 2021 13:57:10 -0400 Date: Sat, 04 Sep 2021 17:56:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778167; bh=q5glyydl1R8dK+AIve/gRQcjiz9BZkSLzd3soZM+koY=; h=Date:To:From:Reply-To:Subject:From; b=TwpHZfoasa17CcO3zsFKo+ZvWqQY13yD2lPLJiyftFz8AqzJmD3HZoBJT8SKGYZR9 IBKjJXjt6ScX9c0iXlMJ8m3IvGagzdZLbJV+mpewSkmT6edm4eOtrV20cbKQlTzv5T dGh27Hfg15HPv+12+0GtDMm1xm01X3ploZ+ghp+s= 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 19/30] platform/x86: wmi: use sizeof(*p) in allocation Message-ID: <20210904175450.156801-20-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org As per the coding style guide, the preferred way to pass the size of objects to allocator functions is `sizeof(*p)`. Use that. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 0e721d868bf7..7f7dfb7f9aa8 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1176,7 +1176,7 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) if (guid_already_parsed(device, &gblock[i].guid)) continue; - wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL); + wblock = kzalloc(sizeof(*wblock), GFP_KERNEL); if (!wblock) { retval = -ENOMEM; break; From patchwork Sat Sep 4 17:56:07 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: 12475745 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 9379EC433EF for ; Sat, 4 Sep 2021 17:56:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6416A6056B for ; Sat, 4 Sep 2021 17:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237311AbhIDR5O (ORCPT ); Sat, 4 Sep 2021 13:57:14 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:56485 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237305AbhIDR5O (ORCPT ); Sat, 4 Sep 2021 13:57:14 -0400 Date: Sat, 04 Sep 2021 17:56:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778170; bh=ZdXpvskwolJs4yhYD/N0m1S46yAiNrFSEd70Yu1Oi+s=; h=Date:To:From:Reply-To:Subject:From; b=LnPDPvqxGojhOcW7Nm6DO+6eloeOiYX/7VBK3gOSaJ6K9M1UziS8o2SiD+6BeQDX+ c5Hm0hroy2xknYCdYErOrzc6poVwx11Mkgh41rAVe8Utzn2mgDyPaMW6xg3hPdW7Ju suEs1palOlKLmCLw00kJSKiqlfbKy7+rz3h8F4OA= 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 20/30] platform/x86: wmi: remove variable Message-ID: <20210904175450.156801-21-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The `block` variable is assigned and only used once, the code shorter and probably clearer without it; so remove it. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 7f7dfb7f9aa8..261a6b68240e 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -118,15 +118,12 @@ static bool find_guid(const char *guid_string, struct wmi_block **out) { guid_t guid_input; struct wmi_block *wblock; - struct guid_block *block; if (guid_parse(guid_string, &guid_input)) return false; list_for_each_entry(wblock, &wmi_block_list, list) { - block = &wblock->gblock; - - if (guid_equal(&block->guid, &guid_input)) { + if (guid_equal(&wblock->gblock.guid, &guid_input)) { if (out) *out = wblock; return true; From patchwork Sat Sep 4 17:56:10 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: 12475749 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 BD0F9C433F5 for ; Sat, 4 Sep 2021 17:56:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B86E6056B for ; Sat, 4 Sep 2021 17:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237325AbhIDR5Y (ORCPT ); Sat, 4 Sep 2021 13:57:24 -0400 Received: from mail-0201.mail-europe.com ([51.77.79.158]:39312 "EHLO mail-0201.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237305AbhIDR5Y (ORCPT ); Sat, 4 Sep 2021 13:57:24 -0400 Date: Sat, 04 Sep 2021 17:56:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778179; bh=84Tx36ctXhaE1KIvvu+LHN26idbWzqLeVLzIml7LtUw=; h=Date:To:From:Reply-To:Subject:From; b=EqQr+IVOWAbIt1s3LYf46WYbAXu1X0y1yO297Pmx/RwPqNvp1nDJUsxdPv8jHIq8z 3QLdNHP++3EwvDB+e11lRfONMhWYkmBUp03OSUREgIkHuJ92aLYsGwcrmKlBEvlBMw K/h7YcZpWIy0bJTIt0GbkdfndNHKuCLnL1e/0cMA= 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 21/30] platform/x86: wmi: move variables Message-ID: <20210904175450.156801-22-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Move some variables in order to keep them in the narrowest possible scope. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 261a6b68240e..23aab588fdb2 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -136,13 +136,14 @@ static const void *find_guid_context(struct wmi_block *wblock, struct wmi_driver *wdriver) { const struct wmi_device_id *id; - guid_t guid_input; id = wdriver->id_table; if (!id) return NULL; while (*id->guid_string) { + guid_t guid_input; + if (guid_parse(id->guid_string, &guid_input)) continue; if (guid_equal(&wblock->gblock.guid, &guid_input)) @@ -604,7 +605,6 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) { struct acpi_object_list input; union acpi_object params[1]; - struct guid_block *gblock; struct wmi_block *wblock; input.count = 1; @@ -613,7 +613,7 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) params[0].integer.value = event; list_for_each_entry(wblock, &wmi_block_list, list) { - gblock = &wblock->gblock; + struct guid_block *gblock = &wblock->gblock; if ((gblock->flags & ACPI_WMI_EVENT) && (gblock->notify_id == event)) @@ -1264,12 +1264,11 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, void *context) { - struct guid_block *block; struct wmi_block *wblock; bool found_it = false; list_for_each_entry(wblock, &wmi_block_list, list) { - block = &wblock->gblock; + struct guid_block *block = &wblock->gblock; if (wblock->acpi_device->handle == handle && (block->flags & ACPI_WMI_EVENT) && From patchwork Sat Sep 4 17:56:13 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: 12475747 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 076C0C433F5 for ; Sat, 4 Sep 2021 17:56:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE0456056B for ; Sat, 4 Sep 2021 17:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237315AbhIDR5U (ORCPT ); Sat, 4 Sep 2021 13:57:20 -0400 Received: from mail-40136.protonmail.ch ([185.70.40.136]:14996 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237305AbhIDR5T (ORCPT ); Sat, 4 Sep 2021 13:57:19 -0400 Date: Sat, 04 Sep 2021 17:56:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778176; bh=KITuurI6kknC8fj+9pkALatR+u7FDSlXJcBw3vxqfV8=; h=Date:To:From:Reply-To:Subject:From; b=P0ImXe0kuGFmgwT6Ikxyh09EAU8y1u55TnaWdHChv1dlr760yzM79HKlJDRuQUjeI zqGlN5B9ponzwiSxL/SjHMVqYFVLSZjEPTVOvsxeqbSHxGWxVIMBG1hY+8HDZg51Ub tcwTSa80a0olm16bhA3wgRHj8KopkJg9AdcCPbag= 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 22/30] platform/x86: wmi: align arguments of functions Message-ID: <20210904175450.156801-23-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Align the arguments of * wmi_evaluate_method() * wmi_install_notify_handler() * wmidev_evaluate_method() * find_guid_context() * acpi_wmi_ec_space_handler() * wmi_char_read() Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 23aab588fdb2..fcc867d79e91 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -133,7 +133,7 @@ static bool find_guid(const char *guid_string, struct wmi_block **out) } static const void *find_guid_context(struct wmi_block *wblock, - struct wmi_driver *wdriver) + struct wmi_driver *wdriver) { const struct wmi_device_id *id; @@ -228,8 +228,8 @@ EXPORT_SYMBOL_GPL(set_required_buffer_size); * * Call an ACPI-WMI method */ -acpi_status wmi_evaluate_method(const char *guid_string, u8 instance, -u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) +acpi_status wmi_evaluate_method(const char *guid_string, u8 instance, u32 method_id, + const struct acpi_buffer *in, struct acpi_buffer *out) { struct wmi_block *wblock; @@ -250,8 +250,8 @@ EXPORT_SYMBOL_GPL(wmi_evaluate_method); * * Call an ACPI-WMI method */ -acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, - u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out) +acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 method_id, + const struct acpi_buffer *in, struct acpi_buffer *out) { struct guid_block *block; struct wmi_block *wblock; @@ -514,7 +514,8 @@ static void wmi_notify_debug(u32 value, void *context) * Register a handler for events sent to the ACPI-WMI mapper device. */ acpi_status wmi_install_notify_handler(const char *guid, -wmi_notify_handler handler, void *data) + wmi_notify_handler handler, + void *data) { struct wmi_block *block; acpi_status status = AE_NOT_EXIST; @@ -827,7 +828,7 @@ static int wmi_char_open(struct inode *inode, struct file *filp) } static ssize_t wmi_char_read(struct file *filp, char __user *buffer, - size_t length, loff_t *offset) + size_t length, loff_t *offset) { struct wmi_block *wblock = filp->private_data; @@ -1226,8 +1227,8 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device) */ static acpi_status acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, - u32 bits, u64 *value, - void *handler_context, void *region_context) + u32 bits, u64 *value, + void *handler_context, void *region_context) { int result = 0, i = 0; u8 temp = 0; From patchwork Sat Sep 4 17:56:16 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: 12475751 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 C22A6C433F5 for ; Sat, 4 Sep 2021 17:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4B7E60F3A for ; Sat, 4 Sep 2021 17:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237305AbhIDR51 (ORCPT ); Sat, 4 Sep 2021 13:57:27 -0400 Received: from mail2.protonmail.ch ([185.70.40.22]:61948 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR51 (ORCPT ); Sat, 4 Sep 2021 13:57:27 -0400 Date: Sat, 04 Sep 2021 17:56:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778184; bh=usYv9jVm/hIKSq/VPgEeLOSCsUDFEddgbdKUwOwH+cQ=; h=Date:To:From:Reply-To:Subject:From; b=jMlAcEgbLCW6XYmQn5mtoiRz5rXNAOtD26ZPEoaSw8ZzTtz659uUX7Sqn3J8gSCce f4HhjTB9yjc47LkzyQhbORHDI6BtsEeoAizkD5vAbCQeZLmGzeaJl2YJb+c5DqoQTh ScWpLW7bHYFJZRitpWb48S6yzIQa+kPOhLVkK9Wc= 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 23/30] platform/x86: wmi: improve debug messages Message-ID: <20210904175450.156801-24-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Print the event identifier number in addition to the already printed information, and use %u for printing unsigned values in `wmi_notify_debug()`. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index fcc867d79e91..ec5ba2970840 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -485,10 +485,10 @@ static void wmi_notify_debug(u32 value, void *context) if (!obj) return; - pr_info("DEBUG Event "); + pr_info("DEBUG: event 0x%02X ", value); switch (obj->type) { case ACPI_TYPE_BUFFER: - pr_cont("BUFFER_TYPE - length %d\n", obj->buffer.length); + pr_cont("BUFFER_TYPE - length %u\n", obj->buffer.length); break; case ACPI_TYPE_STRING: pr_cont("STRING_TYPE - %s\n", obj->string.pointer); @@ -497,7 +497,7 @@ static void wmi_notify_debug(u32 value, void *context) pr_cont("INTEGER_TYPE - %llu\n", obj->integer.value); break; case ACPI_TYPE_PACKAGE: - pr_cont("PACKAGE_TYPE - %d elements\n", obj->package.count); + pr_cont("PACKAGE_TYPE - %u elements\n", obj->package.count); break; default: pr_cont("object type 0x%X\n", obj->type); From patchwork Sat Sep 4 17:56:26 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: 12475753 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 6A356C433EF for ; Sat, 4 Sep 2021 17:56:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B7C560F51 for ; Sat, 4 Sep 2021 17:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237320AbhIDR5i (ORCPT ); Sat, 4 Sep 2021 13:57:38 -0400 Received: from mail-4322.protonmail.ch ([185.70.43.22]:36185 "EHLO mail-4322.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR5i (ORCPT ); Sat, 4 Sep 2021 13:57:38 -0400 Date: Sat, 04 Sep 2021 17:56:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778195; bh=bYrWE5J1d/UXgeba5aFcYrMsGmVzAnYYqLg6oDZgVic=; h=Date:To:From:Reply-To:Subject:From; b=Z34r2xLvR7ALt1Wpcgrqud3Eglg93Fl6AKWt6ci6Dihzm3tk4pKW468I6t2NYn9hE sjxlDT5+eGdg/vVd6E8nDKfAXtTa6ppKEgHD5QooPVvbjQjwVh8aW9k9rOjJy9oGRU gEAbKKE8pVoWkOJDCpide4XWG3ZTb5sJfz3fNaY8= 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 24/30] platform/x86: wmi: do not fail if disabling fails Message-ID: <20210904175450.156801-25-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Previously, `__query_block()` would fail if the second WCxx method call failed. However, the WQxx method might have succeded, and potentially allocated memory for the result. Instead of throwing away the result and potentially leaking memory, ignore the result of the second WCxx call. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index ec5ba2970840..5929d9d26801 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -352,7 +352,14 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance, * the WQxx method failed - we should disable collection anyway. */ if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) { - status = acpi_execute_simple_method(handle, wc_method, 0); + /* + * Ignore whether this WCxx call succeeds or not since + * the previously executed WQxx method call might have + * succeeded, and returning the failing status code + * of this call would throw away the result of the WQxx + * call, potentially leaking memory. + */ + acpi_execute_simple_method(handle, wc_method, 0); } return status; From patchwork Sat Sep 4 17:56:29 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: 12475757 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 A86FCC433FE for ; Sat, 4 Sep 2021 17:56:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B51360F51 for ; Sat, 4 Sep 2021 17:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237329AbhIDR5n (ORCPT ); Sat, 4 Sep 2021 13:57:43 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:53134 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR5n (ORCPT ); Sat, 4 Sep 2021 13:57:43 -0400 Date: Sat, 04 Sep 2021 17:56:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778198; bh=RYOXG0qlglXvaCyoOCoFByGdbmkQSzXOGgZbrvxTvsE=; h=Date:To:From:Reply-To:Subject:From; b=M/9nFIyjSsKbrvwHMA93yAVNYteAcdp7rzX3kk0EAUyaitVM7C67oHxqQCG1e6lex ES/Z+rTBRkwYfjue/oqMbnUWssbGAHG+aJg6JCbP+RiBViIzJWkWW5Tl2xIlR2NLQJ 0/uySG0/0Wah66heDBkXeVGvweuL3YLpopQWjC0I= 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 25/30] platform/x86: wmi: simplify error handling logic Message-ID: <20210904175450.156801-26-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The current code carries out the following ACPI status mapping: AE_NOT_FOUND -> AE_OK AE_OK -> AE_OK AE_$X -> AE_$X That is, everything is mapped to itself, except AE_NOT_FOUND. The current code does not do it in the most straighforward way. Simplify the logic. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 5929d9d26801..ea7154160946 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -189,11 +189,10 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, bool enable) snprintf(method, sizeof(method), "WE%02X", block->notify_id); status = acpi_execute_simple_method(handle, method, enable); - - if (status != AE_OK && status != AE_NOT_FOUND) - return status; - else + if (status == AE_NOT_FOUND) return AE_OK; + + return status; } /* From patchwork Sat Sep 4 17:56:32 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: 12475755 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 9FF6FC433F5 for ; Sat, 4 Sep 2021 17:56:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A22B60F51 for ; Sat, 4 Sep 2021 17:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237326AbhIDR5m (ORCPT ); Sat, 4 Sep 2021 13:57:42 -0400 Received: from mail-40136.protonmail.ch ([185.70.40.136]:61780 "EHLO mail-40136.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR5k (ORCPT ); Sat, 4 Sep 2021 13:57:40 -0400 Date: Sat, 04 Sep 2021 17:56:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778197; bh=QfzVJOVBkRRwwshU93w33mZkxU1oSQz+eJPHse1AB04=; h=Date:To:From:Reply-To:Subject:From; b=GSDDOJJEmhSS1w7y5L3Pne8Iaf1/Md/bcmugCKOo8fLN05CFzIN4kmMRRUQquE3yS EZF7AAPh62V7WAlpK8AoYW2fyOQ9bzjMlggxiCj5g2LLVEVHCL/VUHwDSVVK4YI/bV 9nGkNyR0xwHRZDKAAgsL5i5x7U1gVBJK/IgHBELM= 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 26/30] platform/x86: wmi: introduce helper to convert driver to WMI driver Message-ID: <20210904175450.156801-27-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Introduce a helper function which wraps the appropriate `container_of()` macro invocation to convert a `struct device_driver` to `struct wmi_driver`. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index ea7154160946..ff33ad2053f0 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -673,6 +673,11 @@ static struct wmi_device *dev_to_wdev(struct device *dev) return container_of(dev, struct wmi_device, dev); } +static inline struct wmi_driver *drv_to_wdrv(struct device_driver *drv) +{ + return container_of(drv, struct wmi_driver, driver); +} + /* * sysfs interface */ @@ -791,8 +796,7 @@ static void wmi_dev_release(struct device *dev) static int wmi_dev_match(struct device *dev, struct device_driver *driver) { - struct wmi_driver *wmi_driver = - container_of(driver, struct wmi_driver, driver); + struct wmi_driver *wmi_driver = drv_to_wdrv(driver); struct wmi_block *wblock = dev_to_wblock(dev); const struct wmi_device_id *id = wmi_driver->id_table; @@ -889,8 +893,7 @@ static long wmi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } /* let the driver do any filtering and do the call */ - wdriver = container_of(wblock->dev.dev.driver, - struct wmi_driver, driver); + wdriver = drv_to_wdrv(wblock->dev.dev.driver); if (!try_module_get(wdriver->driver.owner)) { ret = -EBUSY; goto out_ioctl; @@ -923,8 +926,7 @@ static const struct file_operations wmi_fops = { static int wmi_dev_probe(struct device *dev) { struct wmi_block *wblock = dev_to_wblock(dev); - struct wmi_driver *wdriver = - container_of(dev->driver, struct wmi_driver, driver); + struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); int ret = 0; char *buf; @@ -987,8 +989,7 @@ static int wmi_dev_probe(struct device *dev) static void wmi_dev_remove(struct device *dev) { struct wmi_block *wblock = dev_to_wblock(dev); - struct wmi_driver *wdriver = - container_of(dev->driver, struct wmi_driver, driver); + struct wmi_driver *wdriver = drv_to_wdrv(dev->driver); if (wdriver->filter_callback) { misc_deregister(&wblock->char_dev); @@ -1290,15 +1291,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; + 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; - driver = container_of(wblock->dev.dev.driver, - struct wmi_driver, driver); - input.count = 1; input.pointer = params; params[0].type = ACPI_TYPE_INTEGER; From patchwork Sat Sep 4 17:56:35 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: 12475761 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 C5336C433EF for ; Sat, 4 Sep 2021 17:56:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B375C60F56 for ; Sat, 4 Sep 2021 17:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237334AbhIDR5r (ORCPT ); Sat, 4 Sep 2021 13:57:47 -0400 Received: from mail-0301.mail-europe.com ([188.165.51.139]:55162 "EHLO mail-0301.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR5r (ORCPT ); Sat, 4 Sep 2021 13:57:47 -0400 Date: Sat, 04 Sep 2021 17:56:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778202; bh=1JuGZtWbEyLbOtMIRxVOBDmGks9yhQamvsxhZwQ5oJs=; h=Date:To:From:Reply-To:Subject:From; b=oiJT9uGEzaKTssh5Bx1zfw56+3nlvRNB9HZBTjMJranpYEOdi/PDLmzuoWWLtz/jR jZsdj45e2NzbfgWVP7LlpG9oQR4ElH8ww4Ln4Oiad7P7KZbhJB/MffnBW1G8F/Gf11 BPc+rVl1aenehPJDRnnCVcKEpzh9XO02aqu4DiDU= 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 27/30] platform/x86: wmi: introduce helper to generate method names Message-ID: <20210904175450.156801-28-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Instead of "manually" constructing the ACPI method name and hard-coding sizes in WMI functions, introduce a helper method which generates the method name for an arbitrary WMI block. Furthermore, save the appropriate buffer size into a macro. Signed-off-by: Barnabás Pőcze --- drivers/platform/x86/wmi.c | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index ff33ad2053f0..4f484677759b 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -195,6 +195,22 @@ static acpi_status wmi_method_enable(struct wmi_block *wblock, bool enable) return status; } +#define WMI_ACPI_METHOD_NAME_SIZE 5 + +static inline void get_acpi_method_name(const struct wmi_block *wblock, + const char method, + char buffer[static WMI_ACPI_METHOD_NAME_SIZE]) +{ + static_assert(ARRAY_SIZE(wblock->gblock.object_id) == 2); + static_assert(WMI_ACPI_METHOD_NAME_SIZE >= 5); + + buffer[0] = 'W'; + buffer[1] = method; + buffer[2] = wblock->gblock.object_id[0]; + buffer[3] = wblock->gblock.object_id[1]; + buffer[4] = '\0'; +} + /* * Exported WMI functions */ @@ -257,7 +273,7 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met acpi_handle handle; struct acpi_object_list input; union acpi_object params[3]; - char method[5] = "WM"; + char method[WMI_ACPI_METHOD_NAME_SIZE]; wblock = container_of(wdev, struct wmi_block, dev); block = &wblock->gblock; @@ -288,7 +304,7 @@ acpi_status wmidev_evaluate_method(struct wmi_device *wdev, u8 instance, u32 met params[2].buffer.pointer = in->pointer; } - strncat(method, block->object_id, 2); + get_acpi_method_name(wblock, 'M', method); return acpi_evaluate_object(handle, method, &input, out); } @@ -302,8 +318,8 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance, acpi_status status, wc_status = AE_ERROR; struct acpi_object_list input; union acpi_object wq_params[1]; - char method[5]; - char wc_method[5] = "WC"; + char wc_method[WMI_ACPI_METHOD_NAME_SIZE]; + char method[WMI_ACPI_METHOD_NAME_SIZE]; if (!out) return AE_BAD_PARAMETER; @@ -331,7 +347,7 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance, * enable collection. */ if (block->flags & ACPI_WMI_EXPENSIVE) { - strncat(wc_method, block->object_id, 2); + get_acpi_method_name(wblock, 'C', wc_method); /* * Some GUIDs break the specification by declaring themselves @@ -341,9 +357,7 @@ static acpi_status __query_block(struct wmi_block *wblock, u8 instance, wc_status = acpi_execute_simple_method(handle, wc_method, 1); } - strcpy(method, "WQ"); - strncat(method, block->object_id, 2); - + get_acpi_method_name(wblock, 'Q', method); status = acpi_evaluate_object(handle, method, &input, out); /* @@ -415,7 +429,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, acpi_handle handle; struct acpi_object_list input; union acpi_object params[2]; - char method[5] = "WS"; + char method[WMI_ACPI_METHOD_NAME_SIZE]; if (!guid_string || !in) return AE_BAD_DATA; @@ -446,7 +460,7 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, params[1].buffer.length = in->length; params[1].buffer.pointer = in->pointer; - strncat(method, block->object_id, 2); + get_acpi_method_name(wblock, 'S', method); return acpi_evaluate_object(handle, method, &input, NULL); } @@ -1040,7 +1054,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, struct acpi_device *device) { struct acpi_device_info *info; - char method[5]; + char method[WMI_ACPI_METHOD_NAME_SIZE]; int result; if (wblock->gblock.flags & ACPI_WMI_EVENT) { @@ -1059,8 +1073,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, * required per the WMI documentation. If it is not present, * we ignore this data block. */ - strcpy(method, "WQ"); - strncat(method, wblock->gblock.object_id, 2); + get_acpi_method_name(wblock, 'Q', method); result = get_subobj_info(device->handle, method, &info); if (result) { @@ -1087,8 +1100,7 @@ static int wmi_create_device(struct device *wmi_bus_dev, kfree(info); - strcpy(method, "WS"); - strncat(method, wblock->gblock.object_id, 2); + get_acpi_method_name(wblock, 'S', method); result = get_subobj_info(device->handle, method, NULL); if (result == 0) 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; 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; } From patchwork Sat Sep 4 17:56:44 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: 12475765 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 18EBEC433F5 for ; Sat, 4 Sep 2021 17:56:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0D1B60F56 for ; Sat, 4 Sep 2021 17:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237247AbhIDR54 (ORCPT ); Sat, 4 Sep 2021 13:57:56 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:17734 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237178AbhIDR5z (ORCPT ); Sat, 4 Sep 2021 13:57:55 -0400 Date: Sat, 04 Sep 2021 17:56:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1630778212; bh=Lz30czYvQEjqIFQgwmtlqVRJWRZbQdHgeIDs0fZKPXI=; h=Date:To:From:Reply-To:Subject:From; b=izpsE9bT+sqGsngYWq0C4r4BpcjfKusTzxVKaSuVkwBdyNHthrOluOlZaKLzRQTZH 8Y95z/zVrw93zzXhiMmO+r9XMeJ2PjSL1HdXd1xBNjBWNGb4vz4RXs0fwlIXrfzGpJ ZIjd+bcu0oKUskPQVYtbGzMDAcpEJHVv+PlcOlqw= 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 30/30] platform/x86: wmi: more detailed error reporting in find_guid() Message-ID: <20210904175450.156801-31-pobrn@protonmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org 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 --- drivers/platform/x86/wmi.c | 43 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 16 deletions(-) -- 2.33.0 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index cd274de78ab4..6afe67684eef 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; + 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; + 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);