aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/hp-wmi.c81
1 files changed, 46 insertions, 35 deletions
diff --git a/drivers/misc/hp-wmi.c b/drivers/misc/hp-wmi.c
index 1dbcbcb323a2..c6c6d09b376e 100644
--- a/drivers/misc/hp-wmi.c
+++ b/drivers/misc/hp-wmi.c
@@ -177,9 +177,9 @@ static int hp_wmi_wifi_state(void)
177 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); 177 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
178 178
179 if (wireless & 0x100) 179 if (wireless & 0x100)
180 return 1; 180 return RFKILL_STATE_UNBLOCKED;
181 else 181 else
182 return 0; 182 return RFKILL_STATE_SOFT_BLOCKED;
183} 183}
184 184
185static int hp_wmi_bluetooth_state(void) 185static int hp_wmi_bluetooth_state(void)
@@ -187,9 +187,9 @@ static int hp_wmi_bluetooth_state(void)
187 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); 187 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
188 188
189 if (wireless & 0x10000) 189 if (wireless & 0x10000)
190 return 1; 190 return RFKILL_STATE_UNBLOCKED;
191 else 191 else
192 return 0; 192 return RFKILL_STATE_SOFT_BLOCKED;
193} 193}
194 194
195static int hp_wmi_wwan_state(void) 195static int hp_wmi_wwan_state(void)
@@ -197,9 +197,9 @@ static int hp_wmi_wwan_state(void)
197 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0); 197 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
198 198
199 if (wireless & 0x1000000) 199 if (wireless & 0x1000000)
200 return 1; 200 return RFKILL_STATE_UNBLOCKED;
201 else 201 else
202 return 0; 202 return RFKILL_STATE_SOFT_BLOCKED;
203} 203}
204 204
205static ssize_t show_display(struct device *dev, struct device_attribute *attr, 205static ssize_t show_display(struct device *dev, struct device_attribute *attr,
@@ -338,12 +338,14 @@ void hp_wmi_notify(u32 value, void *context)
338 } 338 }
339 } else if (eventcode == 0x5) { 339 } else if (eventcode == 0x5) {
340 if (wifi_rfkill) 340 if (wifi_rfkill)
341 wifi_rfkill->state = hp_wmi_wifi_state(); 341 rfkill_force_state(wifi_rfkill,
342 hp_wmi_wifi_state());
342 if (bluetooth_rfkill) 343 if (bluetooth_rfkill)
343 bluetooth_rfkill->state = 344 rfkill_force_state(bluetooth_rfkill,
344 hp_wmi_bluetooth_state(); 345 hp_wmi_bluetooth_state());
345 if (wwan_rfkill) 346 if (wwan_rfkill)
346 wwan_rfkill->state = hp_wmi_wwan_state(); 347 rfkill_force_state(wwan_rfkill,
348 hp_wmi_wwan_state());
347 } else 349 } else
348 printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n", 350 printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
349 eventcode); 351 eventcode);
@@ -398,6 +400,7 @@ static void cleanup_sysfs(struct platform_device *device)
398static int __init hp_wmi_bios_setup(struct platform_device *device) 400static int __init hp_wmi_bios_setup(struct platform_device *device)
399{ 401{
400 int err; 402 int err;
403 int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
401 404
402 err = device_create_file(&device->dev, &dev_attr_display); 405 err = device_create_file(&device->dev, &dev_attr_display);
403 if (err) 406 if (err)
@@ -412,28 +415,33 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
412 if (err) 415 if (err)
413 goto add_sysfs_error; 416 goto add_sysfs_error;
414 417
415 wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN); 418 if (wireless & 0x1) {
416 wifi_rfkill->name = "hp-wifi"; 419 wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN);
417 wifi_rfkill->state = hp_wmi_wifi_state(); 420 wifi_rfkill->name = "hp-wifi";
418 wifi_rfkill->toggle_radio = hp_wmi_wifi_set; 421 wifi_rfkill->state = hp_wmi_wifi_state();
419 wifi_rfkill->user_claim_unsupported = 1; 422 wifi_rfkill->toggle_radio = hp_wmi_wifi_set;
420 423 wifi_rfkill->user_claim_unsupported = 1;
421 bluetooth_rfkill = rfkill_allocate(&device->dev, 424 rfkill_register(wifi_rfkill);
422 RFKILL_TYPE_BLUETOOTH); 425 }
423 bluetooth_rfkill->name = "hp-bluetooth"; 426
424 bluetooth_rfkill->state = hp_wmi_bluetooth_state(); 427 if (wireless & 0x2) {
425 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; 428 bluetooth_rfkill = rfkill_allocate(&device->dev,
426 bluetooth_rfkill->user_claim_unsupported = 1; 429 RFKILL_TYPE_BLUETOOTH);
427 430 bluetooth_rfkill->name = "hp-bluetooth";
428 wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WIMAX); 431 bluetooth_rfkill->state = hp_wmi_bluetooth_state();
429 wwan_rfkill->name = "hp-wwan"; 432 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
430 wwan_rfkill->state = hp_wmi_wwan_state(); 433 bluetooth_rfkill->user_claim_unsupported = 1;
431 wwan_rfkill->toggle_radio = hp_wmi_wwan_set; 434 rfkill_register(bluetooth_rfkill);
432 wwan_rfkill->user_claim_unsupported = 1; 435 }
433 436
434 rfkill_register(wifi_rfkill); 437 if (wireless & 0x4) {
435 rfkill_register(bluetooth_rfkill); 438 wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WWAN);
436 rfkill_register(wwan_rfkill); 439 wwan_rfkill->name = "hp-wwan";
440 wwan_rfkill->state = hp_wmi_wwan_state();
441 wwan_rfkill->toggle_radio = hp_wmi_wwan_set;
442 wwan_rfkill->user_claim_unsupported = 1;
443 rfkill_register(wwan_rfkill);
444 }
437 445
438 return 0; 446 return 0;
439add_sysfs_error: 447add_sysfs_error:
@@ -445,9 +453,12 @@ static int __exit hp_wmi_bios_remove(struct platform_device *device)
445{ 453{
446 cleanup_sysfs(device); 454 cleanup_sysfs(device);
447 455
448 rfkill_unregister(wifi_rfkill); 456 if (wifi_rfkill)
449 rfkill_unregister(bluetooth_rfkill); 457 rfkill_unregister(wifi_rfkill);
450 rfkill_unregister(wwan_rfkill); 458 if (bluetooth_rfkill)
459 rfkill_unregister(bluetooth_rfkill);
460 if (wwan_rfkill)
461 rfkill_unregister(wwan_rfkill);
451 462
452 return 0; 463 return 0;
453} 464}