public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: alokbarsode@gmail.com
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.com, Alok Barsode <alok.barsode@azingo.com>
Subject: [PATCH 2/3] Code cleanup in adapter.c.
Date: Mon,  4 May 2009 20:38:13 +0530	[thread overview]
Message-ID: <1241449694-17135-2-git-send-email-alok.barsode@azingo.com> (raw)
In-Reply-To: <1241449694-17135-1-git-send-email-alok.barsode@azingo.com>

From: Alok Barsode <alok.barsode@azingo.com>

Not passing device descriptor to adater_up.
---
 src/adapter.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 7ac361b..2135795 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2001,11 +2001,12 @@ static int get_pairable_timeout(const char *src)
 	return main_opts.pairto;
 }
 
-static int adapter_up(struct btd_adapter *adapter, int dd)
+static int adapter_up(struct btd_adapter *adapter)
 {
 	char mode[14], srcaddr[18];
 	uint8_t scan_mode;
 	gboolean powered, dev_down = FALSE;
+	int dd;
 
 	ba2str(&adapter->bdaddr, srcaddr);
 
@@ -2048,7 +2049,7 @@ static int adapter_up(struct btd_adapter *adapter, int dd)
 		else
 			write_device_mode(&adapter->bdaddr, mode);
 
-		return adapter_up(adapter, dd);
+		return adapter_up(adapter);
 	} else if (!g_str_equal(mode, "connectable") &&
 			adapter->discov_timeout == 0) {
 		/* Set discoverable only if timeout is 0 */
@@ -2058,10 +2059,16 @@ static int adapter_up(struct btd_adapter *adapter, int dd)
 	}
 
 proceed:
+	dd = hci_open_dev(adapter->dev_id);
+
+	if (dd < 0)
+		return -EIO;
+
 	if (dev_down == FALSE)
 		hci_send_cmd(dd, OGF_HOST_CTL, OCF_WRITE_SCAN_ENABLE,
 				1, &scan_mode);
 
+
 	if (adapter->initialized == FALSE) {
 		load_drivers(adapter);
 		load_devices(adapter);
@@ -2086,6 +2093,8 @@ proceed:
 					ADAPTER_INTERFACE, "Powered",
 					DBUS_TYPE_BOOLEAN, &powered);
 
+	hci_close_dev(dd);
+
 	return 0;
 }
 
@@ -2199,10 +2208,10 @@ setup:
 	adapter->state &= ~STD_INQUIRY;
 
 	adapter_setup(adapter, dd);
-	err = adapter_up(adapter, dd);
-
 	hci_close_dev(dd);
 
+	err = adapter_up(adapter);
+
 	info("Adapter %s has been enabled", adapter->path);
 
 	return err;
-- 
1.5.6.3


  reply	other threads:[~2009-05-04 15:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-04 15:08 [PATCH 1/3] Do not exit if adapter_ops setup fails alokbarsode
2009-05-04 15:08 ` alokbarsode [this message]
2009-05-04 15:08   ` [PATCH 3/3] Adding stop() functionality to hciops plugin alokbarsode
2009-05-04 15:30     ` Johan Hedberg
2009-05-04 15:27   ` [PATCH 2/3] Code cleanup in adapter.c Johan Hedberg
2009-05-04 15:25 ` [PATCH 1/3] Do not exit if adapter_ops setup fails 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=1241449694-17135-2-git-send-email-alok.barsode@azingo.com \
    --to=alokbarsode@gmail.com \
    --cc=alok.barsode@azingo.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.com \
    /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