From patchwork Sun Apr 30 20:31:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 88953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2317186vqo; Sun, 30 Apr 2023 13:37:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JJ6M82f5c/qu5Wouo6SbFBnHBPtZpwG0nBudOQZAtzxWbs+lNL8pfr08luogQ9qLK6XKj X-Received: by 2002:a17:902:ec87:b0:1a9:bb48:2aae with SMTP id x7-20020a170902ec8700b001a9bb482aaemr13554509plg.52.1682887036473; Sun, 30 Apr 2023 13:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682887036; cv=none; d=google.com; s=arc-20160816; b=bc0tsh98JJWSL2wjYegK/bP2+j1Ugi/bS6r6XnlXqrvctYZvkYMBvekebe0tnnYg6c X2ZMA+QI6jh7FmDYeaRktdZ2jDSLgkg88k5Kx3/0PGVmGHr8k2vgyrwsUiV5Tb3IanYf H7J9OZMHPdgEgCSLjh/Lr/ZC2liFIsr76qD4gQfE5/qRrcTCB5qyJyQx+9OPXm9AXif9 UT1QZHo5ZSkB4apl8H3BxjumQJ8etsB9LCE49dsS5KCH1KiMfS7yEylRdc5sTABZtYU6 JEawOAuBmgSzd76y0+OYbAi8PEELsLe3GRp4YYiDf0FtW2ige64tP1oY9lSKF44kcUCx YWFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tFiEAKX548xrvSLXyf4XS9LXFQajMNMrqjjYbg3F8xI=; b=BYyzo+ENuUVZZBtrBhdloyhyeyZBOqu3lZhI6XsYMXhG/c1fyEjsW97dzbKwx4Llwo LMy+TK93JZrISLYqt3ogQOx9A4xdvUa55dYCBRIN2dhMRHW3ggEvc3UWTob12jXdNE1C 23mHRILRAsS8oZOjxMhSquYbo+U+7odicxLQvqt+qOl90xuR5Ged8mktsYd4dPfSI/nc 41n2856HK4LmbC/5R/SefkCBuKfzWOfHNVrVrg3goq3dCEJaEmKyG1S+s2F518Bibn+G yYAMNXHHqoRjb/yMExOlZ/YwqP5XwB5HoDRUouVj2lsTXf2aS40BmrkYIjAsSkeQRGF3 3NSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Ot5VIA3e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a170902e74800b001a966042af8si21268944plf.341.2023.04.30.13.37.04; Sun, 30 Apr 2023 13:37:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Ot5VIA3e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232091AbjD3UcW (ORCPT + 99 others); Sun, 30 Apr 2023 16:32:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbjD3UcU (ORCPT ); Sun, 30 Apr 2023 16:32:20 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE38E66; Sun, 30 Apr 2023 13:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682886718; i=w_armin@gmx.de; bh=l+0GCKeRezQc9Ws6Rvy4yCiDFaJROwJiUsltiicCshI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Ot5VIA3e51ahXhG/JA7GtZHVBY4qL03lZjHt2kUKH8LOYHMGVuJXZnt7FYVhQ8cA9 HGPxPxv+l5VcptOBp7j/jM3zP1Cs6RMyefD9cqEEQ8NqOmdcS/ZxiS3Di0EMbJScIj GXDnJ+BCMRcn83JMBgy1tZ2ZWVUpmf5oG+Na7DkdUo48wcSOGST6DLYjaCGbk2ZAeO 0yFGc6fv7CpJUb89K49mH4jm7TUQmBgJcfA87zKTLYP6DK2XslI5wcNTsGgnsV54/d kPl9y0unZO1hy5pmoj5CAdBHnwkiw9nGJfbW1eIVrMRpfXW6NhRO2mAa+C0Vzyg11H O5IKua3mbo/oQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MK3Rs-1pXia02pZO-00LSM3; Sun, 30 Apr 2023 22:31:58 +0200 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: Mario.Limonciello@amd.com, prasanth.ksr@dell.com, jorgealtxwork@gmail.com, james@equiv.tech, Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] platform/x86: wmi: Allow retrieving the number of WMI object instances Date: Sun, 30 Apr 2023 22:31:52 +0200 Message-Id: <20230430203153.5587-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230430203153.5587-1-W_Armin@gmx.de> References: <20230430203153.5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B6mgvIGAWfmpra70oUomyRnVadk+1lzWUoHBkx9t2vk1QVaSOAgZcqPPVlJyaaqIN1as FVspd9wduL842uQd1zrISx3hTOlv9pGtj/Fgh4IrmvjG0/HfN0sFH/8QCX814E+kgub79rDjZ swHNnBzkeGABk2S0DVYC1JbEHH7HWAHr3NS+xHrzn26E/Ph+iNDFdAwFG3jBmQ7e8M82syGy4 hDwy9LcYmSA2BKTjOgnP0/vtsSg= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764634957283539781?= X-GMAIL-MSGID: =?utf-8?q?1764634957283539781?= Currently, the WMI driver core knows how many instances of a given WMI object exist, but WMI drivers cannot access this information. At the same time, some current and upcoming WMI drivers want to have access to this information. Add wmi_instance_count() and wmidev_instance_count() to allow WMI drivers to get the number of WMI object instances. Signed-off-by: Armin Wolf --- drivers/platform/x86/wmi.c | 41 ++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 2 ++ include/linux/wmi.h | 2 ++ 3 files changed, 45 insertions(+) -- 2.30.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index c226dd4163a1..5b95d7aa5c2f 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -263,6 +263,47 @@ int set_required_buffer_size(struct wmi_device *wdev, u64 length) } EXPORT_SYMBOL_GPL(set_required_buffer_size); +/** + * wmi_instance_count - Get number of WMI object instances + * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba + * + * Get the number of WMI object instances. + * + * Returns: Number of WMI object instances or negative error code. + */ +int wmi_instance_count(const char *guid_string) +{ + struct wmi_block *wblock; + acpi_status status; + + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) { + if (status == AE_BAD_PARAMETER) + return -EINVAL; + + return -ENODEV; + } + + return wmidev_instance_count(&wblock->dev); +} +EXPORT_SYMBOL_GPL(wmi_instance_count); + +/** + * wmidev_instance_count - Get number of WMI object instances + * @wdev: A wmi bus device from a driver + * + * Get the number of WMI object instances. + * + * Returns: Number of WMI object instances. + */ +u8 wmidev_instance_count(struct wmi_device *wdev) +{ + struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev); + + return wblock->gblock.instance_count; +} +EXPORT_SYMBOL_GPL(wmidev_instance_count); + /** * wmi_evaluate_method - Evaluate a WMI method (deprecated) * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba diff --git a/include/linux/acpi.h b/include/linux/acpi.h index efff750f326d..e52bf2742eaf 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -412,6 +412,8 @@ extern bool acpi_is_pnp_device(struct acpi_device *); typedef void (*wmi_notify_handler) (u32 value, void *context); +int wmi_instance_count(const char *guid); + extern acpi_status wmi_evaluate_method(const char *guid, u8 instance, u32 method_id, const struct acpi_buffer *in, diff --git a/include/linux/wmi.h b/include/linux/wmi.h index c1a3bd4e4838..763bd382cf2d 100644 --- a/include/linux/wmi.h +++ b/include/linux/wmi.h @@ -35,6 +35,8 @@ extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev, extern union acpi_object *wmidev_block_query(struct wmi_device *wdev, u8 instance); +u8 wmidev_instance_count(struct wmi_device *wdev); + extern int set_required_buffer_size(struct wmi_device *wdev, u64 length); /** From patchwork Sun Apr 30 20:31:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 88954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2319257vqo; Sun, 30 Apr 2023 13:44:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xJKaoqAykuQtCnR5ii3J2HANrnNa0MFBZY/aWK35LQlaX5Lo0JcZDk0QbXp9N7Cw2tNB9 X-Received: by 2002:a17:902:e742:b0:1a6:5fdf:6555 with SMTP id p2-20020a170902e74200b001a65fdf6555mr14003275plf.50.1682887465675; Sun, 30 Apr 2023 13:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682887465; cv=none; d=google.com; s=arc-20160816; b=Fg+tDFX6ihrDYJ3BQh5EJnfctrT0V6uWtm06aJ/AQ0HxV9fUNMCuD/IYHRyz3pg7Un N/Jcm3L+93ohvT28X765p8YANAPhQT2qrLdqqCHZjre3qnm+ELPCvLnlVFJyaIkkelaM R/2fOXfibIaD+f7tyjhqoEuG1lPVB91ZbEBhg893wO95xw+AnmNc2OIab9M4fAiY/adl b9aF1wkJJ09GnO/fGd8QZv9bZS40zosYKYuAgo8UEWvt5F8dtaWFNJbOxZKILk5tovtA D479J+EHTUp4D6YdTnVU9mgAsf4vR0nTFcP2KTn+9R1JwmfE2gDSfy3X95lkHmk7XJoM EOQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CNqf+f5zPBZWFdmnoftG1VLGnEP2nTg13y+gdrs0vKg=; b=AQ3cruB/QoeA1k8ZWYeL69lesqNRwcGJYbx//+uXdqqNEQZFk+3HHmMFKOcYMFJ7XC MKfi7kJLbH6fnX00QsXrGjNYz7kS4GNpoDsMfJY1B0w2f0oqdJ/jBg6OPBMd6L59zicc fyEGpfq3HETJe7q6c7BXy6Inr0AD6Got9k0fh7JETGJlHkZnVlNMuCcjC4c1tqr1T5Ye ZzCnS8kYfjJ9sbCiK4bDHl5sBW6j0aKyy6EOhL871S8/IGgAumw/2mrXBH804kimL3mb vjZRZKyhs1kryNTF+WACe+/MRTnzHNu3u2RTysR4peUhvycS6b+QKXuv2OZb5mlbAgG1 ptCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=U33PiAca; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb14-20020a170903338e00b001a8096ef2bfsi25045146plb.34.2023.04.30.13.44.11; Sun, 30 Apr 2023 13:44:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=U33PiAca; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232140AbjD3Uc1 (ORCPT + 99 others); Sun, 30 Apr 2023 16:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232076AbjD3UcW (ORCPT ); Sun, 30 Apr 2023 16:32:22 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89870E65; Sun, 30 Apr 2023 13:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682886721; i=w_armin@gmx.de; bh=EDo2jyGRTWwJyIb6T+IdrYD2Dz8qhCqNBIDZC2iaYVA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=U33PiAca2JeFTgN/u/vb5rZINcXOpDlaWODV6mwUxBp3Bghm46CUkJIzz549t68Zc 2X4LxGE1841PwxFs7/Audbqa7Lre8/PQUQ6REiY5R92TgrqSV7rj6CQmV75BFh21k0 6rXWpcPItLQF1mKwsM39WbVZgTZ+Gm/fbrylVPQzSaqFesUrQEHDINURcqWBrAlHEE c+FJPtf4PZICB7LnmnD+Wh9FvFkPZpgDUxnNpV5Hq0n2mP7hjp8TQuOIVFky3g/XQu xMEeMEJ13fb+3uu2BS4WVIAaYSRKA2njj3WaXYpjpUZd/Yw+89EJoRE+q7VSaqN6Vx X+HoyxqQBn29A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mr9Bu-1qdr0x0mnO-00oEk4; Sun, 30 Apr 2023 22:32:01 +0200 From: Armin Wolf To: hdegoede@redhat.com, markgross@kernel.org Cc: Mario.Limonciello@amd.com, prasanth.ksr@dell.com, jorgealtxwork@gmail.com, james@equiv.tech, Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] platform/x86: dell-sysman: Improve instance detection Date: Sun, 30 Apr 2023 22:31:53 +0200 Message-Id: <20230430203153.5587-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230430203153.5587-1-W_Armin@gmx.de> References: <20230430203153.5587-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:xDqp28RbQ9gdl4+mJCz5HykoBlx+oHBru64jsoI2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Sis/F8BN28Y3GHPoGh0y/C+pjeibs0hfomBRSI1SE/6 gFqENXFT5Atcp9u34n/duA0FlhEHoMV0N3XbqRE/bAR1zlC7fCgR2kMbygYNseaVuBgWJzQcO hF6HZp/uwoR+6jGLzgFnQsTt3MM= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764635407098572058?= X-GMAIL-MSGID: =?utf-8?q?1764635407098572058?= The WMI driver core already knows how many WMI object instances are available, use this information instead of probing the WMI object manually. Compile-tested only. Signed-off-by: Armin Wolf --- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.30.2 diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c index 0285b47d99d1..b68dd11cb892 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c @@ -303,16 +303,13 @@ union acpi_object *get_wmiobj_pointer(int instance_id, const char *guid_string) */ int get_instance_count(const char *guid_string) { - union acpi_object *wmi_obj = NULL; - int i = 0; + int ret; - do { - kfree(wmi_obj); - wmi_obj = get_wmiobj_pointer(i, guid_string); - i++; - } while (wmi_obj); + ret = wmi_instance_count(guid_string); + if (ret < 0) + return 0; - return (i-1); + return ret; } /**