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