mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:24:45 +01:00
platform/x86: intel-wmi-sbl-fw-update: Use new buffer-based WMI API
Use the new buffer-based WMI API to also support ACPI firmware implementations that return a ACPI buffer instead of a ACPI integer. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://patch.msgid.link/20260116204116.4030-6-W_Armin@gmx.de Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
0e1a8143e7
commit
534f685d8a
1 changed files with 18 additions and 25 deletions
|
|
@ -14,7 +14,6 @@
|
|||
* https://slimbootloader.github.io/security/firmware-update.html
|
||||
*/
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
@ -25,41 +24,35 @@
|
|||
|
||||
static int get_fwu_request(struct device *dev, u32 *out)
|
||||
{
|
||||
union acpi_object *obj;
|
||||
struct wmi_buffer buffer;
|
||||
__le32 *result;
|
||||
int ret;
|
||||
|
||||
obj = wmidev_block_query(to_wmi_device(dev), 0);
|
||||
if (!obj)
|
||||
return -ENODEV;
|
||||
ret = wmidev_query_block(to_wmi_device(dev), 0, &buffer);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (obj->type != ACPI_TYPE_INTEGER) {
|
||||
dev_warn(dev, "wmidev_block_query returned invalid value\n");
|
||||
kfree(obj);
|
||||
return -EINVAL;
|
||||
if (buffer.length < sizeof(*result)) {
|
||||
kfree(buffer.data);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
*out = obj->integer.value;
|
||||
kfree(obj);
|
||||
result = buffer.data;
|
||||
*out = le32_to_cpu(*result);
|
||||
kfree(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_fwu_request(struct device *dev, u32 in)
|
||||
{
|
||||
struct acpi_buffer input;
|
||||
acpi_status status;
|
||||
u32 value;
|
||||
__le32 value = cpu_to_le32(in);
|
||||
struct wmi_buffer buffer = {
|
||||
.length = sizeof(value),
|
||||
.data = &value,
|
||||
};
|
||||
|
||||
value = in;
|
||||
input.length = sizeof(u32);
|
||||
input.pointer = &value;
|
||||
|
||||
status = wmidev_block_set(to_wmi_device(dev), 0, &input);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
dev_err(dev, "wmidev_block_set failed\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return wmidev_set_block(to_wmi_device(dev), 0, &buffer);
|
||||
}
|
||||
|
||||
static ssize_t firmware_update_request_show(struct device *dev,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue