All of lore.kernel.org
 help / color / mirror / Atom feed
From: Azael Avalos <coproscefalo@gmail.com>
To: Darren Hart <dvhart@infradead.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Azael Avalos <coproscefalo@gmail.com>
Subject: [PATCH 4/4] toshiba_bluetooth: Remove BT enable code from *_notify function
Date: Wed, 18 Mar 2015 13:12:59 -0600	[thread overview]
Message-ID: <1426705979-11880-6-git-send-email-coproscefalo@gmail.com> (raw)
In-Reply-To: <1426705979-11880-1-git-send-email-coproscefalo@gmail.com>

Bug 93911 reported a broken handling of the BT device, causing the
driver to get stuck in a loop enabling/disabling the device whenever
the device is deactivated by the kill switch as follows:

1. The user activated the kill switch, causing the system to generate
   a 0x90 (status change) event and disabling the BT device.
2. The driver catches the event and re-enables the BT device.
3. The system detects the device being activated, but since the kill
   switch is activated, disables the BT device (again) and generates
   a 0x90 event (again).
4. Repeat from 2.

This patch removes the toshiba_bluetooth_enable call from the
toshiba_bluetooth_notify function, as we do not always need to
re-activate the device everytime we receive an event, we need to act
depending on the status of the BT device.

For now, we simply print the event received and the status of the BT
device, so we can later add code to handle special circumstances
depending on the status of the device.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
---
 drivers/platform/x86/toshiba_bluetooth.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
index 0343d20..07edded 100644
--- a/drivers/platform/x86/toshiba_bluetooth.c
+++ b/drivers/platform/x86/toshiba_bluetooth.c
@@ -2,6 +2,7 @@
  * Toshiba Bluetooth Enable Driver
  *
  * Copyright (C) 2009 Jes Sorensen <Jes.Sorensen@gmail.com>
+ * Copyright (C) 2015 Azael Avalos <coproscefalo@gmail.com>
  *
  * Thanks to Matthew Garrett for background info on ACPI innards which
  * normal people aren't meant to understand :-)
@@ -25,6 +26,10 @@
 #include <linux/types.h>
 #include <linux/acpi.h>
 
+#define BT_KILLSWITCH_MASK	0x01
+#define BT_PLUGGED_MASK		0x40
+#define BT_POWER_MASK		0x80
+
 MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>");
 MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
 MODULE_LICENSE("GPL");
@@ -135,7 +140,20 @@ static int toshiba_bluetooth_disable(acpi_handle handle)
 
 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event)
 {
-	toshiba_bluetooth_enable(device->handle);
+	int status;
+
+	pr_info("Received event %x\n", event);
+
+	/* Query the status of the Bluetooth device */
+	status = toshiba_bluetooth_status(device->handle);
+	if (status < 0)
+		return;
+
+	pr_info("Switch status %x\n", status & BT_KILLSWITCH_MASK);
+	pr_info("Power status %x\n", status & BT_POWER_MASK);
+	pr_info("Plug status %x\n", status & BT_PLUGGED_MASK);
+
+	/* TODO: Add event handling here depending on Bluetooth status */
 }
 
 #ifdef CONFIG_PM_SLEEP
-- 
2.2.2


  parent reply	other threads:[~2015-03-18 19:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18 19:12 [PATCH 0/4] toshiba_bluetooth: Clean up driver plus a bugfix Azael Avalos
2015-03-18 19:12 ` [PATCH 1/4] toshiba_bluetooth: Add three new functions to the driver Azael Avalos
2015-03-18 19:12 ` [PATCH 2/4] toshiba_bluetooth: Clean up *_add function and disable BT device at removal Azael Avalos
2015-03-18 19:12 ` [PATCH 3/4] toshiba_bluetooth: Clean toshiba_bluetooth_enable function Azael Avalos
2015-03-18 19:12 ` Azael Avalos
2015-03-18 19:12 ` Azael Avalos [this message]
2015-03-25 17:50   ` [PATCH 4/4] toshiba_bluetooth: Remove BT enable code from *_notify function Darren Hart
2015-03-25 19:01     ` Azael Avalos
2015-03-25 19:01       ` Azael Avalos
2015-03-25 17:51 ` [PATCH 0/4] toshiba_bluetooth: Clean up driver plus a bugfix Darren Hart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426705979-11880-6-git-send-email-coproscefalo@gmail.com \
    --to=coproscefalo@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.