Commit f25d3464 authored by Armin Wolf's avatar Armin Wolf Committed by Hans de Goede

platform/x86: wmi: Add wmidev_block_set()

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.
Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20231103182526.3524-1-W_Armin@gmx.deReviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent b85ea95d
...@@ -536,41 +536,50 @@ EXPORT_SYMBOL_GPL(wmidev_block_query); ...@@ -536,41 +536,50 @@ EXPORT_SYMBOL_GPL(wmidev_block_query);
* *
* Return: acpi_status signaling success or error. * Return: acpi_status signaling success or error.
*/ */
acpi_status wmi_set_block(const char *guid_string, u8 instance, acpi_status wmi_set_block(const char *guid_string, u8 instance, const struct acpi_buffer *in)
const struct acpi_buffer *in)
{ {
struct wmi_block *wblock;
struct guid_block *block;
struct wmi_device *wdev; 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; acpi_status status;
if (!in)
return AE_BAD_DATA;
wdev = wmi_find_device_by_guid(guid_string); wdev = wmi_find_device_by_guid(guid_string);
if (IS_ERR(wdev)) if (IS_ERR(wdev))
return AE_ERROR; return AE_ERROR;
wblock = container_of(wdev, struct wmi_block, dev); status = wmidev_block_set(wdev, instance, in);
block = &wblock->gblock; wmi_device_put(wdev);
handle = wblock->acpi_device->handle;
if (block->instance_count <= instance) { return status;
status = AE_BAD_PARAMETER; }
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 (!in)
if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) { return AE_BAD_DATA;
status = AE_ERROR;
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.count = 2;
input.pointer = params; input.pointer = params;
...@@ -582,14 +591,9 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance, ...@@ -582,14 +591,9 @@ acpi_status wmi_set_block(const char *guid_string, u8 instance,
get_acpi_method_name(wblock, 'S', method); get_acpi_method_name(wblock, 'S', method);
status = acpi_evaluate_object(handle, method, &input, NULL); return acpi_evaluate_object(handle, method, &input, NULL);
err_wdev_put:
wmi_device_put(wdev);
return status;
} }
EXPORT_SYMBOL_GPL(wmi_set_block); EXPORT_SYMBOL_GPL(wmidev_block_set);
static void wmi_dump_wdg(const struct guid_block *g) static void wmi_dump_wdg(const struct guid_block *g)
{ {
......
...@@ -35,6 +35,8 @@ extern acpi_status wmidev_evaluate_method(struct wmi_device *wdev, ...@@ -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, extern union acpi_object *wmidev_block_query(struct wmi_device *wdev,
u8 instance); 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); u8 wmidev_instance_count(struct wmi_device *wdev);
extern int set_required_buffer_size(struct wmi_device *wdev, u64 length); extern int set_required_buffer_size(struct wmi_device *wdev, u64 length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment