Linux bluetooth development
 help / color / mirror / Atom feed
From: Suraj Sumangala <suraj@atheros.com>
To: <linux-bluetooth@vger.kernel.org>
Cc: <Jothikumar.Mothilal@Atheros.com>, Suraj Sumangala <suraj@atheros.com>
Subject: [PATCH] hciattach: send hci commands after hci socket bring up
Date: Fri, 19 Nov 2010 11:21:43 +0530	[thread overview]
Message-ID: <1290145903-11452-1-git-send-email-suraj@atheros.com> (raw)

This patch makes The Atheros AR300x specific initialization code
to send power management command over HCI socket after bringing up
the device.

---
 tools/hciattach_ath3k.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index b891506..70ade30 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -884,6 +884,8 @@ int ath3k_post(int fd, int pm)
 	int dev_id, dd;
 	struct timespec tm = { 0, 50000 };
 
+	sleep(1);
+
 	dev_id = ioctl(fd, HCIUARTGETDEVICE, 0);
 	if (dev_id < 0) {
 		perror("cannot get device id");
@@ -896,11 +898,15 @@ int ath3k_post(int fd, int pm)
 		return dd;
 	}
 
-	sleep(2);
+	if (ioctl(dd, HCIDEVUP, dev_id) < 0 && errno != EALREADY) {
+		perror("hci down:Power management Disabled");
+		hci_close_dev(dd);
+		return -1;
+	}
 
 	/* send vendor specific command with Sleep feature Enabled */
 	if (hci_send_cmd(dd, OGF_VENDOR_CMD, HCI_SLEEP_CMD_OCF,	1, &pm) < 0)
-		perror("Power management Disabled");
+		perror("PM command failed, power management Disabled");
 
 	nanosleep(&tm, NULL);
 	hci_close_dev(dd);
-- 
1.7.0.4


             reply	other threads:[~2010-11-19  5:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-19  5:51 Suraj Sumangala [this message]
2010-11-19 15:24 ` [PATCH] hciattach: send hci commands after hci socket bring up Johan Hedberg

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=1290145903-11452-1-git-send-email-suraj@atheros.com \
    --to=suraj@atheros.com \
    --cc=Jothikumar.Mothilal@Atheros.com \
    --cc=linux-bluetooth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox