aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/acer-wmi.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-06-02 07:01:37 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-03 14:06:13 -0400
commit19d337dff95cbf76edd3ad95c0cee2732c3e1ec5 (patch)
tree33326eeb09cb9664cc8427a5dc7cd2b08b5a57c3 /drivers/platform/x86/acer-wmi.c
parent0f6399c4c525b518644a9b09f8d6fb125a418c4d (diff)
rfkill: rewrite
This patch completely rewrites the rfkill core to address the following deficiencies: * all rfkill drivers need to implement polling where necessary rather than having one central implementation * updating the rfkill state cannot be done from arbitrary contexts, forcing drivers to use schedule_work and requiring lots of code * rfkill drivers need to keep track of soft/hard blocked internally -- the core should do this * the rfkill API has many unexpected quirks, for example being asymmetric wrt. alloc/free and register/unregister * rfkill can call back into a driver from within a function the driver called -- this is prone to deadlocks and generally should be avoided * rfkill-input pointlessly is a separate module * drivers need to #ifdef rfkill functions (unless they want to depend on or select RFKILL) -- rfkill should provide inlines that do nothing if it isn't compiled in * the rfkill structure is not opaque -- drivers need to initialise it correctly (lots of sanity checking code required) -- instead force drivers to pass the right variables to rfkill_alloc() * the documentation is hard to read because it always assumes the reader is completely clueless and contains way TOO MANY CAPS * the rfkill code needlessly uses a lot of locks and atomic operations in locked sections * fix LED trigger to actually change the LED when the radio state changes -- this wasn't done before Tested-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> [thinkpad] Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/platform/x86/acer-wmi.c')
-rw-r--r--drivers/platform/x86/acer-wmi.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 62d02b3c998e..b618fa51db2d 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -958,58 +958,50 @@ 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
975static int acer_rfkill_set(void *data, enum rfkill_state state) 972static 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
985static struct rfkill * acer_rfkill_register(struct device *dev, 982static const struct rfkill_ops acer_rfkill_ops = {
986enum rfkill_type type, char *name, u32 cap) 983 .set_block = acer_rfkill_set,
984};
985
986static 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; 991 u32 state;
990 u32 *data;
991 struct rfkill *rfkill_dev; 992 struct rfkill *rfkill_dev;
992 993
993 rfkill_dev = rfkill_allocate(dev, type); 994 rfkill_dev = rfkill_alloc(name, dev, type,
995 &acer_rfkill_ops,
996 (void *)(unsigned long)cap);
994 if (!rfkill_dev) 997 if (!rfkill_dev)
995 return ERR_PTR(-ENOMEM); 998 return ERR_PTR(-ENOMEM);
996 rfkill_dev->name = name;
997 get_u32(&state, cap); 999 get_u32(&state, cap);
998 rfkill_dev->state = state ? RFKILL_STATE_UNBLOCKED : 1000 rfkill_set_sw_state(rfkill_dev, !state);
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 1001
1009 err = rfkill_register(rfkill_dev); 1002 err = rfkill_register(rfkill_dev);
1010 if (err) { 1003 if (err) {
1011 kfree(rfkill_dev->data); 1004 rfkill_destroy(rfkill_dev);
1012 rfkill_free(rfkill_dev);
1013 return ERR_PTR(err); 1005 return ERR_PTR(err);
1014 } 1006 }
1015 return rfkill_dev; 1007 return rfkill_dev;
@@ -1027,8 +1019,8 @@ static int acer_rfkill_init(struct device *dev)
1027 RFKILL_TYPE_BLUETOOTH, "acer-bluetooth", 1019 RFKILL_TYPE_BLUETOOTH, "acer-bluetooth",
1028 ACER_CAP_BLUETOOTH); 1020 ACER_CAP_BLUETOOTH);
1029 if (IS_ERR(bluetooth_rfkill)) { 1021 if (IS_ERR(bluetooth_rfkill)) {
1030 kfree(wireless_rfkill->data);
1031 rfkill_unregister(wireless_rfkill); 1022 rfkill_unregister(wireless_rfkill);
1023 rfkill_destroy(wireless_rfkill);
1032 return PTR_ERR(bluetooth_rfkill); 1024 return PTR_ERR(bluetooth_rfkill);
1033 } 1025 }
1034 } 1026 }
@@ -1041,11 +1033,13 @@ static int acer_rfkill_init(struct device *dev)
1041static void acer_rfkill_exit(void) 1033static void acer_rfkill_exit(void)
1042{ 1034{
1043 cancel_delayed_work_sync(&acer_rfkill_work); 1035 cancel_delayed_work_sync(&acer_rfkill_work);
1044 kfree(wireless_rfkill->data); 1036
1045 rfkill_unregister(wireless_rfkill); 1037 rfkill_unregister(wireless_rfkill);
1038 rfkill_destroy(wireless_rfkill);
1039
1046 if (has_cap(ACER_CAP_BLUETOOTH)) { 1040 if (has_cap(ACER_CAP_BLUETOOTH)) {
1047 kfree(bluetooth_rfkill->data);
1048 rfkill_unregister(bluetooth_rfkill); 1041 rfkill_unregister(bluetooth_rfkill);
1042 rfkill_destroy(bluetooth_rfkill);
1049 } 1043 }
1050 return; 1044 return;
1051} 1045}