mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Rong Zhang" <i@rong.moe>,
	"Derek J . Clark" <derekjohn.clark@gmail.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Armin Wolf" <W_Armin@gmx.de>
Cc: Charles <hanker007@gmail.com>,
	"Navon John Lukose" <navonjohnlukose@gmail.com>,
	"platform-driver-x86@vger.kernel.org"
	<platform-driver-x86@vger.kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 01/12] platform/wmi: Introduce wmidev_exists()
Date: Fri, 09 Oct 2026 16:25:16 -0400	[thread overview]
Message-ID: <4ae58ee4-7c9e-4f6c-add4-473cd2a8166a@app.fastmail.com> (raw)
In-Reply-To: <20261009-lwmi-wmi-new-api-v2-1-402828382679@rong.moe>


On Fri, Oct 9, 2026, at 8:53 AM, Rong Zhang wrote:
> From: Armin Wolf <W_Armin@gmx.de>
>
> Some WMI drivers need to be able to detect the existence of WMI
> devices matching a given GUID in order to determine the availability
> of optional features. Using wmi_has_guid() for this will not work for
> WMI devices that cannot be used with the legacy GUID-based API (aka
> have WMI_GUID_DUPLICATED set).
>
> Introduce wmidev_exists() that also checks WMI devices that are only
> available to the bus-based API. Also mark wmi_has_guid() as deprecated
> because only WMI drivers using the legacy GUID-based API will continue
> to have use for it.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> Changes in v2:
> - New patch in the series as discussed at
>   https://msgid.link/83776200-4A60-4756-A99F-D5A3BB4D834A@rong.moe
> ---
>  drivers/platform/wmi/core.c | 33 +++++++++++++++++++++++++++++----
>  include/linux/wmi.h         |  3 +++
>  2 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/wmi/core.c b/drivers/platform/wmi/core.c
> index 529825dcfbfe..a99da9b7039d 100644
> --- a/drivers/platform/wmi/core.c
> +++ b/drivers/platform/wmi/core.c
> @@ -145,7 +145,7 @@ static inline void get_acpi_method_name(const 
> struct wmi_block *wblock,
>  	buffer[4] = '\0';
>  }
> 
> -static int wmidev_match_guid(struct device *dev, const void *data)
> +static int wmidev_match_guid_legacy(struct device *dev, const void 
> *data)
>  {
>  	struct wmi_block *wblock = dev_to_wblock(dev);
>  	const guid_t *guid = data;
> @@ -218,7 +218,7 @@ static struct wmi_device 
> *wmi_find_device_by_guid(const char *guid_string)
>  	if (ret < 0)
>  		return ERR_PTR(ret);
> 
> -	dev = bus_find_device(&wmi_bus_type, NULL, &guid, wmidev_match_guid);
> +	dev = bus_find_device(&wmi_bus_type, NULL, &guid, wmidev_match_guid_legacy);
>  	if (!dev)
>  		return ERR_PTR(-ENODEV);
> 
> @@ -800,10 +800,10 @@ acpi_status wmi_remove_notify_handler(const char *guid)
>  EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
> 
>  /**
> - * wmi_has_guid - Check if a GUID is available
> + * wmi_has_guid - Check if a GUID is available (deprecated)
>   * @guid_string: 36 char string of the form 
> fa50ff2b-f2e8-45de-83fa-65417f2f49ba
>   *
> - * Check if a given GUID is defined by _WDG.
> + * Check if a given GUID is available and usable with the legacy 
> GUID-based API.
>   *
>   * Return: True if GUID is available, false otherwise.
>   */
> @@ -821,6 +821,31 @@ bool wmi_has_guid(const char *guid_string)
>  }
>  EXPORT_SYMBOL_GPL(wmi_has_guid);
> 
> +static int wmidev_match_guid(struct device *dev, void *data)
> +{
> +	struct wmi_block *wblock = dev_to_wblock(dev);
> +	const guid_t *guid = data;
> +
> +	if (guid_equal(guid, &wblock->gblock.guid))
> +		return 1;
> +
> +	return 0;
> +}
> +
> +/**
> + * wmidev_exists - Check if a WMI device with a given GUID exists
> + * @guid: GUID of the WMI device to search for
> + *
> + * Check if a WMI device with a given GUID exists at the given moment.
> + *
> + * Return: True if a matching WMI device exists, false otherwise.
> + */
> +bool wmidev_exists(const guid_t *guid)
> +{
> +	return bus_for_each_dev(&wmi_bus_type, NULL, (void *)guid, 
> wmidev_match_guid) == 1;
> +}
> +EXPORT_SYMBOL_GPL(wmidev_exists);
> +
>  /**
>   * wmi_get_acpi_device_uid() - Get _UID name of ACPI device that 
> defines GUID (deprecated)
>   * @guid_string: 36 char string of the form 
> fa50ff2b-f2e8-45de-83fa-65417f2f49ba
> diff --git a/include/linux/wmi.h b/include/linux/wmi.h
> index defcb624a7e2..3dd223f2ff18 100644
> --- a/include/linux/wmi.h
> +++ b/include/linux/wmi.h
> @@ -13,6 +13,7 @@
>  #include <linux/acpi.h>
>  #include <linux/device-id/wmi.h>
>  #include <linux/types.h>
> +#include <linux/uuid.h>
> 
>  /**
>   * struct wmi_device - WMI device structure
> @@ -83,6 +84,8 @@ acpi_status wmidev_block_set(struct wmi_device *wdev, 
> u8 instance, const struct
> 
>  u8 wmidev_instance_count(struct wmi_device *wdev);
> 
> +bool wmidev_exists(const guid_t *guid);
> +
>  /**
>   * struct wmi_driver - WMI driver structure
>   * @driver: Driver model structure
>
> -- 
> 2.55.0

Tested and confirmed this works.

Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>

Mark

  reply	other threads:[~2026-10-09 20:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 12:53 [PATCH v2 00/12] platform/x86: lenovo-wmi-{other,capdata,helpers}: Improve robustness on faulty firmware Rong Zhang
2026-10-09 12:53 ` [PATCH v2 01/12] platform/wmi: Introduce wmidev_exists() Rong Zhang
2026-10-09 20:25   ` Mark Pearson [this message]
2026-10-09 12:53 ` [PATCH v2 02/12] platform/x86: lenovo-wmi-capdata: Do not stop the AC notifier chain on error Rong Zhang
2026-10-09 12:53 ` [PATCH v2 03/12] platform/x86: lenovo-wmi-capdata: Only allocate sub-master info when necessary Rong Zhang
2026-10-09 15:15   ` Derek J. Clark
2026-10-09 15:45     ` Rong Zhang
2026-10-09 12:53 ` [PATCH v2 04/12] platform/x86: lenovo-wmi-capdata: Store a pointer to component info Rong Zhang
2026-10-09 12:53 ` [PATCH v2 05/12] platform/x86: lenovo-wmi-capdata: Defer mutex initialization Rong Zhang
2026-10-09 12:53 ` [PATCH v2 06/12] platform/x86: lenovo-wmi-{capdata,other}: Only allocate capdata list when necessary Rong Zhang
2026-10-09 12:53 ` [PATCH v2 07/12] platform/x86: lenovo-wmi-capdata: Adopt new WMI API Rong Zhang
2026-10-10  1:16   ` Armin Wolf
2026-10-10  1:51     ` Rong Zhang
2026-10-09 12:53 ` [PATCH v2 08/12] platform/x86: lenovo-wmi-capdata: Register component even on WMI error Rong Zhang
2026-10-09 12:53 ` [PATCH v2 09/12] platform/x86: lenovo-wmi-capdata: Detect stubbed capdata device Rong Zhang
2026-10-09 12:53 ` [PATCH v2 10/12] platform/x86: lenovo-wmi-capdata: Do not match missing components Rong Zhang
2026-10-09 12:53 ` [PATCH v2 11/12] platform/x86: lenovo-wmi-helpers: Adopt new WMI API Rong Zhang
2026-10-10  1:19   ` Armin Wolf
2026-10-09 12:53 ` [PATCH v2 12/12] MAINTAINERS: Add myself as a LENOVO drivers co-maintainer Rong Zhang
2026-10-09 20:26   ` Mark Pearson
2026-10-09 23:01 ` [PATCH v2 00/12] platform/x86: lenovo-wmi-{other,capdata,helpers}: Improve robustness on faulty firmware Derek J. Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ae58ee4-7c9e-4f6c-add4-473cd2a8166a@app.fastmail.com \
    --to=mpearson-lenovo@squebb.ca \
    --cc=W_Armin@gmx.de \
    --cc=derekjohn.clark@gmail.com \
    --cc=hanker007@gmail.com \
    --cc=hansg@kernel.org \
    --cc=i@rong.moe \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=navonjohnlukose@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®