forked from Minki/linux
toshiba_bluetooth: Clean up *_add function and disable BT device at removal
This patch cleans the toshiba_bluetooth_add function by using the recently introduced function toshiba_bluetooth_present, simplifying its code and returning appropriate error values. Also, disables the BT device at the removal of the driver, by using the function toshiba_bluetooth_disable. Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
This commit is contained in:
parent
bb2ea96b48
commit
18b8696b66
@ -62,6 +62,11 @@ static int toshiba_bluetooth_present(acpi_handle handle)
|
|||||||
acpi_status result;
|
acpi_status result;
|
||||||
u64 bt_present;
|
u64 bt_present;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some Toshiba laptops may have a fake TOS6205 device in
|
||||||
|
* their ACPI BIOS, so query the _STA method to see if there
|
||||||
|
* is really anything there.
|
||||||
|
*/
|
||||||
result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present);
|
result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present);
|
||||||
if (ACPI_FAILURE(result)) {
|
if (ACPI_FAILURE(result)) {
|
||||||
pr_err("ACPI call to query Bluetooth presence failed");
|
pr_err("ACPI call to query Bluetooth presence failed");
|
||||||
@ -150,23 +155,18 @@ static int toshiba_bt_resume(struct device *dev)
|
|||||||
|
|
||||||
static int toshiba_bt_rfkill_add(struct acpi_device *device)
|
static int toshiba_bt_rfkill_add(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
acpi_status status;
|
int result;
|
||||||
u64 bt_present;
|
|
||||||
int result = -ENODEV;
|
|
||||||
|
|
||||||
/*
|
result = toshiba_bluetooth_present(device->handle);
|
||||||
* Some Toshiba laptops may have a fake TOS6205 device in
|
if (result)
|
||||||
* their ACPI BIOS, so query the _STA method to see if there
|
return result;
|
||||||
* is really anything there, before trying to enable it.
|
|
||||||
*/
|
|
||||||
status = acpi_evaluate_integer(device->handle, "_STA", NULL,
|
|
||||||
&bt_present);
|
|
||||||
|
|
||||||
if (!ACPI_FAILURE(status) && bt_present) {
|
pr_info("Toshiba ACPI Bluetooth device driver\n");
|
||||||
pr_info("Detected Toshiba ACPI Bluetooth device - "
|
|
||||||
"installing RFKill handler\n");
|
/* Enable the BT device */
|
||||||
result = toshiba_bluetooth_enable(device->handle);
|
result = toshiba_bluetooth_enable(device->handle);
|
||||||
}
|
if (result)
|
||||||
|
return result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ static int toshiba_bt_rfkill_add(struct acpi_device *device)
|
|||||||
static int toshiba_bt_rfkill_remove(struct acpi_device *device)
|
static int toshiba_bt_rfkill_remove(struct acpi_device *device)
|
||||||
{
|
{
|
||||||
/* clean up */
|
/* clean up */
|
||||||
return 0;
|
return toshiba_bluetooth_disable(device->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_acpi_driver(toshiba_bt_rfkill_driver);
|
module_acpi_driver(toshiba_bt_rfkill_driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user