mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: jithu.joseph@intel.com, hdegoede@redhat.com,
	markgross@kernel.org, ilpo.jarvinen@linux.intel.com
Cc: Dell.Client.Kernel@dell.com, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] platform/x86: wmi: Add wmidev_block_set()
Date: Mon, 13 Nov 2023 20:57:07 +0100	[thread overview]
Message-ID: <7b78eed3-eb78-4870-ae12-51219a07ef80@gmx.de> (raw)
In-Reply-To: <20231103182526.3524-1-W_Armin@gmx.de>

Am 03.11.23 um 19:25 schrieb Armin Wolf:

> Currently, WMI drivers have to use the deprecated GUID-based
> interface when setting data blocks. This prevents those
> drivers from fully moving away from this interface.
>
> Provide wmidev_block_set() so drivers using wmi_set_block() can
> fully migrate to the modern bus-based interface.
>
> Tested with a custom SSDT from the Intel Slim Bootloader project.

Any thoughts on this?

Armin Wolf

>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> Changes in v2:
> - applies on pdx86/for-next
> ---
>   drivers/platform/x86/wmi.c | 64 ++++++++++++++++++++------------------
>   include/linux/wmi.h        |  2 ++
>   2 files changed, 36 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 5c27b4aa9690..9d9a050e7086 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -536,41 +536,50 @@ EXPORT_SYMBOL_GPL(wmidev_block_query);
>    *
>    * Return: acpi_status signaling success or error.
>    */
> -acpi_status wmi_set_block(const char *guid_string, u8 instance,
> -			  const struct acpi_buffer *in)
> +acpi_status wmi_set_block(const char *guid_string, u8 instance, const struct acpi_buffer *in)
>   {
> -	struct wmi_block *wblock;
> -	struct guid_block *block;
>   	struct wmi_device *wdev;
> -	acpi_handle handle;
> -	struct acpi_object_list input;
> -	union acpi_object params[2];
> -	char method[WMI_ACPI_METHOD_NAME_SIZE];
>   	acpi_status status;
>
> -	if (!in)
> -		return AE_BAD_DATA;
> -
>   	wdev = wmi_find_device_by_guid(guid_string);
>   	if (IS_ERR(wdev))
>   		return AE_ERROR;
>
> -	wblock = container_of(wdev, struct wmi_block, dev);
> -	block = &wblock->gblock;
> -	handle = wblock->acpi_device->handle;
> +	status =  wmidev_block_set(wdev, instance, in);
> +	wmi_device_put(wdev);
>
> -	if (block->instance_count <= instance) {
> -		status = AE_BAD_PARAMETER;
> +	return status;
> +}
> +EXPORT_SYMBOL_GPL(wmi_set_block);
>
> -		goto err_wdev_put;
> -	}
> +/**
> + * wmidev_block_set - Write to a WMI block
> + * @wdev: A wmi bus device from a driver
> + * @instance: Instance index
> + * @in: Buffer containing new values for the data block
> + *
> + * Write contents of the input buffer to an ACPI-WMI data block.
> + *
> + * Return: acpi_status signaling success or error.
> + */
> +acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct acpi_buffer *in)
> +{
> +	struct wmi_block *wblock = container_of(wdev, struct wmi_block, dev);
> +	acpi_handle handle = wblock->acpi_device->handle;
> +	struct guid_block *block = &wblock->gblock;
> +	char method[WMI_ACPI_METHOD_NAME_SIZE];
> +	struct acpi_object_list input;
> +	union acpi_object params[2];
>
> -	/* Check GUID is a data block */
> -	if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) {
> -		status = AE_ERROR;
> +	if (!in)
> +		return AE_BAD_DATA;
>
> -		goto err_wdev_put;
> -	}
> +	if (block->instance_count <= instance)
> +		return AE_BAD_PARAMETER;
> +
> +	/* Check GUID is a data block */
> +	if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
> +		return AE_ERROR;
>
>   	input.count = 2;
>   	input.pointer = params;
> @@ -582,14 +591,9 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance,
>
>   	get_acpi_method_name(wblock, 'S', method);
>
> -	status = acpi_evaluate_object(handle, method, &input, NULL);
> -
> -err_wdev_put:
> -	wmi_device_put(wdev);
> -
> -	return status;
> +	return acpi_evaluate_object(handle, method, &input, NULL);
>   }
> -EXPORT_SYMBOL_GPL(wmi_set_block);
> +EXPORT_SYMBOL_GPL(wmidev_block_set);
>
>   static void wmi_dump_wdg(const struct guid_block *g)
>   {
> diff --git a/include/linux/wmi.h b/include/linux/wmi.h
> index 763bd382cf2d..207544968268 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);
>
> +acpi_status wmidev_block_set(struct wmi_device *wdev, u8 instance, const struct acpi_buffer *in);
> +
>   u8 wmidev_instance_count(struct wmi_device *wdev);
>
>   extern int set_required_buffer_size(struct wmi_device *wdev, u64 length);
> --
> 2.39.2
>

  parent reply	other threads:[~2023-11-13 19:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 18:25 Armin Wolf
2023-11-03 18:25 ` [PATCH v2 2/4] platform/x86: wmi: Add to_wmi_device() helper macro Armin Wolf
2023-11-03 18:25 ` [PATCH v2 3/4] platform/x86: intel-wmi-sbl-fw-update: Use bus-based WMI interface Armin Wolf
2023-11-03 18:25 ` [PATCH v2 4/4] platform/x86/intel/wmi: thunderbolt: " Armin Wolf
2023-11-16 13:38   ` Ilpo Järvinen
2023-11-13 19:57 ` Armin Wolf [this message]
2023-11-20 12:00 ` [PATCH v2 1/4] platform/x86: wmi: Add wmidev_block_set() Hans de Goede
2023-11-20 21:29   ` Armin Wolf

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=7b78eed3-eb78-4870-ae12-51219a07ef80@gmx.de \
    --to=w_armin@gmx.de \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --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®