aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/asus-wmi.c
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2011-02-26 04:20:39 -0500
committerMatthew Garrett <mjg@redhat.com>2011-03-28 06:07:22 -0400
commitef343491db1770a3af5010ba007167c348cdbe1a (patch)
tree6ca2aa949c72db33eb5f9b2c5dd12885e5e74ee6 /drivers/platform/x86/asus-wmi.c
parent46dbca871df753ce92c321a41a8a38eba7487680 (diff)
asus-wmi: allow debugfs interface to call arbitrary method
Also add some # format flags to debugfs output. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform/x86/asus-wmi.c')
-rw-r--r--drivers/platform/x86/asus-wmi.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 88596ea0f74e..9095c28340cd 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -112,11 +112,14 @@ struct bios_args {
112 * <platform>/ - debugfs root directory 112 * <platform>/ - debugfs root directory
113 * dev_id - current dev_id 113 * dev_id - current dev_id
114 * ctrl_param - current ctrl_param 114 * ctrl_param - current ctrl_param
115 * method_id - current method_id
115 * devs - call DEVS(dev_id, ctrl_param) and print result 116 * devs - call DEVS(dev_id, ctrl_param) and print result
116 * dsts - call DSTS(dev_id) and print result 117 * dsts - call DSTS(dev_id) and print result
118 * call - call method_id(dev_id, ctrl_param) and print result
117 */ 119 */
118struct asus_wmi_debug { 120struct asus_wmi_debug {
119 struct dentry *root; 121 struct dentry *root;
122 u32 method_id;
120 u32 dev_id; 123 u32 dev_id;
121 u32 ctrl_param; 124 u32 ctrl_param;
122}; 125};
@@ -1138,7 +1141,7 @@ static int show_dsts(struct seq_file *m, void *data)
1138 if (err < 0) 1141 if (err < 0)
1139 return err; 1142 return err;
1140 1143
1141 seq_printf(m, "DSTS(%x) = %x\n", asus->debug.dev_id, retval); 1144 seq_printf(m, "DSTS(%#x) = %#x\n", asus->debug.dev_id, retval);
1142 1145
1143 return 0; 1146 return 0;
1144} 1147}
@@ -1155,15 +1158,50 @@ static int show_devs(struct seq_file *m, void *data)
1155 if (err < 0) 1158 if (err < 0)
1156 return err; 1159 return err;
1157 1160
1158 seq_printf(m, "DEVS(%x, %x) = %x\n", asus->debug.dev_id, 1161 seq_printf(m, "DEVS(%#x, %#x) = %#x\n", asus->debug.dev_id,
1159 asus->debug.ctrl_param, retval); 1162 asus->debug.ctrl_param, retval);
1160 1163
1161 return 0; 1164 return 0;
1162} 1165}
1163 1166
1167static int show_call(struct seq_file *m, void *data)
1168{
1169 struct asus_wmi *asus = m->private;
1170 struct bios_args args = {
1171 .arg0 = asus->debug.dev_id,
1172 .arg1 = asus->debug.ctrl_param,
1173 };
1174 struct acpi_buffer input = { (acpi_size) sizeof(args), &args };
1175 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
1176 union acpi_object *obj;
1177 acpi_status status;
1178
1179 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
1180 1, asus->debug.method_id,
1181 &input, &output);
1182
1183 if (ACPI_FAILURE(status))
1184 return -EIO;
1185
1186 obj = (union acpi_object *)output.pointer;
1187 if (obj && obj->type == ACPI_TYPE_INTEGER)
1188 seq_printf(m, "%#x(%#x, %#x) = %#x\n", asus->debug.method_id,
1189 asus->debug.dev_id, asus->debug.ctrl_param,
1190 (u32) obj->integer.value);
1191 else
1192 seq_printf(m, "%#x(%#x, %#x) = t:%d\n", asus->debug.method_id,
1193 asus->debug.dev_id, asus->debug.ctrl_param,
1194 obj->type);
1195
1196 kfree(obj);
1197
1198 return 0;
1199}
1200
1164static struct asus_wmi_debugfs_node asus_wmi_debug_files[] = { 1201static struct asus_wmi_debugfs_node asus_wmi_debug_files[] = {
1165 {NULL, "devs", show_devs}, 1202 {NULL, "devs", show_devs},
1166 {NULL, "dsts", show_dsts}, 1203 {NULL, "dsts", show_dsts},
1204 {NULL, "call", show_call},
1167}; 1205};
1168 1206
1169static int asus_wmi_debugfs_open(struct inode *inode, struct file *file) 1207static int asus_wmi_debugfs_open(struct inode *inode, struct file *file)
@@ -1197,6 +1235,11 @@ static int asus_wmi_debugfs_init(struct asus_wmi *asus)
1197 goto error_debugfs; 1235 goto error_debugfs;
1198 } 1236 }
1199 1237
1238 dent = debugfs_create_x32("method_id", S_IRUGO | S_IWUSR,
1239 asus->debug.root, &asus->debug.method_id);
1240 if (!dent)
1241 goto error_debugfs;
1242
1200 dent = debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR, 1243 dent = debugfs_create_x32("dev_id", S_IRUGO | S_IWUSR,
1201 asus->debug.root, &asus->debug.dev_id); 1244 asus->debug.root, &asus->debug.dev_id);
1202 if (!dent) 1245 if (!dent)