diff options
author | Lee, Chun-Yi <joeyli.kernel@gmail.com> | 2011-08-18 06:47:33 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2011-10-24 10:52:38 -0400 |
commit | 1709adab0773616da7a8190f2762e599afb0a295 (patch) | |
tree | 8cdc7cb33a74bd25989c9833e750d11107985d20 /drivers/platform | |
parent | 8fcf71aa0032acbd30b3222f9cb238919ab3b984 (diff) |
acer-wmi: check wireless capability flag before register rfkill
There will be better to check the wireless capability flag
(ACER_CAP_WIRELESS) before register wireless rfkill because maybe
the machine doesn't have wifi module or the module removed by user.
Tested on Acer Travelmate 8572
Tested on Acer Aspire 4739Z
Tested-by: AceLan Kao <acelan.kao@canonical.com>
Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Thomas Renninger <trenn@suse.de>
Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/acer-wmi.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index dac286a568ea..fc7c9733bba5 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c | |||
@@ -1294,12 +1294,13 @@ static void acer_rfkill_update(struct work_struct *ignored) | |||
1294 | u32 state; | 1294 | u32 state; |
1295 | acpi_status status; | 1295 | acpi_status status; |
1296 | 1296 | ||
1297 | status = get_u32(&state, ACER_CAP_WIRELESS); | 1297 | if (has_cap(ACER_CAP_WIRELESS)) { |
1298 | if (ACPI_SUCCESS(status)) { | 1298 | status = get_u32(&state, ACER_CAP_WIRELESS); |
1299 | if (quirks->wireless == 3) { | 1299 | if (ACPI_SUCCESS(status)) { |
1300 | rfkill_set_hw_state(wireless_rfkill, !state); | 1300 | if (quirks->wireless == 3) |
1301 | } else { | 1301 | rfkill_set_hw_state(wireless_rfkill, !state); |
1302 | rfkill_set_sw_state(wireless_rfkill, !state); | 1302 | else |
1303 | rfkill_set_sw_state(wireless_rfkill, !state); | ||
1303 | } | 1304 | } |
1304 | } | 1305 | } |
1305 | 1306 | ||
@@ -1368,19 +1369,24 @@ static struct rfkill *acer_rfkill_register(struct device *dev, | |||
1368 | 1369 | ||
1369 | static int acer_rfkill_init(struct device *dev) | 1370 | static int acer_rfkill_init(struct device *dev) |
1370 | { | 1371 | { |
1371 | wireless_rfkill = acer_rfkill_register(dev, RFKILL_TYPE_WLAN, | 1372 | int err; |
1372 | "acer-wireless", ACER_CAP_WIRELESS); | 1373 | |
1373 | if (IS_ERR(wireless_rfkill)) | 1374 | if (has_cap(ACER_CAP_WIRELESS)) { |
1374 | return PTR_ERR(wireless_rfkill); | 1375 | wireless_rfkill = acer_rfkill_register(dev, RFKILL_TYPE_WLAN, |
1376 | "acer-wireless", ACER_CAP_WIRELESS); | ||
1377 | if (IS_ERR(wireless_rfkill)) { | ||
1378 | err = PTR_ERR(wireless_rfkill); | ||
1379 | goto error_wireless; | ||
1380 | } | ||
1381 | } | ||
1375 | 1382 | ||
1376 | if (has_cap(ACER_CAP_BLUETOOTH)) { | 1383 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
1377 | bluetooth_rfkill = acer_rfkill_register(dev, | 1384 | bluetooth_rfkill = acer_rfkill_register(dev, |
1378 | RFKILL_TYPE_BLUETOOTH, "acer-bluetooth", | 1385 | RFKILL_TYPE_BLUETOOTH, "acer-bluetooth", |
1379 | ACER_CAP_BLUETOOTH); | 1386 | ACER_CAP_BLUETOOTH); |
1380 | if (IS_ERR(bluetooth_rfkill)) { | 1387 | if (IS_ERR(bluetooth_rfkill)) { |
1381 | rfkill_unregister(wireless_rfkill); | 1388 | err = PTR_ERR(bluetooth_rfkill); |
1382 | rfkill_destroy(wireless_rfkill); | 1389 | goto error_bluetooth; |
1383 | return PTR_ERR(bluetooth_rfkill); | ||
1384 | } | 1390 | } |
1385 | } | 1391 | } |
1386 | 1392 | ||
@@ -1389,30 +1395,44 @@ static int acer_rfkill_init(struct device *dev) | |||
1389 | RFKILL_TYPE_WWAN, "acer-threeg", | 1395 | RFKILL_TYPE_WWAN, "acer-threeg", |
1390 | ACER_CAP_THREEG); | 1396 | ACER_CAP_THREEG); |
1391 | if (IS_ERR(threeg_rfkill)) { | 1397 | if (IS_ERR(threeg_rfkill)) { |
1392 | rfkill_unregister(wireless_rfkill); | 1398 | err = PTR_ERR(threeg_rfkill); |
1393 | rfkill_destroy(wireless_rfkill); | 1399 | goto error_threeg; |
1394 | rfkill_unregister(bluetooth_rfkill); | ||
1395 | rfkill_destroy(bluetooth_rfkill); | ||
1396 | return PTR_ERR(threeg_rfkill); | ||
1397 | } | 1400 | } |
1398 | } | 1401 | } |
1399 | 1402 | ||
1400 | rfkill_inited = true; | 1403 | rfkill_inited = true; |
1401 | 1404 | ||
1402 | if (ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) | 1405 | if ((ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) && |
1406 | has_cap(ACER_CAP_WIRELESS | ACER_CAP_BLUETOOTH | ACER_CAP_THREEG)) | ||
1403 | schedule_delayed_work(&acer_rfkill_work, | 1407 | schedule_delayed_work(&acer_rfkill_work, |
1404 | round_jiffies_relative(HZ)); | 1408 | round_jiffies_relative(HZ)); |
1405 | 1409 | ||
1406 | return 0; | 1410 | return 0; |
1411 | |||
1412 | error_threeg: | ||
1413 | if (has_cap(ACER_CAP_BLUETOOTH)) { | ||
1414 | rfkill_unregister(bluetooth_rfkill); | ||
1415 | rfkill_destroy(bluetooth_rfkill); | ||
1416 | } | ||
1417 | error_bluetooth: | ||
1418 | if (has_cap(ACER_CAP_WIRELESS)) { | ||
1419 | rfkill_unregister(wireless_rfkill); | ||
1420 | rfkill_destroy(wireless_rfkill); | ||
1421 | } | ||
1422 | error_wireless: | ||
1423 | return err; | ||
1407 | } | 1424 | } |
1408 | 1425 | ||
1409 | static void acer_rfkill_exit(void) | 1426 | static void acer_rfkill_exit(void) |
1410 | { | 1427 | { |
1411 | if (ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) | 1428 | if ((ec_raw_mode || !wmi_has_guid(ACERWMID_EVENT_GUID)) && |
1429 | has_cap(ACER_CAP_WIRELESS | ACER_CAP_BLUETOOTH | ACER_CAP_THREEG)) | ||
1412 | cancel_delayed_work_sync(&acer_rfkill_work); | 1430 | cancel_delayed_work_sync(&acer_rfkill_work); |
1413 | 1431 | ||
1414 | rfkill_unregister(wireless_rfkill); | 1432 | if (has_cap(ACER_CAP_WIRELESS)) { |
1415 | rfkill_destroy(wireless_rfkill); | 1433 | rfkill_unregister(wireless_rfkill); |
1434 | rfkill_destroy(wireless_rfkill); | ||
1435 | } | ||
1416 | 1436 | ||
1417 | if (has_cap(ACER_CAP_BLUETOOTH)) { | 1437 | if (has_cap(ACER_CAP_BLUETOOTH)) { |
1418 | rfkill_unregister(bluetooth_rfkill); | 1438 | rfkill_unregister(bluetooth_rfkill); |