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>
This commit is contained in:
parent
b5f6f26550
commit
c9ddf8fede
|
@ -562,7 +562,7 @@ static int eeepc_hotk_add(struct acpi_device *device)
|
||||||
ehotk->device = device;
|
ehotk->device = device;
|
||||||
result = eeepc_hotk_check();
|
result = eeepc_hotk_check();
|
||||||
if (result)
|
if (result)
|
||||||
goto end;
|
goto ehotk_fail;
|
||||||
status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
|
status = acpi_install_notify_handler(ehotk->handle, ACPI_SYSTEM_NOTIFY,
|
||||||
eeepc_hotk_notify, ehotk);
|
eeepc_hotk_notify, ehotk);
|
||||||
if (ACPI_FAILURE(status))
|
if (ACPI_FAILURE(status))
|
||||||
|
@ -573,18 +573,25 @@ static int eeepc_hotk_add(struct acpi_device *device)
|
||||||
RFKILL_TYPE_WLAN);
|
RFKILL_TYPE_WLAN);
|
||||||
|
|
||||||
if (!ehotk->eeepc_wlan_rfkill)
|
if (!ehotk->eeepc_wlan_rfkill)
|
||||||
goto end;
|
goto wlan_fail;
|
||||||
|
|
||||||
ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan";
|
ehotk->eeepc_wlan_rfkill->name = "eeepc-wlan";
|
||||||
ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set;
|
ehotk->eeepc_wlan_rfkill->toggle_radio = eeepc_wlan_rfkill_set;
|
||||||
ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state;
|
ehotk->eeepc_wlan_rfkill->get_state = eeepc_wlan_rfkill_state;
|
||||||
if (get_acpi(CM_ASL_WLAN) == 1)
|
if (get_acpi(CM_ASL_WLAN) == 1) {
|
||||||
ehotk->eeepc_wlan_rfkill->state =
|
ehotk->eeepc_wlan_rfkill->state =
|
||||||
RFKILL_STATE_UNBLOCKED;
|
RFKILL_STATE_UNBLOCKED;
|
||||||
else
|
rfkill_set_default(RFKILL_TYPE_WLAN,
|
||||||
|
RFKILL_STATE_UNBLOCKED);
|
||||||
|
} else {
|
||||||
ehotk->eeepc_wlan_rfkill->state =
|
ehotk->eeepc_wlan_rfkill->state =
|
||||||
RFKILL_STATE_SOFT_BLOCKED;
|
RFKILL_STATE_SOFT_BLOCKED;
|
||||||
rfkill_register(ehotk->eeepc_wlan_rfkill);
|
rfkill_set_default(RFKILL_TYPE_WLAN,
|
||||||
|
RFKILL_STATE_SOFT_BLOCKED);
|
||||||
|
}
|
||||||
|
result = rfkill_register(ehotk->eeepc_wlan_rfkill);
|
||||||
|
if (result)
|
||||||
|
goto wlan_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_acpi(CM_ASL_BLUETOOTH) != -1) {
|
if (get_acpi(CM_ASL_BLUETOOTH) != -1) {
|
||||||
|
@ -592,27 +599,43 @@ static int eeepc_hotk_add(struct acpi_device *device)
|
||||||
rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH);
|
rfkill_allocate(&device->dev, RFKILL_TYPE_BLUETOOTH);
|
||||||
|
|
||||||
if (!ehotk->eeepc_bluetooth_rfkill)
|
if (!ehotk->eeepc_bluetooth_rfkill)
|
||||||
goto end;
|
goto bluetooth_fail;
|
||||||
|
|
||||||
ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth";
|
ehotk->eeepc_bluetooth_rfkill->name = "eeepc-bluetooth";
|
||||||
ehotk->eeepc_bluetooth_rfkill->toggle_radio =
|
ehotk->eeepc_bluetooth_rfkill->toggle_radio =
|
||||||
eeepc_bluetooth_rfkill_set;
|
eeepc_bluetooth_rfkill_set;
|
||||||
ehotk->eeepc_bluetooth_rfkill->get_state =
|
ehotk->eeepc_bluetooth_rfkill->get_state =
|
||||||
eeepc_bluetooth_rfkill_state;
|
eeepc_bluetooth_rfkill_state;
|
||||||
if (get_acpi(CM_ASL_BLUETOOTH) == 1)
|
if (get_acpi(CM_ASL_BLUETOOTH) == 1) {
|
||||||
ehotk->eeepc_bluetooth_rfkill->state =
|
ehotk->eeepc_bluetooth_rfkill->state =
|
||||||
RFKILL_STATE_UNBLOCKED;
|
RFKILL_STATE_UNBLOCKED;
|
||||||
else
|
rfkill_set_default(RFKILL_TYPE_BLUETOOTH,
|
||||||
|
RFKILL_STATE_UNBLOCKED);
|
||||||
|
} else {
|
||||||
ehotk->eeepc_bluetooth_rfkill->state =
|
ehotk->eeepc_bluetooth_rfkill->state =
|
||||||
RFKILL_STATE_SOFT_BLOCKED;
|
RFKILL_STATE_SOFT_BLOCKED;
|
||||||
rfkill_register(ehotk->eeepc_bluetooth_rfkill);
|
rfkill_set_default(RFKILL_TYPE_BLUETOOTH,
|
||||||
}
|
RFKILL_STATE_SOFT_BLOCKED);
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
result = rfkill_register(ehotk->eeepc_bluetooth_rfkill);
|
||||||
if (result) {
|
if (result)
|
||||||
kfree(ehotk);
|
goto bluetooth_fail;
|
||||||
ehotk = NULL;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
bluetooth_fail:
|
||||||
|
if (ehotk->eeepc_bluetooth_rfkill)
|
||||||
|
rfkill_free(ehotk->eeepc_bluetooth_rfkill);
|
||||||
|
rfkill_unregister(ehotk->eeepc_wlan_rfkill);
|
||||||
|
ehotk->eeepc_wlan_rfkill = NULL;
|
||||||
|
wlan_fail:
|
||||||
|
if (ehotk->eeepc_wlan_rfkill)
|
||||||
|
rfkill_free(ehotk->eeepc_wlan_rfkill);
|
||||||
|
ehotk_fail:
|
||||||
|
kfree(ehotk);
|
||||||
|
ehotk = NULL;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue