Message ID | 20230430203153.5587-2-W_Armin@gmx.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;rbbytesnap@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <W_Armin@gmx.de> 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.5587-1-W_Armin@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:AwcIKrVVrreL86dR0hx2hTjHbeTrBLyyjSg2gzhh4/7Vo+rpogQ JyRxm+Bq/vfXVZy2ljyT2FKofSxdFZnct1XtTgmCcgs7YAgCzcKM5C7jJe/n4LEbha79YwG 79wOUIhC1BiMTizVZyTkmFHt9WZ0Eo/jVOFOLamwQ71SM2vsTU1V3GZN7xq9YKwXeZm+Ugn oD7xoB0/gCmjS5fPPsZmQ== UI-OutboundReport: notjunk:1;M01:P0:/l2yjb/EBL4=;qJ0RQ6tlfkJXHORn0kU6joV4cSa QSNT1CbNDCZOnlgSoeffOg+Vu3ZChits8cV8YuDryTclZfqVoT2VMN32Pt7c6vK3a1FJ604PY W7b6YNTCUWB6rOAThK1LNkQYvxZBWfLZkAR9Xg3ReVbwYISBUSswk5OEsK+j5LCHLL71aE2/s NQMF22OtP96xQ9YEBA8ylSM/ZUGISGWW0Eu/q9UDOeSQKuXrAQDUE8h6GsDFfrbgfarSqGAXc 7tavvI0n0IUxFY4XBNE+fBV4K/Hcf/+MA0e6Ew40oZKheuDyBy2CPA2/MLYrRhsqZqTvRT3nI H3ik6sifOkZmv6P5S6sFhIlqWNUqg3EIB+m7lXWb0iWnHBDC1U7z+WOgm6VDLDHQvOaqgnXLU 7RxuUMboJ55X0BKqZU9aMtDanQU+dTwg41yAMfH4JOglAxZ35QwLil2gjTkQ12BpAaDvcxnDw QaHcKP4p1M9Zzjzdi5id38Kt8C+HeZiWCpvVSrDhMgpKLoiMJnvne/FVoWmHl7SB9/9WKTwRK kKhm82mG5/2R+q9fN7Ib548sB0cFR5Rp0r4Lf3owBxUlY0nlwN5PwJLAQybsDQOXY1CrUGj6E pIOt7QOwOOiw97nfm7ka2l8N99MUA3smOMBTWk/KQgKbaVssSYflC/HwX4aF0TH987fYAN4Sh g5gQ95qcchD0Uz74HlH0akY4GAERlPMQID0L6kW7VNTeabQuUbnvQNWDvwoKdlICAZyqFskAo KLl3dB6mgvIGAWfmpra70oUomyRnVadk+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: <linux-kernel.vger.kernel.org> 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?= |
Series |
platform/x86: Allow retrieving the number of WMI object instances
|
|
Commit Message
Armin Wolf
April 30, 2023, 8:31 p.m. UTC
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 <W_Armin@gmx.de>
---
drivers/platform/x86/wmi.c | 41 ++++++++++++++++++++++++++++++++++++++
include/linux/acpi.h | 2 ++
include/linux/wmi.h | 2 ++
3 files changed, 45 insertions(+)
--
2.30.2
Comments
Hi Armin, On 4/30/23 22:31, Armin Wolf wrote: > 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 <W_Armin@gmx.de> Thank you for your work on this. > --- > drivers/platform/x86/wmi.c | 41 ++++++++++++++++++++++++++++++++++++++ > include/linux/acpi.h | 2 ++ > include/linux/wmi.h | 2 ++ > 3 files changed, 45 insertions(+) > > 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; Maybe just return 0 here ? The GUID not existing at all does not seem like an error to me, but rather a case of there being 0 instances. This will also allow patch 2/2 to completely drop the get_instance_count() function and replace its callers with direct calls to wmi_instance_count() as the code is known to always pass a valid GUID, so it won't hit the -EINVAL path. Regards, Hans > + } > + > + 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); > > /** > -- > 2.30.2 >
Am 30.04.23 um 22:41 schrieb Hans de Goede: > Hi Armin, > > On 4/30/23 22:31, Armin Wolf wrote: >> 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 <W_Armin@gmx.de> > Thank you for your work on this. > >> --- >> drivers/platform/x86/wmi.c | 41 ++++++++++++++++++++++++++++++++++++++ >> include/linux/acpi.h | 2 ++ >> include/linux/wmi.h | 2 ++ >> 3 files changed, 45 insertions(+) >> >> 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; > Maybe just return 0 here ? > > The GUID not existing at all does not seem like > an error to me, but rather a case of there > being 0 instances. > > This will also allow patch 2/2 to completely > drop the get_instance_count() function and > replace its callers with direct calls to > wmi_instance_count() as the code is known > to always pass a valid GUID, so it won't hit > the -EINVAL path. > > Regards, > > Hans > Hi, i would prefer returning -ENODEV instead of 0, so WMI drivers can distinguish between "not found" and "zero instances". Also i do not think that relying on the parameter of get_instance_count() always being a valid GUID is a good idea, just in case wmi_instance_count() is later modified to be able to encounter runtime errors. Armin Wolf > >> + } >> + >> + 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); >> >> /** >> -- >> 2.30.2 >>
Hi, On 4/30/23 23:01, Armin Wolf wrote: > Am 30.04.23 um 22:41 schrieb Hans de Goede: > >> Hi Armin, >> >> On 4/30/23 22:31, Armin Wolf wrote: >>> 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 <W_Armin@gmx.de> >> Thank you for your work on this. >> >>> --- >>> drivers/platform/x86/wmi.c | 41 ++++++++++++++++++++++++++++++++++++++ >>> include/linux/acpi.h | 2 ++ >>> include/linux/wmi.h | 2 ++ >>> 3 files changed, 45 insertions(+) >>> >>> 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; >> Maybe just return 0 here ? >> >> The GUID not existing at all does not seem like >> an error to me, but rather a case of there >> being 0 instances. >> >> This will also allow patch 2/2 to completely >> drop the get_instance_count() function and >> replace its callers with direct calls to >> wmi_instance_count() as the code is known >> to always pass a valid GUID, so it won't hit >> the -EINVAL path. >> >> Regards, >> >> Hans >> > Hi, > > i would prefer returning -ENODEV instead of 0, so WMI drivers can > distinguish between "not found" and "zero instances". Ah right, that is a good point, ok lets keep this as is then. Regards, Hans > Also i do not > think that relying on the parameter of get_instance_count() always > being a valid GUID is a good idea, just in case wmi_instance_count() > is later modified to be able to encounter runtime errors. > > Armin Wolf > >> >>> + } >>> + >>> + 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); >>> >>> /** >>> -- >>> 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); /**