Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101997
b: refs/heads/master
c: 8114352
h: refs/heads/master
i:
  101995: 46e47f1
v: v3
  • Loading branch information
Carlos Corbacho authored and Andi Kleen committed Jul 16, 2008
1 parent a41e0a8 commit 5d31507
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5753dd539a86d8fc40a25e1a2cd1005a6525f083
refs/heads/master: 81143522aa823036c4aa35bdd3b2e41966cf6e15
66 changes: 66 additions & 0 deletions trunk/drivers/misc/acer-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/platform_device.h>
#include <linux/acpi.h>
#include <linux/i8042.h>
#include <linux/debugfs.h>

#include <acpi/acpi_drivers.h>

Expand Down Expand Up @@ -152,6 +153,12 @@ struct acer_data {
int brightness;
};

struct acer_debug {
struct dentry *root;
struct dentry *devices;
u32 wmid_devices;
};

/* Each low-level interface must define at least some of the following */
struct wmi_interface {
/* The WMI device type */
Expand All @@ -162,6 +169,9 @@ struct wmi_interface {

/* Private data for the current interface */
struct acer_data data;

/* debugfs entries associated with this interface */
struct acer_debug debug;
};

/* The static interface pointer, points to the currently detected interface */
Expand Down Expand Up @@ -955,6 +965,28 @@ static ssize_t show_interface(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(interface, S_IWUGO | S_IRUGO | S_IWUSR,
show_interface, NULL);

/*
* debugfs functions
*/
static u32 get_wmid_devices(void)
{
struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *obj;
acpi_status status;

status = wmi_query_block(WMID_GUID2, 1, &out);
if (ACPI_FAILURE(status))
return 0;

obj = (union acpi_object *) out.pointer;
if (obj && obj->type == ACPI_TYPE_BUFFER &&
obj->buffer.length == sizeof(u32)) {
return *((u32 *) obj->buffer.pointer);
} else {
return 0;
}
}

/*
* Platform device
*/
Expand Down Expand Up @@ -1114,6 +1146,33 @@ static int create_sysfs(void)
return retval;
}

static void remove_debugfs(void)
{
debugfs_remove(interface->debug.devices);
debugfs_remove(interface->debug.root);
}

static int create_debugfs(void)
{
interface->debug.root = debugfs_create_dir("acer-wmi", NULL);
if (!interface->debug.root) {
printk(ACER_ERR "Failed to create debugfs directory");
return -ENOMEM;
}

interface->debug.devices = debugfs_create_u32("devices", S_IRUGO,
interface->debug.root,
&interface->debug.wmid_devices);
if (!interface->debug.devices)
goto error_debugfs;

return 0;

error_debugfs:
remove_debugfs();
return -ENOMEM;
}

static int __init acer_wmi_init(void)
{
int err;
Expand Down Expand Up @@ -1173,6 +1232,13 @@ static int __init acer_wmi_init(void)
if (err)
return err;

if (wmi_has_guid(WMID_GUID2)) {
interface->debug.wmid_devices = get_wmid_devices();
err = create_debugfs();
if (err)
return err;
}

/* Override any initial settings with values from the commandline */
acer_commandline_init();

Expand Down

0 comments on commit 5d31507

Please sign in to comment.