linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tedd Ho-Jeong An <tedd.an@intel.com>
To: linux-bluetooth <linux-bluetooth@vger.kernel.org>
Cc: marcel <marcel@holtmann.org>, albert.o.ho@intel.com
Subject: [RFC 3/3] Bluetooth: Add timeout for Intel specific device initialization
Date: Mon, 10 Sep 2012 15:35:41 -0700	[thread overview]
Message-ID: <2047428.SOUXqlU6Wn@tedd-ubuntu> (raw)

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch adds the tiemout for Intel specific device initialization.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
---
 drivers/bluetooth/btusb_intel.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/bluetooth/btusb_intel.c b/drivers/bluetooth/btusb_intel.c
index d45ddb9..3657203 100644
--- a/drivers/bluetooth/btusb_intel.c
+++ b/drivers/bluetooth/btusb_intel.c
@@ -30,6 +30,9 @@
 
 #include "btusb.h"
 
+/* patch timeout - 10 seconds */
+#define INTEL_PATCH_TIMEOUT		msecs_to_jiffies(10000)
+
 /* Intel specific HCI cmd opcodes */
 #define INTEL_HCI_MFG_MODE		0xfc11
 #define INTEL_HCI_GET_VER		0xfc05
@@ -71,6 +74,7 @@ struct intel_patch_data {
 	u8			patch_reset;
 
 	struct completion	wait_patch_completion;
+	struct timer_list	patch_timeout;
 
 	char			device_ver[32];
 	const struct firmware	*fw;
@@ -222,6 +226,16 @@ static int intel_prepare_patch_file(struct intel_patch_data *data)
 	return 0;
 }
 
+static void intel_patch_timeout(unsigned long arg)
+{
+	struct intel_patch_data *data = (void *)arg;
+
+	BT_ERR("patch timer expired");
+	data->state = INTEL_PATCH_ERROR;
+
+	complete(&data->wait_patch_completion);
+}
+
 int btusb_intel_init(struct hci_dev *hdev)
 {
 	int ret;
@@ -243,6 +257,10 @@ int btusb_intel_init(struct hci_dev *hdev)
 
 	init_completion(&data->wait_patch_completion);
 
+	setup_timer(&data->patch_timeout, intel_patch_timeout,
+		    (unsigned long) data);
+	mod_timer(&data->patch_timeout, jiffies + INTEL_PATCH_TIMEOUT);
+
 	while (cont) {
 		BT_DBG("patch state: %d", data->state);
 		switch (data->state) {
@@ -324,6 +342,7 @@ skip_wait:
 	}
 
 exit_error:
+	del_timer_sync(&data->patch_timeout);
 	release_firmware(data->fw);
 	kfree(data);
 
-- 
1.7.9.5

             reply	other threads:[~2012-09-10 22:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-10 22:35 Tedd Ho-Jeong An [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-09-10 21:29 [RFC 3/3] Bluetooth: Add timeout for Intel specific device initialization Tedd Ho-Jeong An

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=2047428.SOUXqlU6Wn@tedd-ubuntu \
    --to=tedd.an@intel.com \
    --cc=albert.o.ho@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).