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.org, Alok Barsode <alok.barsode@azingo.com>
Subject: [PATCH 5/7] Modifying load_connections method.
Date: Mon, 18 May 2009 15:19:11 +0530	[thread overview]
Message-ID: <1242640153-23420-5-git-send-email-alok.barsode@azingo.com> (raw)
In-Reply-To: <1242640153-23420-4-git-send-email-alok.barsode@azingo.com>

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

---
 src/adapter.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index cd18412..73e6d80 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1935,11 +1935,15 @@ static void load_drivers(struct btd_adapter *adapter)
 	}
 }
 
-static void load_connections(struct btd_adapter *adapter, int dd)
+static void load_connections(struct btd_adapter *adapter)
 {
 	struct hci_conn_list_req *cl = NULL;
 	struct hci_conn_info *ci;
-	int i;
+	int i, dd;
+
+	dd = hci_open_dev(adapter->dev_id);
+	if (dd < 0)
+		return;
 
 	cl = g_malloc0(10 * sizeof(*ci) + sizeof(*cl));
 
@@ -1949,6 +1953,7 @@ static void load_connections(struct btd_adapter *adapter, int dd)
 
 	if (ioctl(dd, HCIGETCONNLIST, cl) != 0) {
 		g_free(cl);
+		hci_close_dev(dd);
 		return;
 	}
 
@@ -1963,6 +1968,7 @@ static void load_connections(struct btd_adapter *adapter, int dd)
 	}
 
 	g_free(cl);
+	hci_close_dev(dd);
 }
 
 static int get_discoverable_timeout(const char *src)
@@ -1990,7 +1996,7 @@ static int adapter_up(struct btd_adapter *adapter)
 	char mode[14], srcaddr[18];
 	uint8_t scan_mode;
 	gboolean powered, dev_down = FALSE;
-	int dd, err;
+	int err;
 
 	ba2str(&adapter->bdaddr, srcaddr);
 
@@ -2055,19 +2061,14 @@ proceed:
 		load_drivers(adapter);
 		load_devices(adapter);
 
-		dd = hci_open_dev(adapter->dev_id);
-		if (dd < 0)
-			return -EIO;
-
 		/* retrieve the active connections: address the scenario where
 		 * the are active connections before the daemon've started */
-		load_connections(adapter, dd);
+		load_connections(adapter);
 
 		adapter->initialized = TRUE;
 
 		manager_add_adapter(adapter->path);
 
-		hci_close_dev(dd);
 	}
 
 	if (adapter->svc_cache)
-- 
1.5.6.3

  reply	other threads:[~2009-05-18  9:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-18  9:49 [PATCH 1/7] Using hci_send_cmd instead of hci_send_req to set scan mode alokbarsode
2009-05-18  9:49 ` [PATCH 2/7] Adding set_powered method to hciops plugin alokbarsode
2009-05-18  9:49   ` [PATCH 3/7] Adding set_connectable " alokbarsode
2009-05-18  9:49     ` [PATCH 4/7] Adding set_discoverable method to hciops alokbarsode
2009-05-18  9:49       ` alokbarsode [this message]
2009-05-18  9:49         ` [PATCH 6/7] Adding set_limited_discoverable method to hciops plugin alokbarsode
2009-05-18  9:49           ` [PATCH 7/7] Code cleanup in set_mode alokbarsode
  -- strict thread matches above, loose matches on Subject: below --
2009-05-12 12:26 [PATCH 1/7] Using hci_send_cmd instead of hci_send_req to set scan mode alokbarsode
2009-05-12 12:26 ` [PATCH 2/7] Adding set_powered method to hciops plugin alokbarsode
2009-05-12 12:26   ` [PATCH 3/7] Adding set_connectable " alokbarsode
2009-05-12 12:26     ` [PATCH 4/7] Adding set_discoverable method to hciops alokbarsode
2009-05-12 12:26       ` [PATCH 5/7] Modifying load_connections method alokbarsode

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=1242640153-23420-5-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.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