aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzael Avalos <coproscefalo@gmail.com>2015-03-26 16:56:05 -0400
committerDarren Hart <dvhart@linux.intel.com>2015-03-26 17:15:07 -0400
commitbb2ea96b4840fb244e74ed7c470a3ec88e5b084a (patch)
tree541993e608d7c75f37dd2072063fb22be5acb0eb
parentfb42d1f491ebf6bb3e41b4dc93c5a1b1768e0df7 (diff)
toshiba_bluetooth: Add three new functions to the driver
This patch introduces three new functions, which are going to be used by the next patches. The functions introduced are toshiba_bluetooth_present, toshiba_bluetooth_status and toshiba_bluetooth_disable, which queries the presence of the device, queries the status and disables the device respectively. Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
-rw-r--r--drivers/platform/x86/toshiba_bluetooth.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index 2cb1ea62b4a7..b479a701d3a8 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -57,6 +57,38 @@ static struct acpi_driver toshiba_bt_rfkill_driver = {
57 .drv.pm = &toshiba_bt_pm, 57 .drv.pm = &toshiba_bt_pm,
58}; 58};
59 59
60static int toshiba_bluetooth_present(acpi_handle handle)
61{
62 acpi_status result;
63 u64 bt_present;
64
65 result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present);
66 if (ACPI_FAILURE(result)) {
67 pr_err("ACPI call to query Bluetooth presence failed");
68 return -ENXIO;
69 } else if (!bt_present) {
70 pr_info("Bluetooth device not present\n");
71 return -ENODEV;
72 }
73
74 return 0;
75}
76
77static int toshiba_bluetooth_status(acpi_handle handle)
78{
79 acpi_status result;
80 u64 status;
81
82 result = acpi_evaluate_integer(handle, "BTST", NULL, &status);
83 if (ACPI_FAILURE(result)) {
84 pr_err("Could not get Bluetooth device status\n");
85 return -ENXIO;
86 }
87
88 pr_info("Bluetooth status %llu\n", status);
89
90 return status;
91}
60 92
61static int toshiba_bluetooth_enable(acpi_handle handle) 93static int toshiba_bluetooth_enable(acpi_handle handle)
62{ 94{
@@ -85,6 +117,25 @@ static int toshiba_bluetooth_enable(acpi_handle handle)
85 return -ENODEV; 117 return -ENODEV;
86} 118}
87 119
120static int toshiba_bluetooth_disable(acpi_handle handle)
121{
122 acpi_status result;
123
124 result = acpi_evaluate_object(handle, "BTPF", NULL, NULL);
125 if (ACPI_FAILURE(result)) {
126 pr_err("Could not power OFF Bluetooth device\n");
127 return -ENXIO;
128 }
129
130 result = acpi_evaluate_object(handle, "DUSB", NULL, NULL);
131 if (ACPI_FAILURE(result)) {
132 pr_err("Could not detach USB Bluetooth device\n");
133 return -ENXIO;
134 }
135
136 return 0;
137}
138
88static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event) 139static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event)
89{ 140{
90 toshiba_bluetooth_enable(device->handle); 141 toshiba_bluetooth_enable(device->handle);