Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: wmi-bmof: Use new buffer-based WMI API

Use the new buffer-based WMI API to also support ACPI firmware
implementations that do not use ACPI buffers to return the BMOF data.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20260116204116.4030-9-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>

authored by

Armin Wolf and committed by
Ilpo Järvinen
926a2665 bb7527c6

+15 -19
+15 -19
drivers/platform/x86/wmi-bmof.c
··· 8 8 9 9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10 10 11 - #include <linux/acpi.h> 12 11 #include <linux/device.h> 13 12 #include <linux/fs.h> 14 13 #include <linux/kernel.h> ··· 23 24 char *buf, loff_t off, size_t count) 24 25 { 25 26 struct device *dev = kobj_to_dev(kobj); 26 - union acpi_object *obj = dev_get_drvdata(dev); 27 + struct wmi_buffer *buffer = dev_get_drvdata(dev); 27 28 28 - return memory_read_from_buffer(buf, count, &off, obj->buffer.pointer, obj->buffer.length); 29 + return memory_read_from_buffer(buf, count, &off, buffer->data, buffer->length); 29 30 } 30 31 31 32 static const BIN_ATTR_ADMIN_RO(bmof, 0); ··· 38 39 static size_t bmof_bin_size(struct kobject *kobj, const struct bin_attribute *attr, int n) 39 40 { 40 41 struct device *dev = kobj_to_dev(kobj); 41 - union acpi_object *obj = dev_get_drvdata(dev); 42 + struct wmi_buffer *buffer = dev_get_drvdata(dev); 42 43 43 - return obj->buffer.length; 44 + return buffer->length; 44 45 } 45 46 46 47 static const struct attribute_group bmof_group = { ··· 55 56 56 57 static int wmi_bmof_probe(struct wmi_device *wdev, const void *context) 57 58 { 58 - union acpi_object *obj; 59 + struct wmi_buffer *buffer; 60 + int ret; 59 61 60 - obj = wmidev_block_query(wdev, 0); 61 - if (!obj) { 62 - dev_err(&wdev->dev, "failed to read Binary MOF\n"); 63 - return -EIO; 64 - } 62 + buffer = devm_kzalloc(&wdev->dev, sizeof(*buffer), GFP_KERNEL); 63 + if (!buffer) 64 + return -ENOMEM; 65 65 66 - if (obj->type != ACPI_TYPE_BUFFER) { 67 - dev_err(&wdev->dev, "Binary MOF is not a buffer\n"); 68 - kfree(obj); 69 - return -EIO; 70 - } 66 + ret = wmidev_query_block(wdev, 0, buffer); 67 + if (ret < 0) 68 + return ret; 71 69 72 - dev_set_drvdata(&wdev->dev, obj); 70 + dev_set_drvdata(&wdev->dev, buffer); 73 71 74 72 return 0; 75 73 } 76 74 77 75 static void wmi_bmof_remove(struct wmi_device *wdev) 78 76 { 79 - union acpi_object *obj = dev_get_drvdata(&wdev->dev); 77 + struct wmi_buffer *buffer = dev_get_drvdata(&wdev->dev); 80 78 81 - kfree(obj); 79 + kfree(buffer->data); 82 80 } 83 81 84 82 static const struct wmi_device_id wmi_bmof_id_table[] = {