diff options
author | Corentin Chary <corentincj@iksaif.net> | 2011-02-26 04:20:33 -0500 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2011-03-28 06:07:20 -0400 |
commit | a7ce3f041e640daf96e227d8f7ffa6b988f33025 (patch) | |
tree | e19facfea5534b95c908777167062e13fde014c9 /drivers/platform/x86/asus-wmi.c | |
parent | 57ab7dae27fae6a492ec968dc543106685adcad5 (diff) |
asus-wmi: introduce struct asus_rfkill
First, this allow use to remove the custom asusrfkill_wlan_query,
but this will also allow us to give struct asus_wmi * to
get_devstate/set_devstate later.
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.c | 115 |
1 files changed, 59 insertions, 56 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 4c3f68a495d7..d0f0931ea5eb 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c | |||
@@ -114,6 +114,12 @@ struct asus_wmi_debug { | |||
114 | u32 ctrl_param; | 114 | u32 ctrl_param; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | struct asus_rfkill { | ||
118 | struct asus_wmi *asus; | ||
119 | struct rfkill *rfkill; | ||
120 | u32 dev_id; | ||
121 | }; | ||
122 | |||
117 | struct asus_wmi { | 123 | struct asus_wmi { |
118 | struct input_dev *inputdev; | 124 | struct input_dev *inputdev; |
119 | struct backlight_device *backlight_device; | 125 | struct backlight_device *backlight_device; |
@@ -124,10 +130,10 @@ struct asus_wmi { | |||
124 | struct workqueue_struct *led_workqueue; | 130 | struct workqueue_struct *led_workqueue; |
125 | struct work_struct tpd_led_work; | 131 | struct work_struct tpd_led_work; |
126 | 132 | ||
127 | struct rfkill *wlan_rfkill; | 133 | struct asus_rfkill wlan; |
128 | struct rfkill *bluetooth_rfkill; | 134 | struct asus_rfkill bluetooth; |
129 | struct rfkill *wimax_rfkill; | 135 | struct asus_rfkill wimax; |
130 | struct rfkill *wwan3g_rfkill; | 136 | struct asus_rfkill wwan3g; |
131 | 137 | ||
132 | struct hotplug_slot *hotplug_slot; | 138 | struct hotplug_slot *hotplug_slot; |
133 | struct mutex hotplug_lock; | 139 | struct mutex hotplug_lock; |
@@ -377,8 +383,8 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus) | |||
377 | 383 | ||
378 | mutex_lock(&asus->hotplug_lock); | 384 | mutex_lock(&asus->hotplug_lock); |
379 | 385 | ||
380 | if (asus->wlan_rfkill) | 386 | if (asus->wlan.rfkill) |
381 | rfkill_set_sw_state(asus->wlan_rfkill, blocked); | 387 | rfkill_set_sw_state(asus->wlan.rfkill, blocked); |
382 | 388 | ||
383 | if (asus->hotplug_slot) { | 389 | if (asus->hotplug_slot) { |
384 | bus = pci_find_bus(0, 1); | 390 | bus = pci_find_bus(0, 1); |
@@ -570,11 +576,11 @@ error_workqueue: | |||
570 | */ | 576 | */ |
571 | static int asus_rfkill_set(void *data, bool blocked) | 577 | static int asus_rfkill_set(void *data, bool blocked) |
572 | { | 578 | { |
573 | int dev_id = (unsigned long)data; | 579 | struct asus_rfkill *priv = data; |
574 | u32 ctrl_param = !blocked; | 580 | u32 ctrl_param = !blocked; |
575 | acpi_status status; | 581 | acpi_status status; |
576 | 582 | ||
577 | status = asus_wmi_set_devstate(dev_id, ctrl_param, NULL); | 583 | status = asus_wmi_set_devstate(priv->dev_id, ctrl_param, NULL); |
578 | 584 | ||
579 | if (ACPI_FAILURE(status)) | 585 | if (ACPI_FAILURE(status)) |
580 | return -EIO; | 586 | return -EIO; |
@@ -584,20 +590,21 @@ static int asus_rfkill_set(void *data, bool blocked) | |||
584 | 590 | ||
585 | static void asus_rfkill_query(struct rfkill *rfkill, void *data) | 591 | static void asus_rfkill_query(struct rfkill *rfkill, void *data) |
586 | { | 592 | { |
587 | int dev_id = (unsigned long)data; | 593 | struct asus_rfkill *priv = data; |
588 | int result; | 594 | int result; |
589 | 595 | ||
590 | result = asus_wmi_get_devstate_simple(dev_id); | 596 | result = asus_wmi_get_devstate_simple(priv->dev_id); |
591 | 597 | ||
592 | if (result < 0) | 598 | if (result < 0) |
593 | return; | 599 | return; |
594 | 600 | ||
595 | rfkill_set_sw_state(rfkill, !result); | 601 | rfkill_set_sw_state(priv->rfkill, !result); |
596 | } | 602 | } |
597 | 603 | ||
598 | static int asus_rfkill_wlan_set(void *data, bool blocked) | 604 | static int asus_rfkill_wlan_set(void *data, bool blocked) |
599 | { | 605 | { |
600 | struct asus_wmi *asus = data; | 606 | struct asus_rfkill *priv = data; |
607 | struct asus_wmi *asus = priv->asus; | ||
601 | int ret; | 608 | int ret; |
602 | 609 | ||
603 | /* | 610 | /* |
@@ -608,19 +615,14 @@ static int asus_rfkill_wlan_set(void *data, bool blocked) | |||
608 | * any wmi method | 615 | * any wmi method |
609 | */ | 616 | */ |
610 | mutex_lock(&asus->wmi_lock); | 617 | mutex_lock(&asus->wmi_lock); |
611 | ret = asus_rfkill_set((void *)(long)ASUS_WMI_DEVID_WLAN, blocked); | 618 | ret = asus_rfkill_set(data, blocked); |
612 | mutex_unlock(&asus->wmi_lock); | 619 | mutex_unlock(&asus->wmi_lock); |
613 | return ret; | 620 | return ret; |
614 | } | 621 | } |
615 | 622 | ||
616 | static void asus_rfkill_wlan_query(struct rfkill *rfkill, void *data) | ||
617 | { | ||
618 | asus_rfkill_query(rfkill, (void *)(long)ASUS_WMI_DEVID_WLAN); | ||
619 | } | ||
620 | |||
621 | static const struct rfkill_ops asus_rfkill_wlan_ops = { | 623 | static const struct rfkill_ops asus_rfkill_wlan_ops = { |
622 | .set_block = asus_rfkill_wlan_set, | 624 | .set_block = asus_rfkill_wlan_set, |
623 | .query = asus_rfkill_wlan_query, | 625 | .query = asus_rfkill_query, |
624 | }; | 626 | }; |
625 | 627 | ||
626 | static const struct rfkill_ops asus_rfkill_ops = { | 628 | static const struct rfkill_ops asus_rfkill_ops = { |
@@ -629,20 +631,24 @@ static const struct rfkill_ops asus_rfkill_ops = { | |||
629 | }; | 631 | }; |
630 | 632 | ||
631 | static int asus_new_rfkill(struct asus_wmi *asus, | 633 | static int asus_new_rfkill(struct asus_wmi *asus, |
632 | struct rfkill **rfkill, | 634 | struct asus_rfkill *arfkill, |
633 | const char *name, enum rfkill_type type, int dev_id) | 635 | const char *name, enum rfkill_type type, int dev_id) |
634 | { | 636 | { |
635 | int result = asus_wmi_get_devstate_simple(dev_id); | 637 | int result = asus_wmi_get_devstate_simple(dev_id); |
638 | struct rfkill **rfkill = &arfkill->rfkill; | ||
636 | 639 | ||
637 | if (result < 0) | 640 | if (result < 0) |
638 | return result; | 641 | return result; |
639 | 642 | ||
643 | arfkill->dev_id = dev_id; | ||
644 | arfkill->asus = asus; | ||
645 | |||
640 | if (dev_id == ASUS_WMI_DEVID_WLAN && asus->driver->hotplug_wireless) | 646 | if (dev_id == ASUS_WMI_DEVID_WLAN && asus->driver->hotplug_wireless) |
641 | *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, | 647 | *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, |
642 | &asus_rfkill_wlan_ops, asus); | 648 | &asus_rfkill_wlan_ops, arfkill); |
643 | else | 649 | else |
644 | *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, | 650 | *rfkill = rfkill_alloc(name, &asus->platform_device->dev, type, |
645 | &asus_rfkill_ops, (void *)(long)dev_id); | 651 | &asus_rfkill_ops, arfkill); |
646 | 652 | ||
647 | if (!*rfkill) | 653 | if (!*rfkill) |
648 | return -EINVAL; | 654 | return -EINVAL; |
@@ -662,10 +668,10 @@ static void asus_wmi_rfkill_exit(struct asus_wmi *asus) | |||
662 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); | 668 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P5"); |
663 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); | 669 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P6"); |
664 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); | 670 | asus_unregister_rfkill_notifier(asus, "\\_SB.PCI0.P0P7"); |
665 | if (asus->wlan_rfkill) { | 671 | if (asus->wlan.rfkill) { |
666 | rfkill_unregister(asus->wlan_rfkill); | 672 | rfkill_unregister(asus->wlan.rfkill); |
667 | rfkill_destroy(asus->wlan_rfkill); | 673 | rfkill_destroy(asus->wlan.rfkill); |
668 | asus->wlan_rfkill = NULL; | 674 | asus->wlan.rfkill = NULL; |
669 | } | 675 | } |
670 | /* | 676 | /* |
671 | * Refresh pci hotplug in case the rfkill state was changed after | 677 | * Refresh pci hotplug in case the rfkill state was changed after |
@@ -677,20 +683,20 @@ static void asus_wmi_rfkill_exit(struct asus_wmi *asus) | |||
677 | if (asus->hotplug_workqueue) | 683 | if (asus->hotplug_workqueue) |
678 | destroy_workqueue(asus->hotplug_workqueue); | 684 | destroy_workqueue(asus->hotplug_workqueue); |
679 | 685 | ||
680 | if (asus->bluetooth_rfkill) { | 686 | if (asus->bluetooth.rfkill) { |
681 | rfkill_unregister(asus->bluetooth_rfkill); | 687 | rfkill_unregister(asus->bluetooth.rfkill); |
682 | rfkill_destroy(asus->bluetooth_rfkill); | 688 | rfkill_destroy(asus->bluetooth.rfkill); |
683 | asus->bluetooth_rfkill = NULL; | 689 | asus->bluetooth.rfkill = NULL; |
684 | } | 690 | } |
685 | if (asus->wimax_rfkill) { | 691 | if (asus->wimax.rfkill) { |
686 | rfkill_unregister(asus->wimax_rfkill); | 692 | rfkill_unregister(asus->wimax.rfkill); |
687 | rfkill_destroy(asus->wimax_rfkill); | 693 | rfkill_destroy(asus->wimax.rfkill); |
688 | asus->wimax_rfkill = NULL; | 694 | asus->wimax.rfkill = NULL; |
689 | } | 695 | } |
690 | if (asus->wwan3g_rfkill) { | 696 | if (asus->wwan3g.rfkill) { |
691 | rfkill_unregister(asus->wwan3g_rfkill); | 697 | rfkill_unregister(asus->wwan3g.rfkill); |
692 | rfkill_destroy(asus->wwan3g_rfkill); | 698 | rfkill_destroy(asus->wwan3g.rfkill); |
693 | asus->wwan3g_rfkill = NULL; | 699 | asus->wwan3g.rfkill = NULL; |
694 | } | 700 | } |
695 | } | 701 | } |
696 | 702 | ||
@@ -701,30 +707,27 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) | |||
701 | mutex_init(&asus->hotplug_lock); | 707 | mutex_init(&asus->hotplug_lock); |
702 | mutex_init(&asus->wmi_lock); | 708 | mutex_init(&asus->wmi_lock); |
703 | 709 | ||
704 | result = asus_new_rfkill(asus, &asus->wlan_rfkill, | 710 | result = asus_new_rfkill(asus, &asus->wlan, "asus-wlan", |
705 | "asus-wlan", RFKILL_TYPE_WLAN, | 711 | RFKILL_TYPE_WLAN, ASUS_WMI_DEVID_WLAN); |
706 | ASUS_WMI_DEVID_WLAN); | ||
707 | 712 | ||
708 | if (result && result != -ENODEV) | 713 | if (result && result != -ENODEV) |
709 | goto exit; | 714 | goto exit; |
710 | 715 | ||
711 | result = asus_new_rfkill(asus, &asus->bluetooth_rfkill, | 716 | result = asus_new_rfkill(asus, &asus->bluetooth, |
712 | "asus-bluetooth", RFKILL_TYPE_BLUETOOTH, | 717 | "asus-bluetooth", RFKILL_TYPE_BLUETOOTH, |
713 | ASUS_WMI_DEVID_BLUETOOTH); | 718 | ASUS_WMI_DEVID_BLUETOOTH); |
714 | 719 | ||
715 | if (result && result != -ENODEV) | 720 | if (result && result != -ENODEV) |
716 | goto exit; | 721 | goto exit; |
717 | 722 | ||
718 | result = asus_new_rfkill(asus, &asus->wimax_rfkill, | 723 | result = asus_new_rfkill(asus, &asus->wimax, "asus-wimax", |
719 | "asus-wimax", RFKILL_TYPE_WIMAX, | 724 | RFKILL_TYPE_WIMAX, ASUS_WMI_DEVID_WIMAX); |
720 | ASUS_WMI_DEVID_WIMAX); | ||
721 | 725 | ||
722 | if (result && result != -ENODEV) | 726 | if (result && result != -ENODEV) |
723 | goto exit; | 727 | goto exit; |
724 | 728 | ||
725 | result = asus_new_rfkill(asus, &asus->wwan3g_rfkill, | 729 | result = asus_new_rfkill(asus, &asus->wwan3g, "asus-wwan3g", |
726 | "asus-wwan3g", RFKILL_TYPE_WWAN, | 730 | RFKILL_TYPE_WWAN, ASUS_WMI_DEVID_WWAN3G); |
727 | ASUS_WMI_DEVID_WWAN3G); | ||
728 | 731 | ||
729 | if (result && result != -ENODEV) | 732 | if (result && result != -ENODEV) |
730 | goto exit; | 733 | goto exit; |
@@ -1277,7 +1280,7 @@ static int asus_hotk_thaw(struct device *device) | |||
1277 | { | 1280 | { |
1278 | struct asus_wmi *asus = dev_get_drvdata(device); | 1281 | struct asus_wmi *asus = dev_get_drvdata(device); |
1279 | 1282 | ||
1280 | if (asus->wlan_rfkill) { | 1283 | if (asus->wlan.rfkill) { |
1281 | bool wlan; | 1284 | bool wlan; |
1282 | 1285 | ||
1283 | /* | 1286 | /* |
@@ -1298,20 +1301,20 @@ static int asus_hotk_restore(struct device *device) | |||
1298 | int bl; | 1301 | int bl; |
1299 | 1302 | ||
1300 | /* Refresh both wlan rfkill state and pci hotplug */ | 1303 | /* Refresh both wlan rfkill state and pci hotplug */ |
1301 | if (asus->wlan_rfkill) | 1304 | if (asus->wlan.rfkill) |
1302 | asus_rfkill_hotplug(asus); | 1305 | asus_rfkill_hotplug(asus); |
1303 | 1306 | ||
1304 | if (asus->bluetooth_rfkill) { | 1307 | if (asus->bluetooth.rfkill) { |
1305 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_BLUETOOTH); | 1308 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_BLUETOOTH); |
1306 | rfkill_set_sw_state(asus->bluetooth_rfkill, bl); | 1309 | rfkill_set_sw_state(asus->bluetooth.rfkill, bl); |
1307 | } | 1310 | } |
1308 | if (asus->wimax_rfkill) { | 1311 | if (asus->wimax.rfkill) { |
1309 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WIMAX); | 1312 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WIMAX); |
1310 | rfkill_set_sw_state(asus->wimax_rfkill, bl); | 1313 | rfkill_set_sw_state(asus->wimax.rfkill, bl); |
1311 | } | 1314 | } |
1312 | if (asus->wwan3g_rfkill) { | 1315 | if (asus->wwan3g.rfkill) { |
1313 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WWAN3G); | 1316 | bl = !asus_wmi_get_devstate_simple(ASUS_WMI_DEVID_WWAN3G); |
1314 | rfkill_set_sw_state(asus->wwan3g_rfkill, bl); | 1317 | rfkill_set_sw_state(asus->wwan3g.rfkill, bl); |
1315 | } | 1318 | } |
1316 | 1319 | ||
1317 | return 0; | 1320 | return 0; |