aboutsummaryrefslogtreecommitdiff
path: root/tools/hciattach_ath3k.c
diff options
context:
space:
mode:
authorSuraj Sumangala <suraj@atheros.com>2010-11-19 11:21:43 +0530
committerJohan Hedberg <johan.hedberg@nokia.com>2010-11-19 17:24:17 +0200
commit0e32ca24d11a83acf5f54f914dfed9ffb9da5610 (patch)
tree15d88997621791c2b66e2540eb9168f4ed8e658e /tools/hciattach_ath3k.c
parentf9523a9bf583d9979b0157f8615d2a914ee588e8 (diff)
downloadbluez-0e32ca24d11a83acf5f54f914dfed9ffb9da5610.tar.gz
hciattach: send hci commands after hci socket bring up
This patch makes The Atheros AR300x specific initialization code to send power management command over HCI socket after bringing up the device.
Diffstat (limited to 'tools/hciattach_ath3k.c')
-rw-r--r--tools/hciattach_ath3k.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index b891506a..70ade304 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);