eeepc-laptop: Check return values from rfkill_register

Error out if rfkill registration fails, and also set the default system state
appropriately on boot

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by Matthew Garrett and committed by Len Brown c9ddf8fe b5f6f265

+37 -14
+37 -14
drivers/platform/x86/eeepc-laptop.c
··· 562 562 ehotk->device = device; 563 563 result = eeepc_hotk_check(); 564 564 if (result) 565 - goto end; 565 + goto ehotk_fail; 566 566 status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY, 567 567 eeepc_hotk_notify, ehotk); 568 568 if (ACPI_FAILURE(status)) ··· 573 573 RFKILL_TYPE_WLAN); 574 574 575 575 if (!ehotk->eeepc_wlan_rfkill) 576 - goto end; 576 + goto wlan_fail; 577 577 578 578 ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan"; 579 579 ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set; 580 580 ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state; 581 - if (get_acpi(CM_ASL_WLAN) == 1) 581 + if (get_acpi(CM_ASL_WLAN) == 1) { 582 582 ehotk->eeepc_wlan_rfkill->state = 583 583 RFKILL_STATE_UNBLOCKED; 584 - else 584 + rfkill_set_default(RFKILL_TYPE_WLAN, 585 + RFKILL_STATE_UNBLOCKED); 586 + } else { 585 587 ehotk->eeepc_wlan_rfkill->state = 586 588 RFKILL_STATE_SOFT_BLOCKED; 587 - rfkill_register(ehotk->eeepc_wlan_rfkill); 589 + rfkill_set_default(RFKILL_TYPE_WLAN, 590 + RFKILL_STATE_SOFT_BLOCKED); 591 + } 592 + result = rfkill_register(ehotk->eeepc_wlan_rfkill); 593 + if (result) 594 + goto wlan_fail; 588 595 } 589 596 590 597 if (get_acpi(CM_ASL_BLUETOOTH) != -1) { ··· 599 592 rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH); 600 593 601 594 if (!ehotk->eeepc_bluetooth_rfkill) 602 - goto end; 595 + goto bluetooth_fail; 603 596 604 597 ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth"; 605 598 ehotk->eeepc_bluetooth_rfkill->toggle_radio = 606 599 eeepc_bluetooth_rfkill_set; 607 600 ehotk->eeepc_bluetooth_rfkill->get_state = 608 601 eeepc_bluetooth_rfkill_state; 609 - if (get_acpi(CM_ASL_BLUETOOTH) == 1) 602 + if (get_acpi(CM_ASL_BLUETOOTH) == 1) { 610 603 ehotk->eeepc_bluetooth_rfkill->state = 611 604 RFKILL_STATE_UNBLOCKED; 612 - else 605 + rfkill_set_default(RFKILL_TYPE_BLUETOOTH, 606 + RFKILL_STATE_UNBLOCKED); 607 + } else { 613 608 ehotk->eeepc_bluetooth_rfkill->state = 614 609 RFKILL_STATE_SOFT_BLOCKED; 615 - rfkill_register(ehotk->eeepc_bluetooth_rfkill); 616 - } 610 + rfkill_set_default(RFKILL_TYPE_BLUETOOTH, 611 + RFKILL_STATE_SOFT_BLOCKED); 612 + } 617 613 618 - end: 619 - if (result) { 620 - kfree(ehotk); 621 - ehotk = NULL; 614 + result = rfkill_register(ehotk->eeepc_bluetooth_rfkill); 615 + if (result) 616 + goto bluetooth_fail; 622 617 } 618 + return 0; 619 + 620 + bluetooth_fail: 621 + if (ehotk->eeepc_bluetooth_rfkill) 622 + rfkill_free(ehotk->eeepc_bluetooth_rfkill); 623 + rfkill_unregister(ehotk->eeepc_wlan_rfkill); 624 + ehotk->eeepc_wlan_rfkill = NULL; 625 + wlan_fail: 626 + if (ehotk->eeepc_wlan_rfkill) 627 + rfkill_free(ehotk->eeepc_wlan_rfkill); 628 + ehotk_fail: 629 + kfree(ehotk); 630 + ehotk = NULL; 631 + 623 632 return result; 624 633 } 625 634