Skip to content

Commit 926a266

Browse files
Wer-Wolfij-intel
authored andcommitted
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>
1 parent bb7527c commit 926a266

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

drivers/platform/x86/wmi-bmof.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1010

11-
#include <linux/acpi.h>
1211
#include <linux/device.h>
1312
#include <linux/fs.h>
1413
#include <linux/kernel.h>
@@ -24,9 +23,9 @@ static ssize_t bmof_read(struct file *filp, struct kobject *kobj, const struct b
2423
char *buf, loff_t off, size_t count)
2524
{
2625
struct device *dev = kobj_to_dev(kobj);
27-
union acpi_object *obj = dev_get_drvdata(dev);
26+
struct wmi_buffer *buffer = dev_get_drvdata(dev);
2827

29-
return memory_read_from_buffer(buf, count, &off, obj->buffer.pointer, obj->buffer.length);
28+
return memory_read_from_buffer(buf, count, &off, buffer->data, buffer->length);
3029
}
3130

3231
static const BIN_ATTR_ADMIN_RO(bmof, 0);
@@ -39,9 +38,9 @@ static const struct bin_attribute * const bmof_attrs[] = {
3938
static size_t bmof_bin_size(struct kobject *kobj, const struct bin_attribute *attr, int n)
4039
{
4140
struct device *dev = kobj_to_dev(kobj);
42-
union acpi_object *obj = dev_get_drvdata(dev);
41+
struct wmi_buffer *buffer = dev_get_drvdata(dev);
4342

44-
return obj->buffer.length;
43+
return buffer->length;
4544
}
4645

4746
static const struct attribute_group bmof_group = {
@@ -56,30 +55,27 @@ static const struct attribute_group *bmof_groups[] = {
5655

5756
static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
5857
{
59-
union acpi_object *obj;
58+
struct wmi_buffer *buffer;
59+
int ret;
6060

61-
obj = wmidev_block_query(wdev, 0);
62-
if (!obj) {
63-
dev_err(&wdev->dev, "failed to read Binary MOF\n");
64-
return -EIO;
65-
}
61+
buffer = devm_kzalloc(&wdev->dev, sizeof(*buffer), GFP_KERNEL);
62+
if (!buffer)
63+
return -ENOMEM;
6664

67-
if (obj->type != ACPI_TYPE_BUFFER) {
68-
dev_err(&wdev->dev, "Binary MOF is not a buffer\n");
69-
kfree(obj);
70-
return -EIO;
71-
}
65+
ret = wmidev_query_block(wdev, 0, buffer);
66+
if (ret < 0)
67+
return ret;
7268

73-
dev_set_drvdata(&wdev->dev, obj);
69+
dev_set_drvdata(&wdev->dev, buffer);
7470

7571
return 0;
7672
}
7773

7874
static void wmi_bmof_remove(struct wmi_device *wdev)
7975
{
80-
union acpi_object *obj = dev_get_drvdata(&wdev->dev);
76+
struct wmi_buffer *buffer = dev_get_drvdata(&wdev->dev);
8177

82-
kfree(obj);
78+
kfree(buffer->data);
8379
}
8480

8581
static const struct wmi_device_id wmi_bmof_id_table[] = {

0 commit comments

Comments
 (0)