Skip to contentSkip to conversation

toshiba_acpi: Add support for bluetooth toggling through rfkill (v5)

PATCH In review Philip Langdale 2 participants 3 messages Aug 16, 2008 – Aug 20, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toshiba_acpi: Add support for bluetooth toggling through rfkill (v5)

There's been a patch floating around for toshiba_acpi that exports an ad-hoc /proc interface to toggle the bluetooth adapter in a large number of Toshiba laptops. I'm not sure if it's still relevant for the latest models, but it is still required for older models such as my Tecra M3.

This change pulls in the low level Toshiba-specific code from the old patch and sets up an rfkill device and a polled input device to track the state of the hardware kill-switch.

---
 Kconfig        |    1
 toshiba_acpi.c |  264 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 257 insertions(+), 8 deletions(-)
drivers/acpi/Kconfig +1 -0
index 735f5ea..047829c 100644
@@ -260,6 +260,7 @@ config ACPI_ASUS
 config ACPI_TOSHIBA
 	tristate "Toshiba Laptop Extras"
 	depends on X86
+	select INPUT_POLLDEV
 	select BACKLIGHT_CLASS_DEVICE
 	---help---
 	  This driver adds support for access to certain system settings
drivers/acpi/toshiba_acpi.c +256 -8

353 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Philip Langdale
drivers/acpi/toshiba_acpi.c +2 -1
@@ -607,7 +796,66 @@ static int __init toshiba_acpi_init(void)
 	}
         toshiba_backlight_device->props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1;
 
-	return (ACPI_SUCCESS(status)) ? 0 : -ENODEV;
+	/* Register rfkill switch for Bluetooth */
+	if (hci_get_bt_present(&bt_present) == HCI_SUCCESS && bt_present) {

drivers/acpi/toshiba_acpi.c static int __init toshiba_acpi_init(void) · line 810

Quoted 10 lines
drivers/acpi/toshiba_acpi.c +10 -0
+		toshiba_acpi.rfk_dev = rfkill_allocate(&toshiba_acpi.p_dev->dev,
+							RFKILL_TYPE_BLUETOOTH);
+		if (!toshiba_acpi.rfk_dev) {
+			printk(MY_ERR "unable to allocate rfkill device\n");
+			toshiba_acpi_exit();
+			return -ENOMEM;
+		}
+
+		toshiba_acpi.rfk_dev->name = toshiba_acpi.bt_name;
+		toshiba_acpi.rfk_dev->state = RFKILL_STATE_OFF;

Where did that RFKILL_STATE_OFF came from ? :-) Just get rid of it, you override it four statements later anyway...

drivers/acpi/toshiba_acpi.c static int __init toshiba_acpi_init(void) · line 821

Quoted 11 lines
drivers/acpi/toshiba_acpi.c +11 -0
+		toshiba_acpi.rfk_dev->toggle_radio = bt_rfkill_toggle_radio;
+		toshiba_acpi.rfk_dev->user_claim_unsupported = 1;
+		toshiba_acpi.rfk_dev->data = &toshiba_acpi;
+
+		if (hci_get_bt_on(&bt_on) == HCI_SUCCESS && bt_on) {
+			toshiba_acpi.rfk_dev->state = RFKILL_STATE_UNBLOCKED;
+		} else if (hci_get_radio_state(&radio_on) == HCI_SUCCESS && radio_on) {
+			toshiba_acpi.rfk_dev->state = RFKILL_STATE_SOFT_BLOCKED;
+		} else {
+			toshiba_acpi.rfk_dev->state = RFKILL_STATE_HARD_BLOCKED;
+		}

i.e. in the code above.

Other than that, the rfkill bits look fine to me.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#2 lore raw
Quoted 4 lines · Henrique de Moraes Holschuh

drivers/acpi/toshiba_acpi.c static int __init toshiba_acpi_init(void) · line 810

Quoted 1 line
drivers/acpi/toshiba_acpi.c +1 -0
+		toshiba_acpi.rfk_dev->state = RFKILL_STATE_OFF;

Where did that RFKILL_STATE_OFF came from ? :-) Just get rid of it, you override it four statements later anyway...

Left over from the first iteration. Now removed and diff updated.

Quoted 3 lines

Other than that, the rfkill bits look fine to me.

Thanks. Anyone else care to voice an opinion? Should this go in through wireless-testing then?

--phil