aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorCarlos Corbacho <carlos@strangeworlds.co.uk>2008-06-21 04:09:53 -0400
committerAndi Kleen <andi@basil.nowhere.org>2008-07-16 17:27:02 -0400
commit81143522aa823036c4aa35bdd3b2e41966cf6e15 (patch)
treea196808097139443ba355450c36a22b816fda0d9 /drivers/misc
parent5753dd539a86d8fc40a25e1a2cd1005a6525f083 (diff)
acer-wmi: Add debugfs file for device detection
Add a debugfs file for showing the full results of the method we use to detect devices on WMID laptops. This should be useful in the case that a Linux user gets an Acer laptop with 3G support (and/ or people who enjoy ripping their wireless cards out) so we can get some feedback on how this value changes in these cases. (At the moment, we always enable the wireless and 3G control. In the case of the former, this is fairly safe. In the case of the latter though, trying to toggle this device if it doesn't exist on a laptop causes ACPI warnings/ errors). To summarise: If you have an Acer laptop with a built in 3G card, please report back the value from this file. Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/acer-wmi.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c
index dd0b8d8b5bd9..d8b8574e303c 100644
--- a/drivers/misc/acer-wmi.c
+++ b/drivers/misc/acer-wmi.c
@@ -35,6 +35,7 @@
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/i8042.h> 37#include <linux/i8042.h>
38#include <linux/debugfs.h>
38 39
39#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
40 41
@@ -152,6 +153,12 @@ struct acer_data {
152 int brightness; 153 int brightness;
153}; 154};
154 155
156struct acer_debug {
157 struct dentry *root;
158 struct dentry *devices;
159 u32 wmid_devices;
160};
161
155/* Each low-level interface must define at least some of the following */ 162/* Each low-level interface must define at least some of the following */
156struct wmi_interface { 163struct wmi_interface {
157 /* The WMI device type */ 164 /* The WMI device type */
@@ -162,6 +169,9 @@ struct wmi_interface {
162 169
163 /* Private data for the current interface */ 170 /* Private data for the current interface */
164 struct acer_data data; 171 struct acer_data data;
172
173 /* debugfs entries associated with this interface */
174 struct acer_debug debug;
165}; 175};
166 176
167/* The static interface pointer, points to the currently detected interface */ 177/* The static interface pointer, points to the currently detected interface */
@@ -956,6 +966,28 @@ static DEVICE_ATTR(interface, S_IWUGO | S_IRUGO | S_IWUSR,
956 show_interface, NULL); 966 show_interface, NULL);
957 967
958/* 968/*
969 * debugfs functions
970 */
971static u32 get_wmid_devices(void)
972{
973 struct acpi_buffer out = {ACPI_ALLOCATE_BUFFER, NULL};
974 union acpi_object *obj;
975 acpi_status status;
976
977 status = wmi_query_block(WMID_GUID2, 1, &out);
978 if (ACPI_FAILURE(status))
979 return 0;
980
981 obj = (union acpi_object *) out.pointer;
982 if (obj && obj->type == ACPI_TYPE_BUFFER &&
983 obj->buffer.length == sizeof(u32)) {
984 return *((u32 *) obj->buffer.pointer);
985 } else {
986 return 0;
987 }
988}
989
990/*
959 * Platform device 991 * Platform device
960 */ 992 */
961static int __devinit acer_platform_probe(struct platform_device *device) 993static int __devinit acer_platform_probe(struct platform_device *device)
@@ -1114,6 +1146,33 @@ error_sysfs:
1114 return retval; 1146 return retval;
1115} 1147}
1116 1148
1149static void remove_debugfs(void)
1150{
1151 debugfs_remove(interface->debug.devices);
1152 debugfs_remove(interface->debug.root);
1153}
1154
1155static int create_debugfs(void)
1156{
1157 interface->debug.root = debugfs_create_dir("acer-wmi", NULL);
1158 if (!interface->debug.root) {
1159 printk(ACER_ERR "Failed to create debugfs directory");
1160 return -ENOMEM;
1161 }
1162
1163 interface->debug.devices = debugfs_create_u32("devices", S_IRUGO,
1164 interface->debug.root,
1165 &interface->debug.wmid_devices);
1166 if (!interface->debug.devices)
1167 goto error_debugfs;
1168
1169 return 0;
1170
1171error_debugfs:
1172 remove_debugfs();
1173 return -ENOMEM;
1174}
1175
1117static int __init acer_wmi_init(void) 1176static int __init acer_wmi_init(void)
1118{ 1177{
1119 int err; 1178 int err;
@@ -1173,6 +1232,13 @@ static int __init acer_wmi_init(void)
1173 if (err) 1232 if (err)
1174 return err; 1233 return err;
1175 1234
1235 if (wmi_has_guid(WMID_GUID2)) {
1236 interface->debug.wmid_devices = get_wmid_devices();
1237 err = create_debugfs();
1238 if (err)
1239 return err;
1240 }
1241
1176 /* Override any initial settings with values from the commandline */ 1242 /* Override any initial settings with values from the commandline */
1177 acer_commandline_init(); 1243 acer_commandline_init();
1178 1244