From patchwork Wed Apr 26 21:03:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 87985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp510083vqo; Wed, 26 Apr 2023 14:15:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YHbEmt4yQSzCBTSuzEw154VUuZAPDdGMy8VT9sCWxv1G33+6gy2hsAN5Paq8OVB/mdt/59 X-Received: by 2002:a17:90a:cd06:b0:247:603a:bd60 with SMTP id d6-20020a17090acd0600b00247603abd60mr21156253pju.45.1682543758586; Wed, 26 Apr 2023 14:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682543758; cv=none; d=google.com; s=arc-20160816; b=dZipSoDZ28DbrKQVoPoQttZzwGA6cjP6MjCU9qLyZumfPkjFKql/4PoPLsfnuVaowc 9qQr/S+q6y7ZiKFkvCtca6Ru4NUdVKdB9Gv6Slb4nVCPPNZuZgq02QnEAQUzPVgblMln VKXxXYF40h/KTpcDqnU6m80iWsnr/r8gUv3b/j7qAqiY2RqGKfqL2t5zTl0JB/5VWdVy PY5hTDfdl2KbUJ9MLAHS2+6S3GnGU5WeLRUaka3gPROrklwd7L1F6Rbsc9HIIh2g3Ge6 aKGafqcXdi8NTfDVAMeyw/ZtTHxywsIt4+HntXKYP8FGMDewaVWglNDww91ovcT/jNZL g1Vg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=NlCtZCWJk00XcmpY7mjl7ud+19dOFERAGe9N+5rmtQ8=; b=ziEtGwTtzZEounmFPP235lrCxrRzskF/3ice83mAYswjOppCkIO5SmpyKDf8E+8hp5 L5G/tMaNElJ/o8ag8PAgwzpkUiDOjszCTCKlCrzkyzP4j8sMPyC2l/rKYwYHT++Pj3ZJ IfjKlLGhrYgSVPHwjmABHj3v25myqGWe3+8JVhW3/hiotqLlRrtSa6RQMxDx8/5frj0C Hr3We9AWPGtqtCvsn+8NO90+mjRem0P8zpGVFqK7r295XIuC6PSFTZKO3UA8XRI0ft2Z 0Wb9ua2FLhV2vPEO4gPd3xWQPptvMpXP37raIywAfnntytIK7b2o/NFQVrG77ELYO3Xd Ab0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="bTmI/9f4"; 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 n8-20020a17090a9f0800b00247af6f0497si16874153pjp.21.2023.04.26.14.15.43; Wed, 26 Apr 2023 14:15:58 -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="bTmI/9f4"; 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 S239964AbjDZVEp (ORCPT + 99 others); Wed, 26 Apr 2023 17:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239869AbjDZVEl (ORCPT ); Wed, 26 Apr 2023 17:04:41 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC392118; Wed, 26 Apr 2023 14:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1682543036; i=w_armin@gmx.de; bh=/NvD9oCO/r0GrFnR01vAe+1hQd5sbYS115i1sHjdYVU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=bTmI/9f4BZxjfDmLTJ2FL8gFdxZuVkBIZZa/2ZDoZZA2z6A0dUzRKxVWoF+Ui7ZjN LlqBT8AOiCR7D4PO063jKlFa0cU+QDvTqnnenTsfwLXxIZvg8WryAW9UjUJOccIhpw YocFZfXBqakl7OIEklDOyFvudY1omh0lnYRFNeqiHKbo+1mKOIPlIWSR1et7FlRkTP 7MvwPW0Gd7Q+d02g5n8YGHU0dZJ1rAElWStcYkqWPS64nkP2dHCaYk52LMkIsPXUMr ZxJfyyUlwgP0ygMkdUyEWTMfV5crilMOXxk/wHl004Zs+5IQi+nVHmTrw/MIvLvYUb faZ8SoQJ9O/uA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MZTqW-1pp7Xx43Ms-00WUCY; Wed, 26 Apr 2023 23:03:56 +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: [RFC] platform/x86: wmi: Allow retrieving the number of WMI object instances Date: Wed, 26 Apr 2023 23:03:49 +0200 Message-Id: <20230426210349.100838-1-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:cLFnNxImVvmhI5yLyiv2KbsyIDd1PiGN5UijaXwnLIS1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jnfa++P6fdqsvMQzxK lZLHEVf6XNr7hRmzyqcrB/nC3Viut6B3keq+LU8SZkicyPC59Th70r/r9wnuF06l5Fe+C/khj DQp7dizspiuacNiygViux0zcYtI= 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, URIBL_BLOCKED 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?1764274649385375484?= X-GMAIL-MSGID: =?utf-8?q?1764275004014283212?= 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 | 40 ++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 2 ++ include/linux/wmi.h | 2 ++ 3 files changed, 44 insertions(+) -- 2.30.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index c226dd4163a1..7c1a904dec5f 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -263,6 +263,46 @@ 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 + * @instance_count: variable to hold the instance count + * + * Get the number of WMI object instances. + * + * Returns: acpi_status signaling success or error. + */ +acpi_status wmi_instance_count(const char *guid_string, u8 *instance_count) +{ + struct wmi_block *wblock; + acpi_status status; + + status = find_guid(guid_string, &wblock); + if (ACPI_FAILURE(status)) + return status; + + *instance_count = wmidev_instance_count(&wblock->dev); + + return AE_OK; +} +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..ab2a4b23e7a3 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); +acpi_status wmi_instance_count(const char *guid, u8 *instance_count); + 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); /**