Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109417
b: refs/heads/master
c: 3f6e2f1
h: refs/heads/master
i:
  109415: a423701
v: v3
  • Loading branch information
Matthew Garrett authored and Linus Torvalds committed Sep 3, 2008
1 parent cd1a424 commit 6bbed39
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 61e55d0576d0e7eb4fecaeb25b3618e035de5be1
refs/heads/master: 3f6e2f137c5b83c3c2d48fae971e845c3450cc7c
81 changes: 46 additions & 35 deletions trunk/drivers/misc/hp-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,29 @@ static int hp_wmi_wifi_state(void)
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);

if (wireless & 0x100)
return 1;
return RFKILL_STATE_UNBLOCKED;
else
return 0;
return RFKILL_STATE_SOFT_BLOCKED;
}

static int hp_wmi_bluetooth_state(void)
{
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);

if (wireless & 0x10000)
return 1;
return RFKILL_STATE_UNBLOCKED;
else
return 0;
return RFKILL_STATE_SOFT_BLOCKED;
}

static int hp_wmi_wwan_state(void)
{
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);

if (wireless & 0x1000000)
return 1;
return RFKILL_STATE_UNBLOCKED;
else
return 0;
return RFKILL_STATE_SOFT_BLOCKED;
}

static ssize_t show_display(struct device *dev, struct device_attribute *attr,
Expand Down Expand Up @@ -338,12 +338,14 @@ void hp_wmi_notify(u32 value, void *context)
}
} else if (eventcode == 0x5) {
if (wifi_rfkill)
wifi_rfkill->state = hp_wmi_wifi_state();
rfkill_force_state(wifi_rfkill,
hp_wmi_wifi_state());
if (bluetooth_rfkill)
bluetooth_rfkill->state =
hp_wmi_bluetooth_state();
rfkill_force_state(bluetooth_rfkill,
hp_wmi_bluetooth_state());
if (wwan_rfkill)
wwan_rfkill->state = hp_wmi_wwan_state();
rfkill_force_state(wwan_rfkill,
hp_wmi_wwan_state());
} else
printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
eventcode);
Expand Down Expand Up @@ -398,6 +400,7 @@ static void cleanup_sysfs(struct platform_device *device)
static int __init hp_wmi_bios_setup(struct platform_device *device)
{
int err;
int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);

err = device_create_file(&device->dev, &dev_attr_display);
if (err)
Expand All @@ -412,28 +415,33 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
if (err)
goto add_sysfs_error;

wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN);
wifi_rfkill->name = "hp-wifi";
wifi_rfkill->state = hp_wmi_wifi_state();
wifi_rfkill->toggle_radio = hp_wmi_wifi_set;
wifi_rfkill->user_claim_unsupported = 1;

bluetooth_rfkill = rfkill_allocate(&device->dev,
RFKILL_TYPE_BLUETOOTH);
bluetooth_rfkill->name = "hp-bluetooth";
bluetooth_rfkill->state = hp_wmi_bluetooth_state();
bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
bluetooth_rfkill->user_claim_unsupported = 1;

wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WIMAX);
wwan_rfkill->name = "hp-wwan";
wwan_rfkill->state = hp_wmi_wwan_state();
wwan_rfkill->toggle_radio = hp_wmi_wwan_set;
wwan_rfkill->user_claim_unsupported = 1;

rfkill_register(wifi_rfkill);
rfkill_register(bluetooth_rfkill);
rfkill_register(wwan_rfkill);
if (wireless & 0x1) {
wifi_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WLAN);
wifi_rfkill->name = "hp-wifi";
wifi_rfkill->state = hp_wmi_wifi_state();
wifi_rfkill->toggle_radio = hp_wmi_wifi_set;
wifi_rfkill->user_claim_unsupported = 1;
rfkill_register(wifi_rfkill);
}

if (wireless & 0x2) {
bluetooth_rfkill = rfkill_allocate(&device->dev,
RFKILL_TYPE_BLUETOOTH);
bluetooth_rfkill->name = "hp-bluetooth";
bluetooth_rfkill->state = hp_wmi_bluetooth_state();
bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
bluetooth_rfkill->user_claim_unsupported = 1;
rfkill_register(bluetooth_rfkill);
}

if (wireless & 0x4) {
wwan_rfkill = rfkill_allocate(&device->dev, RFKILL_TYPE_WWAN);
wwan_rfkill->name = "hp-wwan";
wwan_rfkill->state = hp_wmi_wwan_state();
wwan_rfkill->toggle_radio = hp_wmi_wwan_set;
wwan_rfkill->user_claim_unsupported = 1;
rfkill_register(wwan_rfkill);
}

return 0;
add_sysfs_error:
Expand All @@ -445,9 +453,12 @@ static int __exit hp_wmi_bios_remove(struct platform_device *device)
{
cleanup_sysfs(device);

rfkill_unregister(wifi_rfkill);
rfkill_unregister(bluetooth_rfkill);
rfkill_unregister(wwan_rfkill);
if (wifi_rfkill)
rfkill_unregister(wifi_rfkill);
if (bluetooth_rfkill)
rfkill_unregister(bluetooth_rfkill);
if (wwan_rfkill)
rfkill_unregister(wwan_rfkill);

return 0;
}
Expand Down

0 comments on commit 6bbed39

Please sign in to comment.