Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v10 2/6] doc: Update settings-storage.txt
From: Frédéric Danis @ 2012-10-30 17:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351616728-10075-1-git-send-email-frederic.danis@linux.intel.com>

Device name should be saved in device info file.
---
 doc/settings-storage.txt |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 93184d1..1174d44 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -132,6 +132,8 @@ Long term key) related to a remote device.
 
 [General] group contains:
 
+  Name			String		Remote device friendly name
+
   Alias			String		Alias name
 
   Class			String		Device class in hexadecimal,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v10 3/6] device: Retrieve name from storage
From: Frédéric Danis @ 2012-10-30 17:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351616728-10075-1-git-send-email-frederic.danis@linux.intel.com>

Try to retrieve name from device info file.
If that fails fall back to the cache and save it to device info file.

When device name is updated, save it.
---
 src/device.c |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 101 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index bc7f8dd..9749bfd 100644
--- a/src/device.c
+++ b/src/device.c
@@ -76,6 +76,9 @@
 #define DISCONNECT_TIMER	2
 #define DISCOVERY_TIMER		2
 
+#define INFO_PATH STORAGEDIR "/%s/%s/info"
+#define CACHE_PATH STORAGEDIR "/%s/cache/%s"
+
 struct btd_disconnect_data {
 	guint id;
 	disconnect_watch watch;
@@ -202,6 +205,36 @@ static uint16_t uuid_list[] = {
 	0
 };
 
+static void store_device_info(struct btd_device *device)
+{
+	GKeyFile *key_file;
+	char filename[PATH_MAX + 1];
+	char adapter_addr[18];
+	char device_addr[18];
+	char *str;
+	gsize length = 0;
+
+	if (device->temporary)
+		return;
+
+	key_file = g_key_file_new();
+
+	g_key_file_set_string(key_file, "General", "Name", device->name);
+
+	ba2str(adapter_get_address(device->adapter), adapter_addr);
+	ba2str(&device->bdaddr, device_addr);
+	snprintf(filename, PATH_MAX, INFO_PATH, adapter_addr, device_addr);
+	filename[PATH_MAX] = '\0';
+
+	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+	str = g_key_file_to_data(key_file, &length, NULL);
+	g_file_set_contents(filename, str, length, NULL);
+	g_free(str);
+
+	g_key_file_free(key_file);
+}
+
 static void browse_request_free(struct browse_req *req)
 {
 	if (req->listener_id)
@@ -1564,6 +1597,70 @@ static void device_set_version(struct btd_device *device, uint16_t value)
 						DEVICE_INTERFACE, "Version");
 }
 
+static char *load_cached_name(struct btd_device *device, const char *local,
+				const gchar *peer)
+{
+	char filename[PATH_MAX + 1];
+	GKeyFile *key_file;
+	char *str = NULL;
+	int len;
+
+	snprintf(filename, PATH_MAX, CACHE_PATH, local, peer);
+	filename[PATH_MAX] = '\0';
+
+	key_file = g_key_file_new();
+
+	if (!g_key_file_load_from_file(key_file, filename, 0, NULL))
+		goto failed;
+
+	str = g_key_file_get_string(key_file, "General", "Name", NULL);
+	if (str) {
+		len = strlen(str);
+		if (len > HCI_MAX_NAME_LENGTH)
+			str[HCI_MAX_NAME_LENGTH] = '\0';
+	}
+
+failed:
+	g_key_file_free(key_file);
+
+	return str;
+}
+
+static void load_info(struct btd_device *device, const gchar *local,
+			const gchar *peer)
+{
+	char filename[PATH_MAX + 1];
+	GKeyFile *key_file;
+	char *str;
+	gboolean store_needed = FALSE;
+
+	snprintf(filename, PATH_MAX, INFO_PATH, local, peer);
+	filename[PATH_MAX] = '\0';
+
+	key_file = g_key_file_new();
+	g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+	/* Load device name from storage info file, if that fails fall back to
+	 * the cache.
+	 */
+	str = g_key_file_get_string(key_file, "General", "Name", NULL);
+	if (str == NULL) {
+		str = load_cached_name(device, local, peer);
+		if (str)
+			store_needed = TRUE;
+	}
+
+	if (str) {
+		strcpy(device->name, str);
+		g_free(str);
+	}
+
+	if (store_needed)
+		store_device_info(device);
+
+	g_key_file_free(key_file);
+}
+
 struct btd_device *device_create(struct btd_adapter *adapter,
 				const gchar *address, uint8_t bdaddr_type)
 {
@@ -1600,7 +1697,8 @@ struct btd_device *device_create(struct btd_adapter *adapter,
 	src = adapter_get_address(adapter);
 	ba2str(src, srcaddr);
 
-	read_device_name(srcaddr, address, bdaddr_type, device->name);
+	load_info(device, srcaddr, address);
+
 	if (read_device_alias(srcaddr, address, bdaddr_type, alias,
 							sizeof(alias)) == 0)
 		device->alias = g_strdup(alias);
@@ -1640,6 +1738,8 @@ void device_set_name(struct btd_device *device, const char *name)
 
 	strncpy(device->name, name, MAX_NAME_LENGTH);
 
+	store_device_info(device);
+
 	g_dbus_emit_property_changed(btd_get_dbus_connection(), device->path,
 						DEVICE_INTERFACE, "Name");
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v10 4/6] dbusoob: Set device name in device object
From: Frédéric Danis @ 2012-10-30 17:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351616728-10075-1-git-send-email-frederic.danis@linux.intel.com>

---
 plugins/dbusoob.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 5c5b6ef..0278941 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -193,6 +193,7 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
 
 static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 {
+	bdaddr_t local = *adapter_get_address(adapter);
 	bdaddr_t bdaddr;
 
 	str2ba(data->addr, &bdaddr);
@@ -207,9 +208,13 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 		write_remote_class(adapter_get_address(adapter), &bdaddr,
 								data->class);
 
-	if (data->name)
-		write_device_name(adapter_get_address(adapter), &bdaddr, 0,
-								data->name);
+	if (data->name) {
+		char *str;
+
+		str = g_strdup(data->name);
+		btd_event_remote_name(&local, &bdaddr, str);
+		g_free(str);
+	}
 
 	return TRUE;
 }
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v10 5/6] input: Retrieve device name from device object
From: Frédéric Danis @ 2012-10-30 17:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351616728-10075-1-git-send-email-frederic.danis@linux.intel.com>

---
 profiles/input/device.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index fbc3d6f..108be39 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -777,7 +777,7 @@ static struct input_device *input_device_new(struct btd_device *device,
 {
 	struct btd_adapter *adapter = device_get_adapter(device);
 	struct input_device *idev;
-	char name[249], src_addr[18], dst_addr[18];
+	char name[HCI_MAX_NAME_LENGTH + 1];
 
 	idev = g_new0(struct input_device, 1);
 	bacpy(&idev->src, adapter_get_address(adapter));
@@ -787,11 +787,8 @@ static struct input_device *input_device_new(struct btd_device *device,
 	idev->handle = handle;
 	idev->disable_sdp = disable_sdp;
 
-	ba2str(&idev->src, src_addr);
-	ba2str(&idev->dst, dst_addr);
-
-	if (read_device_name(src_addr, dst_addr, device_get_addr_type(device),
-				name) == 0)
+	device_get_name(device, name, HCI_MAX_NAME_LENGTH);
+	if (strlen(name) > 0)
 		idev->name = g_strdup(name);
 
 	if (g_dbus_register_interface(btd_get_dbus_connection(),
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v10 6/6] hcitool: Retrieve names from cache directory
From: Frédéric Danis @ 2012-10-30 17:05 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351616728-10075-1-git-send-email-frederic.danis@linux.intel.com>

---
 Makefile.tools  |    2 +-
 tools/hcitool.c |   31 ++++++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/Makefile.tools b/Makefile.tools
index ec79cea..f7c85ef 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -28,7 +28,7 @@ tools_hciconfig_LDADD = lib/libbluetooth-private.la
 
 tools_hcitool_SOURCES = tools/hcitool.c src/oui.h src/oui.c \
 						src/textfile.h src/textfile.c
-tools_hcitool_LDADD = lib/libbluetooth-private.la
+tools_hcitool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
 
 tools_sdptool_SOURCES = tools/sdptool.c src/sdp-xml.h src/sdp-xml.c
 tools_sdptool_LDADD = lib/libbluetooth-private.la @GLIB_LIBS@
diff --git a/tools/hcitool.c b/tools/hcitool.c
index aefbd68..a05e31f 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -40,6 +40,8 @@
 #include <sys/socket.h>
 #include <signal.h>
 
+#include <glib.h>
+
 #include <bluetooth/bluetooth.h>
 #include <bluetooth/hci.h>
 #include <bluetooth/hci_lib.h>
@@ -409,13 +411,32 @@ static char *major_classes[] = {
 
 static char *get_device_name(const bdaddr_t *local, const bdaddr_t *peer)
 {
-	char filename[PATH_MAX + 1], addr[18];
+	char filename[PATH_MAX + 1];
+	char local_addr[18], peer_addr[18];
+	GKeyFile *key_file;
+	char *str = NULL;
+	int len;
+
+	ba2str(local, local_addr);
+	ba2str(peer, peer_addr);
+
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", local_addr,
+			peer_addr);
+	filename[PATH_MAX] = '\0';
+	key_file = g_key_file_new();
+
+	if (g_key_file_load_from_file(key_file, filename, 0, NULL)) {
+		str = g_key_file_get_string(key_file, "General", "Name", NULL);
+		if (str) {
+			len = strlen(str);
+			if (len > HCI_MAX_NAME_LENGTH)
+				str[HCI_MAX_NAME_LENGTH] = '\0';
+		}
+	}
 
-	ba2str(local, addr);
-	create_name(filename, PATH_MAX, STORAGEDIR, addr, "names");
+	g_key_file_free(key_file);
 
-	ba2str(peer, addr);
-	return textfile_get(filename, addr);
+	return str;
 }
 
 /* Display local devices */
-- 
1.7.9.5


^ permalink raw reply related

* Re: [RFCv2 03/12] Bluetooth: Return correct L2CAP response type
From: Andrei Emeltchenko @ 2012-10-30 17:16 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1351615743.1828.4.camel@aeonflux>

Hi Marcel,

On Tue, Oct 30, 2012 at 09:49:03AM -0700, Marcel Holtmann wrote:
> Hi Andrei,
> 
> > Return L2CAP_CREATE_CHAN_RSP for Create Channel Request and
> > L2CAP_CONN_RSP for Create Connection Request.
> > 
> > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > ---
> >  net/bluetooth/l2cap_core.c |   11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index 4ef85d2..d51741f 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -3478,12 +3478,21 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
> >  	struct l2cap_conn_rsp rsp;
> >  	struct l2cap_conn *conn = chan->conn;
> >  	u8 buf[128];
> > +	u8 rsp_code;
> >  
> >  	rsp.scid   = cpu_to_le16(chan->dcid);
> >  	rsp.dcid   = cpu_to_le16(chan->scid);
> >  	rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS);
> >  	rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
> > -	l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
> > +
> > +	if (chan->hs_hcon)
> > +		rsp_code = L2CAP_CREATE_CHAN_RSP;
> > +	else
> > +		rsp_code = L2CAP_CONN_RSP;
> > +
> > +	BT_DBG("chan %p rsp_code %u", chan, rsp_code);
> > +
> > +	l2cap_send_cmd(conn, chan->ident, rsp_code, sizeof(rsp), &rsp);
> 
> looks a bit hackish to me, but seems to work since both responses are
> essentially identical. Separate functions might be better, but that can
> be also fixed later on.

I have continued to use method proposed by Mat. Do you think it shall be
changed?

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* Re: [RFCv2 03/12] Bluetooth: Return correct L2CAP response type
From: Marcel Holtmann @ 2012-10-30 17:48 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <20121030171611.GA28901@aemeltch-MOBL1>

Hi Andrei,

> > > Return L2CAP_CREATE_CHAN_RSP for Create Channel Request and
> > > L2CAP_CONN_RSP for Create Connection Request.
> > > 
> > > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > > ---
> > >  net/bluetooth/l2cap_core.c |   11 ++++++++++-
> > >  1 file changed, 10 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > > index 4ef85d2..d51741f 100644
> > > --- a/net/bluetooth/l2cap_core.c
> > > +++ b/net/bluetooth/l2cap_core.c
> > > @@ -3478,12 +3478,21 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
> > >  	struct l2cap_conn_rsp rsp;
> > >  	struct l2cap_conn *conn = chan->conn;
> > >  	u8 buf[128];
> > > +	u8 rsp_code;
> > >  
> > >  	rsp.scid   = cpu_to_le16(chan->dcid);
> > >  	rsp.dcid   = cpu_to_le16(chan->scid);
> > >  	rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS);
> > >  	rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
> > > -	l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
> > > +
> > > +	if (chan->hs_hcon)
> > > +		rsp_code = L2CAP_CREATE_CHAN_RSP;
> > > +	else
> > > +		rsp_code = L2CAP_CONN_RSP;
> > > +
> > > +	BT_DBG("chan %p rsp_code %u", chan, rsp_code);
> > > +
> > > +	l2cap_send_cmd(conn, chan->ident, rsp_code, sizeof(rsp), &rsp);
> > 
> > looks a bit hackish to me, but seems to work since both responses are
> > essentially identical. Separate functions might be better, but that can
> > be also fixed later on.
> 
> I have continued to use method proposed by Mat. Do you think it shall be
> changed?

I think at some point we should change this. However for now I am
actually fine keeping this in favor of making progress. You do need to
get back at some point and do some cleanups. Just make a note of it.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH v10 4/6] dbusoob: Set device name in device object
From: Szymon Janc @ 2012-10-31  7:22 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1351616728-10075-4-git-send-email-frederic.danis@linux.intel.com>

Hi Frédéric,

On Tuesday 30 of October 2012 19:05:26 Frédéric Danis wrote:
> ---
>  plugins/dbusoob.c |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
> index 5c5b6ef..0278941 100644
> --- a/plugins/dbusoob.c
> +++ b/plugins/dbusoob.c
> @@ -193,6 +193,7 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
>  
>  static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
>  {
> +	bdaddr_t local = *adapter_get_address(adapter);
>  	bdaddr_t bdaddr;
>  
>  	str2ba(data->addr, &bdaddr);
> @@ -207,9 +208,13 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
>  		write_remote_class(adapter_get_address(adapter), &bdaddr,
>  								data->class);
>  
> -	if (data->name)
> -		write_device_name(adapter_get_address(adapter), &bdaddr, 0,
> -								data->name);
> +	if (data->name) {
> +		char *str;
> +
> +		str = g_strdup(data->name);
> +		btd_event_remote_name(&local, &bdaddr, str);
> +		g_free(str);

Is this g_strdup needed? Why not just pass data->name directly?

> +	}
>  
>  	return TRUE;
>  }
> -- 
> 1.7.9.5
> 

-- 
BR
Szymon Janc

^ permalink raw reply

* Re: [PATCH BlueZ 1/7] AVRCP: Add initial support for controller player
From: Johan Hedberg @ 2012-10-31  8:39 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1351521709-4063-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Mon, Oct 29, 2012, Luiz Augusto von Dentz wrote:
> This also bump controller record to 1.3.
> ---
>  audio/avrcp.c | 531 ++++++++++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 441 insertions(+), 90 deletions(-)

This patch set has been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH v10 1/6] adapter: Simplify cached name storage
From: Johan Hedberg @ 2012-10-31  9:07 UTC (permalink / raw)
  To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1351616728-10075-1-git-send-email-frederic.danis@linux.intel.com>

Hi Frédéric,

On Tue, Oct 30, 2012, Frédéric Danis wrote:
> ---
>  src/adapter.c |   75 +++++++++++++++++++++++++--------------------------------
>  1 file changed, 33 insertions(+), 42 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH v10 4/6] dbusoob: Set device name in device object
From: Johan Hedberg @ 2012-10-31  9:07 UTC (permalink / raw)
  To: Szymon Janc; +Cc: Frédéric Danis, linux-bluetooth@vger.kernel.org
In-Reply-To: <14230948.4LRRcOUNYX@uw000953>

Hi Szymon,

On Wed, Oct 31, 2012, Szymon Janc wrote:
> > --- a/plugins/dbusoob.c
> > +++ b/plugins/dbusoob.c
> > @@ -193,6 +193,7 @@ static gboolean parse_data(DBusMessageIter *data, struct oob_data *remote_data)
> >  
> >  static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
> >  {
> > +	bdaddr_t local = *adapter_get_address(adapter);
> >  	bdaddr_t bdaddr;
> >  
> >  	str2ba(data->addr, &bdaddr);
> > @@ -207,9 +208,13 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
> >  		write_remote_class(adapter_get_address(adapter), &bdaddr,
> >  								data->class);
> >  
> > -	if (data->name)
> > -		write_device_name(adapter_get_address(adapter), &bdaddr, 0,
> > -								data->name);
> > +	if (data->name) {
> > +		char *str;
> > +
> > +		str = g_strdup(data->name);
> > +		btd_event_remote_name(&local, &bdaddr, str);
> > +		g_free(str);
> 
> Is this g_strdup needed? Why not just pass data->name directly?

This was because of missing const declarations in the event.h API. I
fixed this up and removed the extra strdup from this patch.

Johan

^ permalink raw reply

* [PATCH BlueZ] AVCTP: Fix scope of transactions to be per channel
From: Luiz Augusto von Dentz @ 2012-10-31 10:04 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

As per AVRCP spec:

  "It should be noted that transaction labels are scoped to an AVCTP
  channel, so an AVRCP specific AV/C command and an AVRCP specific
  browsing command may be outstanding at the same time with the same
  transaction label."
---
 audio/avctp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/audio/avctp.c b/audio/avctp.c
index 5f6a677..6ba25e4 100644
--- a/audio/avctp.c
+++ b/audio/avctp.c
@@ -150,6 +150,7 @@ struct avctp_pending_req {
 struct avctp_channel {
 	struct avctp *session;
 	GIOChannel *io;
+	uint8_t transaction;
 	guint watch;
 	uint16_t imtu;
 	uint16_t omtu;
@@ -1224,17 +1225,16 @@ static struct avctp_pending_req *pending_create(struct avctp_channel *chan,
 						GDestroyNotify destroy)
 {
 	struct avctp_pending_req *p;
-	static uint8_t transaction = 0;
 
 	p = g_new0(struct avctp_pending_req, 1);
 	p->chan = chan;
-	p->transaction = transaction;
+	p->transaction = chan->transaction;
 	p->process = process;
 	p->data = data;
 	p->destroy = destroy;
 
-	transaction++;
-	transaction %= 16;
+	chan->transaction++;
+	chan->transaction %= 16;
 
 	return p;
 }
-- 
1.7.11.7


^ permalink raw reply related

* Re: [PATCH BlueZ] AVCTP: Fix scope of transactions to be per channel
From: Johan Hedberg @ 2012-10-31 11:48 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1351677897-2580-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Wed, Oct 31, 2012, Luiz Augusto von Dentz wrote:
> As per AVRCP spec:
> 
>   "It should be noted that transaction labels are scoped to an AVCTP
>   channel, so an AVRCP specific AV/C command and an AVRCP specific
>   browsing command may be outstanding at the same time with the same
>   transaction label."
> ---
>  audio/avctp.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH hcidump] Change maximum pkt size for High Speed max pkt
From: Andrei Emeltchenko @ 2012-10-31 13:16 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

For AMP, L2CAP packets might be of bigger size, up to 1492 bytes.
Without the change hcidump cuts AMP data packets.
---
 lib/hci.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/hci.h b/lib/hci.h
index 7eacca5..d424e80 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -34,7 +34,7 @@ extern "C" {
 
 #define HCI_MAX_DEV	16
 
-#define HCI_MAX_ACL_SIZE	1024
+#define HCI_MAX_ACL_SIZE	(1492 + 4)
 #define HCI_MAX_SCO_SIZE	255
 #define HCI_MAX_EVENT_SIZE	260
 #define HCI_MAX_FRAME_SIZE	(HCI_MAX_ACL_SIZE + 4)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 00/12] Handling physical and logical link fixes
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1350493622.26318.114.camel@aeonflux>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Set of patches adding fixes for physical and logical link event handlings.

Changes:
	* PATCHv1: Added Marcel's acks, rewritten patch
	"12/12 Bluetooth: Process Create Chan Request" following review comments.
	* rfcv2: Added several new patches, fixing style issues.
	* rfcv1: Rebased on top of Mat's patches, preserve Marcel's ack for
	not-changed-much patches only.
	* rfcv0: original 

Andrei Emeltchenko (12):
  Bluetooth: trivial: Fix braces style and remove empty line
  Bluetooth: Save hs_hchan instead of hs_hcon in loglink complete
  Bluetooth: Return correct L2CAP response type
  Bluetooth: Derive remote and local amp id from chan struct
  Bluetooth: AMP: Add Logical Link Create function
  Bluetooth: AMP: Process Disc Logical Link
  Bluetooth: AMP: Process Disc Physical Link Complete evt
  Bluetooth: AMP: Remove hci_conn receiving error command status
  Bluetooth: Disconnect logical link when deleteing chan
  Bluetooth: AMP: Check for hs_hcon instead of ctrl_id
  Bluetooth: AMP: Use l2cap_physical_cfm in phylink complete evt
  Bluetooth: Process Create Chan Request

 include/net/bluetooth/amp.h   |    4 ++
 include/net/bluetooth/l2cap.h |    1 +
 net/bluetooth/amp.c           |   94 +++++++++++++++++++++++++++++++++
 net/bluetooth/hci_event.c     |   95 ++++++++++++++++++++++++++++------
 net/bluetooth/l2cap_core.c    |  114 +++++++++++++++++++++++++++++------------
 5 files changed, 259 insertions(+), 49 deletions(-)

-- 
1.7.9.5


^ permalink raw reply

* [PATCHv1 01/12] Bluetooth: trivial: Fix braces style and remove empty line
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/l2cap_core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d1728af..c2fbaf9 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6252,9 +6252,9 @@ void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 		conn = l2cap_conn_add(hcon, status);
 		if (conn)
 			l2cap_conn_ready(conn);
-	} else
+	} else {
 		l2cap_conn_del(hcon, bt_to_errno(status));
-
+	}
 }
 
 int l2cap_disconn_ind(struct hci_conn *hcon)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 02/12] Bluetooth: Save hs_hchan instead of hs_hcon in loglink complete
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

When logical link creation is completed we need to save hs_hchan
which represents logical link instead of hs_hcon representing
physical link. hs_hcon shall be saved when receiving physical link
complete event.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/l2cap_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index c2fbaf9..4ef85d2 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4375,7 +4375,7 @@ static void l2cap_logical_finish_create(struct l2cap_chan *chan,
 {
 	struct l2cap_conf_rsp rsp;
 
-	chan->hs_hcon = hchan->conn;
+	chan->hs_hchan = hchan;
 	chan->hs_hcon->l2cap_data = chan->conn;
 
 	l2cap_send_efs_conf_rsp(chan, &rsp, chan->ident, 0);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 03/12] Bluetooth: Return correct L2CAP response type
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Return L2CAP_CREATE_CHAN_RSP for Create Channel Request and
L2CAP_CONN_RSP for Create Connection Request.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/l2cap_core.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 4ef85d2..d51741f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3478,12 +3478,21 @@ void __l2cap_connect_rsp_defer(struct l2cap_chan *chan)
 	struct l2cap_conn_rsp rsp;
 	struct l2cap_conn *conn = chan->conn;
 	u8 buf[128];
+	u8 rsp_code;
 
 	rsp.scid   = cpu_to_le16(chan->dcid);
 	rsp.dcid   = cpu_to_le16(chan->scid);
 	rsp.result = __constant_cpu_to_le16(L2CAP_CR_SUCCESS);
 	rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
-	l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
+
+	if (chan->hs_hcon)
+		rsp_code = L2CAP_CREATE_CHAN_RSP;
+	else
+		rsp_code = L2CAP_CONN_RSP;
+
+	BT_DBG("chan %p rsp_code %u", chan, rsp_code);
+
+	l2cap_send_cmd(conn, chan->ident, rsp_code, sizeof(rsp), &rsp);
 
 	if (test_and_set_bit(CONF_REQ_SENT, &chan->conf_state))
 		return;
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 04/12] Bluetooth: Derive remote and local amp id from chan struct
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

l2cap_chan already keeps information about *_amp_id.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/l2cap_core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d51741f..782e49c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4573,9 +4573,11 @@ static void l2cap_do_move_cancel(struct l2cap_chan *chan, int result)
 	l2cap_ertm_send(chan);
 }
 
-void l2cap_physical_cfm(struct l2cap_chan *chan, int result, u8 local_amp_id,
-			u8 remote_amp_id)
+void l2cap_physical_cfm(struct l2cap_chan *chan, int result)
 {
+	u8 local_amp_id = chan->local_amp_id;
+	u8 remote_amp_id = chan->ctrl_id;
+
 	BT_DBG("chan %p, result %d, local_amp_id %d, remote_amp_id %d",
 	       chan, result, local_amp_id, remote_amp_id);
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 05/12] Bluetooth: AMP: Add Logical Link Create function
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

After physical link is created logical link needs to be created.
The process starts after L2CAP channel is created and L2CAP
Configuration Response with result PENDING is received.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 include/net/bluetooth/amp.h |    1 +
 net/bluetooth/amp.c         |   49 +++++++++++++++++++++++++++++++++++++++++++
 net/bluetooth/hci_event.c   |    9 ++++++++
 net/bluetooth/l2cap_core.c  |   19 ++++++++++++-----
 4 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h
index 2e7c79e..70d5c15 100644
--- a/include/net/bluetooth/amp.h
+++ b/include/net/bluetooth/amp.h
@@ -46,5 +46,6 @@ void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
 			struct hci_conn *hcon);
 void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle);
 void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle);
+void amp_create_logical_link(struct l2cap_chan *chan);
 
 #endif /* __AMP_H */
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index 231d7ef..fbb6360 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -372,3 +372,52 @@ void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
 
 	hci_send_cmd(hdev, HCI_OP_ACCEPT_PHY_LINK, sizeof(cp), &cp);
 }
+
+void amp_create_logical_link(struct l2cap_chan *chan)
+{
+	struct hci_cp_create_accept_logical_link cp;
+	struct hci_conn *hcon;
+	struct hci_dev *hdev;
+
+	BT_DBG("chan %p", chan);
+
+	if (!chan->hs_hcon)
+		return;
+
+	hdev = hci_dev_hold(chan->hs_hcon->hdev);
+	if (!hdev)
+		return;
+
+	BT_DBG("chan %p ctrl_id %d dst %pMR", chan, chan->ctrl_id,
+	       chan->conn->dst);
+
+	hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, chan->conn->dst);
+	if (!hcon)
+		goto done;
+
+	cp.phy_handle = hcon->handle;
+
+	cp.tx_flow_spec.id = chan->local_id;
+	cp.tx_flow_spec.stype = chan->local_stype;
+	cp.tx_flow_spec.msdu = cpu_to_le16(chan->local_msdu);
+	cp.tx_flow_spec.sdu_itime = cpu_to_le32(chan->local_sdu_itime);
+	cp.tx_flow_spec.acc_lat = cpu_to_le32(chan->local_acc_lat);
+	cp.tx_flow_spec.flush_to = cpu_to_le32(chan->local_flush_to);
+
+	cp.rx_flow_spec.id = chan->remote_id;
+	cp.rx_flow_spec.stype = chan->remote_stype;
+	cp.rx_flow_spec.msdu = cpu_to_le16(chan->remote_msdu);
+	cp.rx_flow_spec.sdu_itime = cpu_to_le32(chan->remote_sdu_itime);
+	cp.rx_flow_spec.acc_lat = cpu_to_le32(chan->remote_acc_lat);
+	cp.rx_flow_spec.flush_to = cpu_to_le32(chan->remote_flush_to);
+
+	if (hcon->out)
+		hci_send_cmd(hdev, HCI_OP_CREATE_LOGICAL_LINK, sizeof(cp),
+			     &cp);
+	else
+		hci_send_cmd(hdev, HCI_OP_ACCEPT_LOGICAL_LINK, sizeof(cp),
+			     &cp);
+
+done:
+	hci_dev_put(hdev);
+}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index aa79ed2..9963ec9 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1836,6 +1836,11 @@ static void hci_cs_accept_phylink(struct hci_dev *hdev, u8 status)
 	amp_write_remote_assoc(hdev, cp->phy_handle);
 }
 
+static void hci_cs_create_logical_link(struct hci_dev *hdev, u8 status)
+{
+	BT_DBG("%s status 0x%2.2x", hdev->name, status);
+}
+
 static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
@@ -2670,6 +2675,10 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
 		hci_cs_accept_phylink(hdev, ev->status);
 		break;
 
+	case HCI_OP_CREATE_LOGICAL_LINK:
+		hci_cs_create_logical_link(hdev, ev->status);
+		break;
+
 	default:
 		BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode);
 		break;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 782e49c..ecc5020 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -38,6 +38,7 @@
 #include <net/bluetooth/l2cap.h>
 #include <net/bluetooth/smp.h>
 #include <net/bluetooth/a2mp.h>
+#include <net/bluetooth/amp.h>
 
 bool disable_ertm;
 
@@ -1013,6 +1014,12 @@ static bool __amp_capable(struct l2cap_chan *chan)
 		return false;
 }
 
+static bool l2cap_check_efs(struct l2cap_chan *chan)
+{
+	/* Check EFS parameters */
+	return true;
+}
+
 void l2cap_send_conn_req(struct l2cap_chan *chan)
 {
 	struct l2cap_conn *conn = chan->conn;
@@ -3957,13 +3964,15 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
 				goto done;
 			}
 
-			/* check compatibility */
-
-			if (!chan->ctrl_id)
+			if (!chan->ctrl_id) {
 				l2cap_send_efs_conf_rsp(chan, buf, cmd->ident,
 							0);
-			else
-				chan->ident = cmd->ident;
+			} else {
+				if (l2cap_check_efs(chan)) {
+					amp_create_logical_link(chan);
+					chan->ident = cmd->ident;
+				}
+			}
 		}
 		goto done;
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 06/12] Bluetooth: AMP: Process Disc Logical Link
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add processing for HCI Disconnection Logical Link Complete
Event.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 include/net/bluetooth/amp.h |    1 +
 net/bluetooth/amp.c         |    7 +++++++
 net/bluetooth/hci_event.c   |   28 ++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h
index 70d5c15..405fb9c 100644
--- a/include/net/bluetooth/amp.h
+++ b/include/net/bluetooth/amp.h
@@ -47,5 +47,6 @@ void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
 void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle);
 void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle);
 void amp_create_logical_link(struct l2cap_chan *chan);
+void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason);
 
 #endif /* __AMP_H */
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index fbb6360..0f3fef3 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -421,3 +421,10 @@ void amp_create_logical_link(struct l2cap_chan *chan)
 done:
 	hci_dev_put(hdev);
 }
+
+void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason)
+{
+	BT_DBG("hchan %p", hchan);
+
+	hci_chan_del(hchan);
+}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 9963ec9..036cd8d 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3742,6 +3742,30 @@ static void hci_loglink_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 	}
 }
 
+static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev,
+					     struct sk_buff *skb)
+{
+	struct hci_ev_disconn_logical_link_complete *ev = (void *) skb->data;
+	struct hci_chan *hchan;
+
+	BT_DBG("%s log handle 0x%4.4x status 0x%2.2x", hdev->name,
+	       le16_to_cpu(ev->handle), ev->status);
+
+	if (ev->status)
+		return;
+
+	hci_dev_lock(hdev);
+
+	hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle));
+	if (!hchan)
+		goto unlock;
+
+	amp_destroy_logical_link(hchan, ev->reason);
+
+unlock:
+	hci_dev_unlock(hdev);
+}
+
 static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_ev_le_conn_complete *ev = (void *) skb->data;
@@ -4077,6 +4101,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
 		hci_loglink_complete_evt(hdev, skb);
 		break;
 
+	case HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE:
+		hci_disconn_loglink_complete_evt(hdev, skb);
+		break;
+
 	case HCI_EV_NUM_COMP_BLOCKS:
 		hci_num_comp_blocks_evt(hdev, skb);
 		break;
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 07/12] Bluetooth: AMP: Process Disc Physical Link Complete evt
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add processing for HCI Disconnection Physical Link Complete Event.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/hci_event.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 036cd8d..7ca98b9 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3766,6 +3766,28 @@ unlock:
 	hci_dev_unlock(hdev);
 }
 
+static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev,
+					     struct sk_buff *skb)
+{
+	struct hci_ev_disconn_phy_link_complete *ev = (void *) skb->data;
+	struct hci_conn *hcon;
+
+	BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
+
+	if (ev->status)
+		return;
+
+	hci_dev_lock(hdev);
+
+	hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle);
+	if (hcon) {
+		hcon->state = BT_CLOSED;
+		hci_conn_del(hcon);
+	}
+
+	hci_dev_unlock(hdev);
+}
+
 static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_ev_le_conn_complete *ev = (void *) skb->data;
@@ -4105,6 +4127,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
 		hci_disconn_loglink_complete_evt(hdev, skb);
 		break;
 
+	case HCI_EV_DISCONN_PHY_LINK_COMPLETE:
+		hci_disconn_phylink_complete_evt(hdev, skb);
+		break;
+
 	case HCI_EV_NUM_COMP_BLOCKS:
 		hci_num_comp_blocks_evt(hdev, skb);
 		break;
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 08/12] Bluetooth: AMP: Remove hci_conn receiving error command status
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

When receiving HCI Event: Command Status for Create Physical Link
with Error code remove AMP hcon.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/hci_event.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 7ca98b9..03d51a1 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1810,14 +1810,23 @@ static void hci_cs_create_phylink(struct hci_dev *hdev, u8 status)
 
 	BT_DBG("%s status 0x%2.2x", hdev->name, status);
 
-	if (status)
-		return;
-
 	cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_PHY_LINK);
 	if (!cp)
 		return;
 
-	amp_write_remote_assoc(hdev, cp->phy_handle);
+	hci_dev_lock(hdev);
+
+	if (status) {
+		struct hci_conn *hcon;
+
+		hcon = hci_conn_hash_lookup_handle(hdev, cp->phy_handle);
+		if (hcon)
+			hci_conn_del(hcon);
+	} else {
+		amp_write_remote_assoc(hdev, cp->phy_handle);
+	}
+
+	hci_dev_unlock(hdev);
 }
 
 static void hci_cs_accept_phylink(struct hci_dev *hdev, u8 status)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 09/12] Bluetooth: Disconnect logical link when deleteing chan
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Disconnect logical link for high speed channel hs_hchan
associated with L2CAP channel chan.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 include/net/bluetooth/amp.h |    1 +
 net/bluetooth/amp.c         |   14 ++++++++++++++
 net/bluetooth/l2cap_core.c  |    7 +++++++
 3 files changed, 22 insertions(+)

diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h
index 405fb9c..f1c0017 100644
--- a/include/net/bluetooth/amp.h
+++ b/include/net/bluetooth/amp.h
@@ -47,6 +47,7 @@ void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr,
 void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle);
 void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle);
 void amp_create_logical_link(struct l2cap_chan *chan);
+void amp_disconnect_logical_link(struct hci_chan *hchan);
 void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason);
 
 #endif /* __AMP_H */
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index 0f3fef3..917e034 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -422,6 +422,20 @@ done:
 	hci_dev_put(hdev);
 }
 
+void amp_disconnect_logical_link(struct hci_chan *hchan)
+{
+	struct hci_conn *hcon = hchan->conn;
+	struct hci_cp_disconn_logical_link cp;
+
+	if (hcon->state != BT_CONNECTED) {
+		BT_DBG("hchan %p not connected", hchan);
+		return;
+	}
+
+	cp.log_handle = cpu_to_le16(hchan->handle);
+	hci_send_cmd(hcon->hdev, HCI_OP_DISCONN_LOGICAL_LINK, sizeof(cp), &cp);
+}
+
 void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason)
 {
 	BT_DBG("hchan %p", hchan);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ecc5020..bb2cd9e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -578,6 +578,13 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 			mgr->bredr_chan = NULL;
 	}
 
+	if (chan->hs_hchan) {
+		struct hci_chan *hs_hchan = chan->hs_hchan;
+
+		BT_DBG("chan %p disconnect hs_hchan %p", chan, hs_hchan);
+		amp_disconnect_logical_link(hs_hchan);
+	}
+
 	chan->ops->teardown(chan, err);
 
 	if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
-- 
1.7.9.5


^ permalink raw reply related

* [PATCHv1 10/12] Bluetooth: AMP: Check for hs_hcon instead of ctrl_id
From: Andrei Emeltchenko @ 2012-10-31 13:46 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1351691197-8394-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

When deciding whether to send EFS configuration response with success,
check rather for existence of High Speed physical link hs_hcon then
ctrl_id. There might be cases when there is ctrl_id but high speed link
is not established yet.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/l2cap_core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index bb2cd9e..bdffc4c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3921,7 +3921,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn,
 		/* check compatibility */
 
 		/* Send rsp for BR/EDR channel */
-		if (!chan->ctrl_id)
+		if (!chan->hs_hcon)
 			l2cap_send_efs_conf_rsp(chan, rsp, cmd->ident, flags);
 		else
 			chan->ident = cmd->ident;
@@ -3971,7 +3971,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,
 				goto done;
 			}
 
-			if (!chan->ctrl_id) {
+			if (!chan->hs_hcon) {
 				l2cap_send_efs_conf_rsp(chan, buf, cmd->ident,
 							0);
 			} else {
-- 
1.7.9.5


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox