Commit a8ec105c0764c848d59f18a31f91fa00c99b2e7f
1 parent
c76a3e1d6c
Exists in
master
and in
7 other branches
hp-wmi: Fix query interface
The machines I have appear to provide their return value in the arguments structure, not the output structure. Rework the driver to use that again in order to get rfkill working again. Signed-off-by: Matthew Garrett <mjg@redhat.com>
Showing 1 changed file with 25 additions and 39 deletions Side-by-side Diff
drivers/platform/x86/hp-wmi.c
... | ... | @@ -79,12 +79,13 @@ |
79 | 79 | u32 command; |
80 | 80 | u32 commandtype; |
81 | 81 | u32 datasize; |
82 | - char *data; | |
82 | + u32 data; | |
83 | 83 | }; |
84 | 84 | |
85 | 85 | struct bios_return { |
86 | 86 | u32 sigpass; |
87 | 87 | u32 return_code; |
88 | + u32 value; | |
88 | 89 | }; |
89 | 90 | |
90 | 91 | struct key_entry { |
... | ... | @@ -148,7 +149,7 @@ |
148 | 149 | * buffer = kzalloc(128, GFP_KERNEL); |
149 | 150 | * ret = hp_wmi_perform_query(0x7, 0, buffer, 128) |
150 | 151 | */ |
151 | -static int hp_wmi_perform_query(int query, int write, char *buffer, | |
152 | +static int hp_wmi_perform_query(int query, int write, u32 *buffer, | |
152 | 153 | int buffersize) |
153 | 154 | { |
154 | 155 | struct bios_return bios_return; |
... | ... | @@ -159,7 +160,7 @@ |
159 | 160 | .command = write ? 0x2 : 0x1, |
160 | 161 | .commandtype = query, |
161 | 162 | .datasize = buffersize, |
162 | - .data = buffer, | |
163 | + .data = *buffer, | |
163 | 164 | }; |
164 | 165 | struct acpi_buffer input = { sizeof(struct bios_args), &args }; |
165 | 166 | struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; |
166 | 167 | |
... | ... | @@ -177,29 +178,14 @@ |
177 | 178 | |
178 | 179 | bios_return = *((struct bios_return *)obj->buffer.pointer); |
179 | 180 | |
180 | - if (bios_return.return_code) { | |
181 | - printk(KERN_WARNING PREFIX "Query %d returned %d\n", query, | |
182 | - bios_return.return_code); | |
183 | - kfree(obj); | |
184 | - return bios_return.return_code; | |
185 | - } | |
186 | - if (obj->buffer.length - sizeof(bios_return) > buffersize) { | |
187 | - kfree(obj); | |
188 | - return -EINVAL; | |
189 | - } | |
190 | - | |
191 | - memset(buffer, 0, buffersize); | |
192 | - memcpy(buffer, | |
193 | - ((char *)obj->buffer.pointer) + sizeof(struct bios_return), | |
194 | - obj->buffer.length - sizeof(bios_return)); | |
195 | - kfree(obj); | |
181 | + memcpy(buffer, &bios_return.value, sizeof(bios_return.value)); | |
196 | 182 | return 0; |
197 | 183 | } |
198 | 184 | |
199 | 185 | static int hp_wmi_display_state(void) |
200 | 186 | { |
201 | - int state; | |
202 | - int ret = hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, (char *)&state, | |
187 | + int state = 0; | |
188 | + int ret = hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, &state, | |
203 | 189 | sizeof(state)); |
204 | 190 | if (ret) |
205 | 191 | return -EINVAL; |
... | ... | @@ -208,8 +194,8 @@ |
208 | 194 | |
209 | 195 | static int hp_wmi_hddtemp_state(void) |
210 | 196 | { |
211 | - int state; | |
212 | - int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, (char *)&state, | |
197 | + int state = 0; | |
198 | + int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, &state, | |
213 | 199 | sizeof(state)); |
214 | 200 | if (ret) |
215 | 201 | return -EINVAL; |
... | ... | @@ -218,8 +204,8 @@ |
218 | 204 | |
219 | 205 | static int hp_wmi_als_state(void) |
220 | 206 | { |
221 | - int state; | |
222 | - int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, (char *)&state, | |
207 | + int state = 0; | |
208 | + int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, &state, | |
223 | 209 | sizeof(state)); |
224 | 210 | if (ret) |
225 | 211 | return -EINVAL; |
... | ... | @@ -228,8 +214,8 @@ |
228 | 214 | |
229 | 215 | static int hp_wmi_dock_state(void) |
230 | 216 | { |
231 | - int state; | |
232 | - int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, (char *)&state, | |
217 | + int state = 0; | |
218 | + int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, | |
233 | 219 | sizeof(state)); |
234 | 220 | |
235 | 221 | if (ret) |
... | ... | @@ -240,8 +226,8 @@ |
240 | 226 | |
241 | 227 | static int hp_wmi_tablet_state(void) |
242 | 228 | { |
243 | - int state; | |
244 | - int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, (char *)&state, | |
229 | + int state = 0; | |
230 | + int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, | |
245 | 231 | sizeof(state)); |
246 | 232 | if (ret) |
247 | 233 | return ret; |
... | ... | @@ -256,7 +242,7 @@ |
256 | 242 | int ret; |
257 | 243 | |
258 | 244 | ret = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, |
259 | - (char *)&query, sizeof(query)); | |
245 | + &query, sizeof(query)); | |
260 | 246 | if (ret) |
261 | 247 | return -EINVAL; |
262 | 248 | return 0; |
263 | 249 | |
... | ... | @@ -268,10 +254,10 @@ |
268 | 254 | |
269 | 255 | static bool hp_wmi_get_sw_state(enum hp_wmi_radio r) |
270 | 256 | { |
271 | - int wireless; | |
257 | + int wireless = 0; | |
272 | 258 | int mask; |
273 | 259 | hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, |
274 | - (char *)&wireless, sizeof(wireless)); | |
260 | + &wireless, sizeof(wireless)); | |
275 | 261 | /* TBD: Pass error */ |
276 | 262 | |
277 | 263 | mask = 0x200 << (r * 8); |
278 | 264 | |
... | ... | @@ -284,10 +270,10 @@ |
284 | 270 | |
285 | 271 | static bool hp_wmi_get_hw_state(enum hp_wmi_radio r) |
286 | 272 | { |
287 | - int wireless; | |
273 | + int wireless = 0; | |
288 | 274 | int mask; |
289 | 275 | hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, |
290 | - (char *)&wireless, sizeof(wireless)); | |
276 | + &wireless, sizeof(wireless)); | |
291 | 277 | /* TBD: Pass error */ |
292 | 278 | |
293 | 279 | mask = 0x800 << (r * 8); |
... | ... | @@ -347,7 +333,7 @@ |
347 | 333 | const char *buf, size_t count) |
348 | 334 | { |
349 | 335 | u32 tmp = simple_strtoul(buf, NULL, 10); |
350 | - int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, (char *)&tmp, | |
336 | + int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, &tmp, | |
351 | 337 | sizeof(tmp)); |
352 | 338 | if (ret) |
353 | 339 | return -EINVAL; |
... | ... | @@ -421,7 +407,7 @@ |
421 | 407 | static struct key_entry *key; |
422 | 408 | union acpi_object *obj; |
423 | 409 | u32 event_id, event_data; |
424 | - int key_code, ret; | |
410 | + int key_code = 0, ret; | |
425 | 411 | u32 *location; |
426 | 412 | acpi_status status; |
427 | 413 | |
... | ... | @@ -475,7 +461,7 @@ |
475 | 461 | break; |
476 | 462 | case HPWMI_BEZEL_BUTTON: |
477 | 463 | ret = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0, |
478 | - (char *)&key_code, | |
464 | + &key_code, | |
479 | 465 | sizeof(key_code)); |
480 | 466 | if (ret) |
481 | 467 | break; |
482 | 468 | |
... | ... | @@ -578,9 +564,9 @@ |
578 | 564 | static int __devinit hp_wmi_bios_setup(struct platform_device *device) |
579 | 565 | { |
580 | 566 | int err; |
581 | - int wireless; | |
567 | + int wireless = 0; | |
582 | 568 | |
583 | - err = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, (char *)&wireless, | |
569 | + err = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, &wireless, | |
584 | 570 | sizeof(wireless)); |
585 | 571 | if (err) |
586 | 572 | return err; |