Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 243103
b: refs/heads/master
c: a7ce3f0
h: refs/heads/master
i:
  243101: 697d69c
  243099: 3febd75
  243095: c30f8b1
  243087: a52412d
  243071: f66158c
v: v3
  • Loading branch information
Corentin Chary authored and Matthew Garrett committed Mar 28, 2011
1 parent 2538d1c commit df5dfdf
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 57 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: 57ab7dae27fae6a492ec968dc543106685adcad5
refs/heads/master: a7ce3f041e640daf96e227d8f7ffa6b988f33025
115 changes: 59 additions & 56 deletions trunk/drivers/platform/x86/asus-wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ struct asus_wmi_debug {
u32 ctrl_param;
};

struct asus_rfkill {
struct asus_wmi *asus;
struct rfkill *rfkill;
u32 dev_id;
};

struct asus_wmi {
struct input_dev *inputdev;
struct backlight_device *backlight_device;
Expand All @@ -124,10 +130,10 @@ struct asus_wmi {
struct workqueue_struct *led_workqueue;
struct work_struct tpd_led_work;

struct rfkill *wlan_rfkill;
struct rfkill *bluetooth_rfkill;
struct rfkill *wimax_rfkill;
struct rfkill *wwan3g_rfkill;
struct asus_rfkill wlan;
struct asus_rfkill bluetooth;
struct asus_rfkill wimax;
struct asus_rfkill wwan3g;

struct hotplug_slot *hotplug_slot;
struct mutex hotplug_lock;
Expand Down Expand Up @@ -377,8 +383,8 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus)

mutex_lock(&asus->hotplug_lock);

if (asus->wlan_rfkill)
rfkill_set_sw_state(asus->wlan_rfkill, blocked);
if (asus->wlan.rfkill)
rfkill_set_sw_state(asus->wlan.rfkill, blocked);

if (asus->hotplug_slot) {
bus = pci_find_bus(0, 1);
Expand Down Expand Up @@ -570,11 +576,11 @@ static int asus_setup_pci_hotplug(struct asus_wmi *asus)
*/
static int asus_rfkill_set(void *data, bool blocked)
{
int dev_id = (unsigned long)data;
struct asus_rfkill *priv = data;
u32 ctrl_param = !blocked;
acpi_status status;

status = asus_wmi_set_devstate(dev_id, ctrl_param, NULL);
status = asus_wmi_set_devstate(priv->dev_id, ctrl_param, NULL);

if (ACPI_FAILURE(status))
return -EIO;
Expand All @@ -584,20 +590,21 @@ static int asus_rfkill_set(void *data, bool blocked)

static void asus_rfkill_query(struct rfkill *rfkill, void *data)
{
int dev_id = (unsigned long)data;
struct asus_rfkill *priv = data;
int result;

result = asus_wmi_get_devstate_simple(dev_id);
result = asus_wmi_get_devstate_simple(priv->dev_id);

if (result < 0)
return;

rfkill_set_sw_state(rfkill, !result);
rfkill_set_sw_state(priv->rfkill, !result);
}

static int asus_rfkill_wlan_set(void *data, bool blocked)
{
struct asus_wmi *asus = data;
struct asus_rfkill *priv = data;
struct asus_wmi *asus = priv->asus;
int ret;

/*
Expand All @@ -608,19 +615,14 @@ static int asus_rfkill_wlan_set(void *data, bool blocked)
* any wmi method
*/
mutex_lock(&asus->wmi_lock);
ret = asus_rfkill_set((void *)(long)ASUS_WMI_DEVID_WLAN, blocked);
ret = asus_rfkill_set(data, blocked);
mutex_unlock(&asus->wmi_lock);
return ret;
}

static void asus_rfkill_wlan_query(struct rfkill *rfkill, void *data)
{
asus_rfkill_query(rfkill, (void *)(long)ASUS_WMI_DEVID_WLAN);
}

static const struct rfkill_ops asus_rfkill_wlan_ops = {
.set_block = asus_rfkill_wlan_set,
.query = asus_rfkill_wlan_query,
.query = asus_rfkill_query,
};

static const struct rfkill_ops asus_rfkill_ops = {
Expand All @@ -629,20 +631,24 @@ static const struct rfkill_ops asus_rfkill_ops = {
};

static int asus_new_rfkill(struct asus_wmi *asus,
struct rfkill **rfkill,
struct asus_rfkill *arfkill,
const char *name, enum rfkill_type type, int dev_id)
{
int result = asus_wmi_get_devstate_simple(dev_id);
struct rfkill **rfkill = &arfkill->rfkill;

if (result < 0)
return result;

arfkill->dev_id = dev_id;
arfkill->asus = asus;

if (dev_id == ASUS_WMI_DEVID_WLAN && asus->driver->hotplug_wireless)
*rfkill = rfkill_alloc(name, &asus->platform_device->dev, type,
&asus_rfkill_wlan_ops, asus);
&asus_rfkill_wlan_ops, arfkill);
else
*rfkill = rfkill_alloc(name, &asus->platform_device->dev, type,
&asus_rfkill_ops, (void *)(long)dev_id);
&asus_rfkill_ops, arfkill);

if (!*rfkill)
return -EINVAL;
Expand All @@ -662,10 +668,10 @@ static void asus_wmi_rfkill_exit(struct asus_wmi *asus)
asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5");
asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6");
asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7");
if (asus->wlan_rfkill) {
rfkill_unregister(asus->wlan_rfkill);
rfkill_destroy(asus->wlan_rfkill);
asus->wlan_rfkill = NULL;
if (asus->wlan.rfkill) {
rfkill_unregister(asus->wlan.rfkill);
rfkill_destroy(asus->wlan.rfkill);
asus->wlan.rfkill = NULL;
}
/*
* Refresh pci hotplug in case the rfkill state was changed after
Expand All @@ -677,20 +683,20 @@ static void asus_wmi_rfkill_exit(struct asus_wmi *asus)
if (asus->hotplug_workqueue)
destroy_workqueue(asus->hotplug_workqueue);

if (asus->bluetooth_rfkill) {
rfkill_unregister(asus->bluetooth_rfkill);
rfkill_destroy(asus->bluetooth_rfkill);
asus->bluetooth_rfkill = NULL;
if (asus->bluetooth.rfkill) {
rfkill_unregister(asus->bluetooth.rfkill);
rfkill_destroy(asus->bluetooth.rfkill);
asus->bluetooth.rfkill = NULL;
}
if (asus->wimax_rfkill) {
rfkill_unregister(asus->wimax_rfkill);
rfkill_destroy(asus->wimax_rfkill);
asus->wimax_rfkill = NULL;
if (asus->wimax.rfkill) {
rfkill_unregister(asus->wimax.rfkill);
rfkill_destroy(asus->wimax.rfkill);
asus->wimax.rfkill = NULL;
}
if (asus->wwan3g_rfkill) {
rfkill_unregister(asus->wwan3g_rfkill);
rfkill_destroy(asus->wwan3g_rfkill);
asus->wwan3g_rfkill = NULL;
if (asus->wwan3g.rfkill) {
rfkill_unregister(asus->wwan3g.rfkill);
rfkill_destroy(asus->wwan3g.rfkill);
asus->wwan3g.rfkill = NULL;
}
}

Expand All @@ -701,30 +707,27 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus)
mutex_init(&asus->hotplug_lock);
mutex_init(&asus->wmi_lock);

result = asus_new_rfkill(asus, &asus->wlan_rfkill,
"asus-wlan", RFKILL_TYPE_WLAN,
ASUS_WMI_DEVID_WLAN);
result = asus_new_rfkill(asus, &asus->wlan, "asus-wlan",
RFKILL_TYPE_WLAN, ASUS_WMI_DEVID_WLAN);

if (result && result != -ENODEV)
goto exit;

result = asus_new_rfkill(asus, &asus->bluetooth_rfkill,
result = asus_new_rfkill(asus, &asus->bluetooth,
"asus-bluetooth", RFKILL_TYPE_BLUETOOTH,
ASUS_WMI_DEVID_BLUETOOTH);

if (result && result != -ENODEV)
goto exit;

result = asus_new_rfkill(asus, &asus->wimax_rfkill,
"asus-wimax", RFKILL_TYPE_WIMAX,
ASUS_WMI_DEVID_WIMAX);
result = asus_new_rfkill(asus, &asus->wimax, "asus-wimax",
RFKILL_TYPE_WIMAX, ASUS_WMI_DEVID_WIMAX);

if (result && result != -ENODEV)
goto exit;

result = asus_new_rfkill(asus, &asus->wwan3g_rfkill,
"asus-wwan3g", RFKILL_TYPE_WWAN,
ASUS_WMI_DEVID_WWAN3G);
result = asus_new_rfkill(asus, &asus->wwan3g, "asus-wwan3g",
RFKILL_TYPE_WWAN, ASUS_WMI_DEVID_WWAN3G);

if (result && result != -ENODEV)
goto exit;
Expand Down Expand Up @@ -1277,7 +1280,7 @@ static int asus_hotk_thaw(struct device *device)
{
struct asus_wmi *asus = dev_get_drvdata(device);

if (asus->wlan_rfkill) {
if (asus->wlan.rfkill) {
bool wlan;

/*
Expand All @@ -1298,20 +1301,20 @@ static int asus_hotk_restore(struct device *device)
int bl;

/* Refresh both wlan rfkill state and pci hotplug */
if (asus->wlan_rfkill)
if (asus->wlan.rfkill)
asus_rfkill_hotplug(asus);

if (asus->bluetooth_rfkill) {
if (asus->bluetooth.rfkill) {
bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_BLUETOOTH);
rfkill_set_sw_state(asus->bluetooth_rfkill, bl);
rfkill_set_sw_state(asus->bluetooth.rfkill, bl);
}
if (asus->wimax_rfkill) {
if (asus->wimax.rfkill) {
bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WIMAX);
rfkill_set_sw_state(asus->wimax_rfkill, bl);
rfkill_set_sw_state(asus->wimax.rfkill, bl);
}
if (asus->wwan3g_rfkill) {
if (asus->wwan3g.rfkill) {
bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WWAN3G);
rfkill_set_sw_state(asus->wwan3g_rfkill, bl);
rfkill_set_sw_state(asus->wwan3g.rfkill, bl);
}

return 0;
Expand Down

0 comments on commit df5dfdf

Please sign in to comment.