diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-16 20:24:53 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-16 20:24:53 -0400 |
commit | 492b057c426e4aa747484958e18e9da29003985d (patch) | |
tree | 34e08c24618688d8bcc190523028b5f94cce0c0b /drivers/platform/x86/acer-wmi.c | |
parent | 313485175da221c388f6a8ecf4c30062ba9bea17 (diff) | |
parent | 300df7dc89cc276377fc020704e34875d5c473b6 (diff) |
Merge commit 'origin/master' into next
Diffstat (limited to 'drivers/platform/x86/acer-wmi.c')
-rw-r--r-- | drivers/platform/x86/acer-wmi.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 0f6e43bf4fc2..09a503e5da6a 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c | |||
@@ -958,59 +958,47 @@ static void acer_rfkill_update(struct work_struct *ignored) | |||
958 | 958 | ||
959 | status = get_u32(&state, ACER_CAP_WIRELESS); | 959 | status = get_u32(&state, ACER_CAP_WIRELESS); |
960 | if (ACPI_SUCCESS(status)) | 960 | if (ACPI_SUCCESS(status)) |
961 | rfkill_force_state(wireless_rfkill, state ? | 961 | rfkill_set_sw_state(wireless_rfkill, !!state); |
962 | RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED); | ||
963 | 962 | ||
964 | if (has_cap(ACER_CAP_BLUETOOTH)) { | 963 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
965 | status = get_u32(&state, ACER_CAP_BLUETOOTH); | 964 | status = get_u32(&state, ACER_CAP_BLUETOOTH); |
966 | if (ACPI_SUCCESS(status)) | 965 | if (ACPI_SUCCESS(status)) |
967 | rfkill_force_state(bluetooth_rfkill, state ? | 966 | rfkill_set_sw_state(bluetooth_rfkill, !!state); |
968 | RFKILL_STATE_UNBLOCKED : | ||
969 | RFKILL_STATE_SOFT_BLOCKED); | ||
970 | } | 967 | } |
971 | 968 | ||
972 | schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ)); | 969 | schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ)); |
973 | } | 970 | } |
974 | 971 | ||
975 | static int acer_rfkill_set(void *data, enum rfkill_state state) | 972 | static int acer_rfkill_set(void *data, bool blocked) |
976 | { | 973 | { |
977 | acpi_status status; | 974 | acpi_status status; |
978 | u32 *cap = data; | 975 | u32 cap = (unsigned long)data; |
979 | status = set_u32((u32) (state == RFKILL_STATE_UNBLOCKED), *cap); | 976 | status = set_u32(!!blocked, cap); |
980 | if (ACPI_FAILURE(status)) | 977 | if (ACPI_FAILURE(status)) |
981 | return -ENODEV; | 978 | return -ENODEV; |
982 | return 0; | 979 | return 0; |
983 | } | 980 | } |
984 | 981 | ||
985 | static struct rfkill * acer_rfkill_register(struct device *dev, | 982 | static const struct rfkill_ops acer_rfkill_ops = { |
986 | enum rfkill_type type, char *name, u32 cap) | 983 | .set_block = acer_rfkill_set, |
984 | }; | ||
985 | |||
986 | static struct rfkill *acer_rfkill_register(struct device *dev, | ||
987 | enum rfkill_type type, | ||
988 | char *name, u32 cap) | ||
987 | { | 989 | { |
988 | int err; | 990 | int err; |
989 | u32 state; | ||
990 | u32 *data; | ||
991 | struct rfkill *rfkill_dev; | 991 | struct rfkill *rfkill_dev; |
992 | 992 | ||
993 | rfkill_dev = rfkill_allocate(dev, type); | 993 | rfkill_dev = rfkill_alloc(name, dev, type, |
994 | &acer_rfkill_ops, | ||
995 | (void *)(unsigned long)cap); | ||
994 | if (!rfkill_dev) | 996 | if (!rfkill_dev) |
995 | return ERR_PTR(-ENOMEM); | 997 | return ERR_PTR(-ENOMEM); |
996 | rfkill_dev->name = name; | ||
997 | get_u32(&state, cap); | ||
998 | rfkill_dev->state = state ? RFKILL_STATE_UNBLOCKED : | ||
999 | RFKILL_STATE_SOFT_BLOCKED; | ||
1000 | data = kzalloc(sizeof(u32), GFP_KERNEL); | ||
1001 | if (!data) { | ||
1002 | rfkill_free(rfkill_dev); | ||
1003 | return ERR_PTR(-ENOMEM); | ||
1004 | } | ||
1005 | *data = cap; | ||
1006 | rfkill_dev->data = data; | ||
1007 | rfkill_dev->toggle_radio = acer_rfkill_set; | ||
1008 | rfkill_dev->user_claim_unsupported = 1; | ||
1009 | 998 | ||
1010 | err = rfkill_register(rfkill_dev); | 999 | err = rfkill_register(rfkill_dev); |
1011 | if (err) { | 1000 | if (err) { |
1012 | kfree(rfkill_dev->data); | 1001 | rfkill_destroy(rfkill_dev); |
1013 | rfkill_free(rfkill_dev); | ||
1014 | return ERR_PTR(err); | 1002 | return ERR_PTR(err); |
1015 | } | 1003 | } |
1016 | return rfkill_dev; | 1004 | return rfkill_dev; |
@@ -1028,8 +1016,8 @@ static int acer_rfkill_init(struct device *dev) | |||
1028 | RFKILL_TYPE_BLUETOOTH, "acer-bluetooth", | 1016 | RFKILL_TYPE_BLUETOOTH, "acer-bluetooth", |
1029 | ACER_CAP_BLUETOOTH); | 1017 | ACER_CAP_BLUETOOTH); |
1030 | if (IS_ERR(bluetooth_rfkill)) { | 1018 | if (IS_ERR(bluetooth_rfkill)) { |
1031 | kfree(wireless_rfkill->data); | ||
1032 | rfkill_unregister(wireless_rfkill); | 1019 | rfkill_unregister(wireless_rfkill); |
1020 | rfkill_destroy(wireless_rfkill); | ||
1033 | return PTR_ERR(bluetooth_rfkill); | 1021 | return PTR_ERR(bluetooth_rfkill); |
1034 | } | 1022 | } |
1035 | } | 1023 | } |
@@ -1042,11 +1030,13 @@ static int acer_rfkill_init(struct device *dev) | |||
1042 | static void acer_rfkill_exit(void) | 1030 | static void acer_rfkill_exit(void) |
1043 | { | 1031 | { |
1044 | cancel_delayed_work_sync(&acer_rfkill_work); | 1032 | cancel_delayed_work_sync(&acer_rfkill_work); |
1045 | kfree(wireless_rfkill->data); | 1033 | |
1046 | rfkill_unregister(wireless_rfkill); | 1034 | rfkill_unregister(wireless_rfkill); |
1035 | rfkill_destroy(wireless_rfkill); | ||
1036 | |||
1047 | if (has_cap(ACER_CAP_BLUETOOTH)) { | 1037 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
1048 | kfree(bluetooth_rfkill->data); | ||
1049 | rfkill_unregister(bluetooth_rfkill); | 1038 | rfkill_unregister(bluetooth_rfkill); |
1039 | rfkill_destroy(bluetooth_rfkill); | ||
1050 | } | 1040 | } |
1051 | return; | 1041 | return; |
1052 | } | 1042 | } |