Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Fix typo in adapter documentation
From: Jose Antonio Santos Cadenas @ 2010-11-22 19:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas

---
 doc/adapter-api.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 65e2887..f287f29 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -148,7 +148,7 @@ Methods		dict GetProperties()
 
 			This registers the adapter wide agent.
 
-			The object path defines the path the of the agent
+			The object path defines the path of the agent
 			that will be called when user input is needed.
 
 			If an application disconnects from the bus all
-- 
1.7.1


^ permalink raw reply related

* pull request: bluetooth-2.6 2010-11-22
From: Gustavo F. Padovan @ 2010-11-22 18:14 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth

Hi John,

Following batch is intended to 2.6.37, it includes a very trivial return
err fix from myself and an remote name request fix from Johan Hedberg.
This fix move the remote name request (during the connection creation
process) to the kernelspace. In addition we have removed this operation
from BlueZ in userspace. Quoting part of Johan's patch which already
explain the change:

   "So far userspace has been responsible for this extra name request but
    tighter control is needed in order not to flood Bluetooth controllers
    with two many commands during connection creation. It has been shown
    that some controllers simply fail to function correctly if they get too
    many (almost) simultaneous commands during connection creation. The
    simplest way to acheive better control of these commands is to move
    their sending completely to the kernel side."

As side effect, we have a clean up patch in preparation to this fix.

Please pull, or let me know any problems you find here. Thanks.


The following changes since commit 3bf30b56c4f0a1c4fae34050b7db4527c92891e8:

  ath9k_htc: Avoid setting QoS control for non-QoS frames (2010-11-18 13:17:47 -0500)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-2.6.git master

Gustavo F. Padovan (1):
      Bluetooth: Fix not returning proper error in SCO

Johan Hedberg (3):
      Bluetooth: Simplify remote features callback function logic
      Bluetooth: Create a unified authentication request function
      Bluetooth: Automate remote name requests

 net/bluetooth/hci_event.c |  153 ++++++++++++++++++++++++++++++++-------------
 net/bluetooth/sco.c       |    6 +-
 2 files changed, 112 insertions(+), 47 deletions(-)

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: [PATCH v2] Bluetooth: Fix error handling for l2cap_init()
From: Anderson Lizardo @ 2010-11-22 18:05 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <20101122173447.GA23109@vigoh>

Hi Gustavo,

On Mon, Nov 22, 2010 at 1:34 PM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> * Anderson Lizardo <anderson.lizardo@openbossa.org> [2010-11-22 06:57:14 -0400]:
>> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
>> index 18a802c..7980e24 100644
>> --- a/net/bluetooth/l2cap.c
>> +++ b/net/bluetooth/l2cap.c
>> @@ -4875,8 +4875,10 @@ static int __init l2cap_init(void)
>>               return err;
>>
>>       _busy_wq = create_singlethread_workqueue("l2cap");
>> -     if (!_busy_wq)
>> -             goto error;
>> +     if (!_busy_wq) {
>> +             err = -ENOMEM;
>> +             goto error_busy_wq;
>> +     }
>
> I prefer if you move the workqueue creation to after the
> hci_register_proto block. That will make things easier.

I wonder if that might not introduce a race condition, because after
hci_register_proto() new connections may already arrive?

Or is it guaranteed to only happen after l2cap_init() has finished?

If not, I can make this change without problem.

Regards,
-- 
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH 2/2] Bluetooth: Get ride of __rfcomm_get_sock_by_channel()
From: Gustavo F. Padovan @ 2010-11-22 17:44 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1290036176-4022-2-git-send-email-padovan@profusion.mobi>

* Gustavo F. Padovan <padovan@profusion.mobi> [2010-11-17 21:22:56 -0200]:

> rfcomm_get_sock_by_channel() was the only user of this function, so I merged
> both into rfcomm_get_sock_by_channel(). The socket lock now should be hold
> outside of rfcomm_get_sock_by_channel() once we hold and release it inside the
> same function now.
> 
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
>  net/bluetooth/rfcomm/sock.c |   19 +++++++------------
>  1 files changed, 7 insertions(+), 12 deletions(-)

I'm also pushing these two to bluetooth-next. It should be good as
nobody commented on it, or people don't looked to it since there is a
clear typo and in commit messase (ride -> rid)

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: [PATCH] Bluetooth: do not use assignment in if condition
From: Gustavo F. Padovan @ 2010-11-22 17:40 UTC (permalink / raw)
  To: Emeltchenko Andrei; +Cc: linux-bluetooth
In-Reply-To: <1290424897-32463-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

* Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2010-11-22 13:21:37 +0200]:

> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
> 
> Fix checkpatch errors like:
> "ERROR: do not use assignment in if condition"
> Simplify code and fix one long line.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
> ---
>  net/bluetooth/hci_event.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)

Applied, thanks.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: [PATCH v2] Bluetooth: Fix error handling for l2cap_init()
From: Gustavo F. Padovan @ 2010-11-22 17:34 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1290423434-2920-1-git-send-email-anderson.lizardo@openbossa.org>

Hi Anderson,

* Anderson Lizardo <anderson.lizardo@openbossa.org> [2010-11-22 06:57:14 -0400]:

> create_singlethread_workqueue() may fail with errors such as -ENOMEM. If
> this happens, the return value is not set to a negative value and the
> module load will succeed. It will then crash on module unload because of
> a destroy_workqueue() call on a NULL pointer.
> 
> Additionally, the _busy_wq workqueue is not being destroyed if any
> errors happen on l2cap_init().
> 
> Signed-off-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
> ---
>  net/bluetooth/l2cap.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
> index 18a802c..7980e24 100644
> --- a/net/bluetooth/l2cap.c
> +++ b/net/bluetooth/l2cap.c
> @@ -4875,8 +4875,10 @@ static int __init l2cap_init(void)
>  		return err;
>  
>  	_busy_wq = create_singlethread_workqueue("l2cap");
> -	if (!_busy_wq)
> -		goto error;
> +	if (!_busy_wq) {
> +		err = -ENOMEM;
> +		goto error_busy_wq;
> +	}

I prefer if you move the workqueue creation to after the
hci_register_proto block. That will make things easier.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: [PATCH 2/2] Fix: increment MDL and MCL reference counter in IO watchers.
From: Johan Hedberg @ 2010-11-22 17:05 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <1290437712-28991-1-git-send-email-santoscadenas@gmail.com>

Hi Jose,

On Mon, Nov 22, 2010, Jose Antonio Santos Cadenas wrote:
> When a io_watcher is added to an MDL or an MCL channel, its reference
> should be incremented because the watcher should keep its own
> reference the the structure.
> 
> Also  a destroy function is added in order to decrement the reference
> once the watcher is removed.
> ---
>  health/mcap.c |   28 +++++++++++++++++++---------
>  1 files changed, 19 insertions(+), 9 deletions(-)

Thanks. Pushed upstream, but I still had to tweak the summary line a
little bit (take a look at the upstream tree if you're interested).

Johan

^ permalink raw reply

* Re: [PATCH v6] Bluetooth: btwilink driver
From: Dan Carpenter @ 2010-11-22 16:46 UTC (permalink / raw)
  To: pavan_savoy; +Cc: marcel, padovan, linux-bluetooth, linux-kernel
In-Reply-To: <1290424125-2717-1-git-send-email-pavan_savoy@ti.com>

On Mon, Nov 22, 2010 at 06:08:45AM -0500, pavan_savoy@ti.com wrote:
> +static int bt_ti_probe(struct platform_device *pdev)
> +{
> +	static struct ti_st *hst;
> +	struct hci_dev *hdev;
> +	int err;
> +
> +	hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
> +	if (!hst)
> +		return -ENOMEM;
> +
> +	/* Expose "hciX" device to user space */
> +	hdev = hci_alloc_dev();
> +	if (!hdev) {
> +		kfree(hst);
> +		return -ENOMEM;
> +	}
> +
> +	BT_DBG("hdev %p", hdev);
> +
> +	hst->hdev = hdev;
> +	hdev->bus = HCI_UART;
> +	hdev->driver_data = hst;
> +	hdev->open = ti_st_open;
> +	hdev->close = ti_st_close;
> +	hdev->flush = NULL;
> +	hdev->send = ti_st_send_frame;
> +	hdev->destruct = ti_st_destruct;
> +	hdev->owner = THIS_MODULE;
> +
> +	err = hci_register_dev(hdev);
> +	if (err < 0) {
> +		BT_ERR("Can't register HCI device error %d", err);
> +		hci_free_dev(hdev);

	Should there be a kfree(hst); here?  That's how it's done in
	bpa10x_probe() from drivers/bluetooth/bpa10x.c

> +		return err;
> +	}
> +
> +	BT_DBG(" HCI device registered (hdev %p)", hdev);
                ^
	Quite a few places have an extra space at the start.

> +
> +	dev_set_drvdata(&pdev->dev, hst);
> +	return err;
> +}

regards,
dan carpenter

^ permalink raw reply

* Re: [PATCH 00/00] Remove deprecated items from Makefiles
From: David Miller @ 2010-11-22 16:17 UTC (permalink / raw)
  To: tdent48227
  Cc: marcel, padovan, linux-bluetooth, netdev, sjur.brandeland,
	socketcan, urs.thuermann, socketcan-core, sage, ceph-devel,
	wang840925, jlayton, kaber, pekkas, linux-kernel, netfilter-devel,
	netfilter, samuel
In-Reply-To: <1290387808-2239-1-git-send-email-tdent48227@gmail.com>

From: Tracey Dent <tdent48227@gmail.com>
Date: Sun, 21 Nov 2010 20:03:11 -0500

> I changed Makefiles to use <modules>-y instead of <modules>-objs because -objs
> is deprecated and not even mentioned in Documentation/kbuild/makefiles.txt.
> 
> Also, remove some if-conditional statments because I used the ccflags-$ flag 
> instead of EXTRA_CFLAGS because EXTRA_CFLAGS.

All applied, thanks Tracey.

^ permalink raw reply

* [PATCH 2/2] Fix: increment MDL and MCL reference counter in IO watchers.
From: Jose Antonio Santos Cadenas @ 2010-11-22 14:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <AANLkTinQAeN8jyBmmPnw0tMWDfvOVamOU5+gBXLF-hTT@mail.gmail.com>

When a io_watcher is added to an MDL or an MCL channel, its reference
should be incremented because the watcher should keep its own
reference the the structure.

Also  a destroy function is added in order to decrement the reference
once the watcher is removed.
---
 health/mcap.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/health/mcap.c b/health/mcap.c
index 8ecdc68..81fd8df 100644
--- a/health/mcap.c
+++ b/health/mcap.c
@@ -1638,8 +1638,11 @@ static void mcap_connect_mdl_cb(GIOChannel *chan, GError *conn_err,
 	}
 
 	mdl->state = MDL_CONNECTED;
-	mdl->wid = g_io_add_watch(mdl->dc, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-						(GIOFunc) mdl_event_cb, mdl);
+	mdl->wid = g_io_add_watch_full(mdl->dc, G_PRIORITY_DEFAULT,
+					G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+					(GIOFunc) mdl_event_cb,
+					mcap_mdl_ref(mdl),
+					(GDestroyNotify) mcap_mdl_unref);
 
 	cb(mdl, conn_err, user_data);
 }
@@ -1774,9 +1777,11 @@ static void mcap_connect_mcl_cb(GIOChannel *chan, GError *conn_err,
 							mcap_mcl_ref(mcl));
 	}
 
-	mcl->wid = g_io_add_watch(mcl->cc,
+	mcl->wid = g_io_add_watch_full(mcl->cc, G_PRIORITY_DEFAULT,
 				G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-				(GIOFunc) mcl_control_cb, mcl);
+				(GIOFunc) mcl_control_cb,
+				mcap_mcl_ref(mcl),
+				(GDestroyNotify) mcap_mcl_unref);
 	connect_cb(mcl, gerr, data);
 }
 
@@ -1786,8 +1791,11 @@ static void set_mdl_properties(GIOChannel *chan, struct mcap_mdl *mdl)
 
 	mdl->state = MDL_CONNECTED;
 	mdl->dc = g_io_channel_ref(chan);
-	mdl->wid = g_io_add_watch(mdl->dc, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-						(GIOFunc) mdl_event_cb, mdl);
+	mdl->wid = g_io_add_watch_full(mdl->dc, G_PRIORITY_DEFAULT,
+					G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+					(GIOFunc) mdl_event_cb,
+					mcap_mdl_ref(mdl),
+					(GDestroyNotify) mcap_mdl_unref);
 
 	mcl->state = MCL_ACTIVE;
 	mcl->cb->mdl_connected(mdl, mcl->cb->user_data);
@@ -1919,9 +1927,11 @@ static void set_mcl_conf(GIOChannel *chan, struct mcap_mcl *mcl)
 		mcl->mi->mcls = g_slist_prepend(mcl->mi->mcls,
 							mcap_mcl_ref(mcl));
 
-	mcl->wid = g_io_add_watch(mcl->cc,
-			G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-			(GIOFunc) mcl_control_cb, mcl);
+	mcl->wid = g_io_add_watch_full(mcl->cc, G_PRIORITY_DEFAULT,
+				G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+				(GIOFunc) mcl_control_cb,
+				mcap_mcl_ref(mcl),
+				(GDestroyNotify) mcap_mcl_unref);
 
 	/* Callback to report new MCL */
 	if (reconn)
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH 2/2] Increment reference counter when a io_watcher is added
From: Jose Antonio Santos Cadenas @ 2010-11-22 14:54 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas, linux-bluetooth
In-Reply-To: <20101122144301.GC2303@jh-x301>

Hi Johan,

2010/11/22 Johan Hedberg <johan.hedberg@gmail.com>:
> Hi Jose,
>
> On Mon, Nov 22, 2010, Jose Antonio Santos Cadenas wrote:
>> Also a destroy function is added in order to avoid memory leaks
>> ---
>>  health/mcap.c |   28 +++++++++++++++++++---------
>>  1 files changed, 19 insertions(+), 9 deletions(-)
>
> The patch content itself is fine but you need to fix the commit message.
> Now you have half of the info in the summary and half in the message
> body (both halves being equaly relevant). The summary line should be a
> summary of the whole patch (in this case it could be e.g. "Fix MDL
> reference counting for IO watchers") and the body should contain the
> details. So please reformulate, resend, and pay more attention to this
> kind of things in the future. Thanks :)

Sorry for for the inconvenience, I'm fixing this and sending the new
patch. I'll try be more carefully with the commit messages in the
future.

Regards

>
> Johan
>

^ permalink raw reply

* Re: [PATCH 2/2] Increment reference counter when a io_watcher is added
From: Johan Hedberg @ 2010-11-22 14:43 UTC (permalink / raw)
  To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <1290413266-3949-1-git-send-email-santoscadenas@gmail.com>

Hi Jose,

On Mon, Nov 22, 2010, Jose Antonio Santos Cadenas wrote:
> Also a destroy function is added in order to avoid memory leaks
> ---
>  health/mcap.c |   28 +++++++++++++++++++---------
>  1 files changed, 19 insertions(+), 9 deletions(-)

The patch content itself is fine but you need to fix the commit message.
Now you have half of the info in the summary and half in the message
body (both halves being equaly relevant). The summary line should be a
summary of the whole patch (in this case it could be e.g. "Fix MDL
reference counting for IO watchers") and the body should contain the
details. So please reformulate, resend, and pay more attention to this
kind of things in the future. Thanks :)

Johan

^ permalink raw reply

* Re: [PATCH v2] Implement Characteristic Value Read using UUID in the gatttool
From: Sheldon Demario @ 2010-11-22 14:38 UTC (permalink / raw)
  To: Mike Tsai; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <35B17FE5076C7040809188FBE7913F98406D58BBA3@SC1EXMB-MBCL.global.atheros.com>

Hi Mike,

On 11/19/2010 07:49 PM, Mike Tsai wrote:
> Hi Sheldon,
>
> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-owner@vger.kernel.org] On Behalf Of Sheldon Demario
> Sent: Friday, November 19, 2010 5:35 AM
> To: linux-bluetooth@vger.kernel.org
> Cc: Sheldon Demario
> Subject: [PATCH v2] Implement Characteristic Value Read using UUID in the gatttool
>
> Sub-procedure used to read a Characteristic Value when the client
> only knows the characteristic UUID and doesn't know the handle.
> More than one handle and attribute value pair can be returned,
> it is up to the user define the handles range based on the service
> handles range.
>
> Usage example:
> $gatttool --char-read --uuid=2a00 -i hcix -b xx:xx:xx:xx:xx:xx
> ---
>   attrib/gatt.c     |   15 ++++++++++++---
>   attrib/gatt.h     |    4 ++++
>   attrib/gatttool.c |   39 +++++++++++++++++++++++++++++++++++++++
>   3 files changed, 55 insertions(+), 3 deletions(-)
>
> diff --git a/attrib/gatt.c b/attrib/gatt.c
> index 2c87daf..bca8b49 100644
> --- a/attrib/gatt.c
> +++ b/attrib/gatt.c
> @@ -74,13 +74,22 @@ guint gatt_discover_primary(GAttrib *attrib, uint16_t start, uint16_t end,
>   guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
>   				GAttribResultFunc func, gpointer user_data)
>   {
> -	uint8_t pdu[ATT_DEFAULT_MTU];
>   	uuid_t uuid;
> -	guint16 plen;
>
>   	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
>
> -	plen = enc_read_by_type_req(start, end,&uuid, pdu, sizeof(pdu));
> +	return gatt_read_char_by_uuid(attrib, start, end,&uuid, func,
> +							user_data);
> +}
> +
> +guint gatt_read_char_by_uuid(GAttrib *attrib, uint16_t start, uint16_t end,
> +					uuid_t *uuid, GAttribResultFunc func,
> +					gpointer user_data)
> +{
> +	uint8_t pdu[ATT_DEFAULT_MTU];
> +	guint16 plen;
> +
> +	plen = enc_read_by_type_req(start, end, uuid, pdu, sizeof(pdu));
>   	if (plen == 0)
>   		return 0;
>
> diff --git a/attrib/gatt.h b/attrib/gatt.h
> index 4e7d88b..1e1e628 100644
> --- a/attrib/gatt.h
> +++ b/attrib/gatt.h
> @@ -41,3 +41,7 @@ guint gatt_find_info(GAttrib *attrib, uint16_t start, uint16_t end,
>
>   guint gatt_write_cmd(GAttrib *attrib, uint16_t handle, uint8_t *value, int vlen,
>   				GDestroyNotify notify, gpointer user_data);
> +
> +guint gatt_read_char_by_uuid(GAttrib *attrib, uint16_t start, uint16_t end,
> +				uuid_t *uuid, GAttribResultFunc func,
> +				gpointer user_data);
> diff --git a/attrib/gatttool.c b/attrib/gatttool.c
> index e961431..d0ef6d3 100644
> --- a/attrib/gatttool.c
> +++ b/attrib/gatttool.c
> @@ -398,10 +398,49 @@ done:
>   		g_main_loop_quit(event_loop);
>   }
>
> +static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
> +					guint16 plen, gpointer user_data)
> +{
> +	struct att_data_list *list;
> +	int i;
> +
> +	if (status != 0) {
> +		g_printerr("Read characteristics by UUID failed: %s\n",
> +							att_ecode2str(status));
> +		goto done;
> +	}
> +
> +	list = dec_read_by_type_resp(pdu, plen);
> +	if (list == NULL)
> +		goto done;
> +
> +	for (i = 0; i<  list->num; i++) {
> +		uint8_t *value = list->data[i];
> +		int j;
> +
> +		g_print("handle: 0x%04x \t value: ", att_get_u16(value));
> +		value += 2;
> +		for (j = 0; j<  list->len - 2; j++, value++)
> +			g_print("%02x ", *value);
> +		g_print("\n");
> +	}
> +
> +	att_data_list_free(list);
> +
> +done:
> +	g_main_loop_quit(event_loop);
> +}
> +
> [MTsai] in your call back function here, you assume that "read_by_type_request" operation has completed. In the case of example with uuid=0x2a00 (device name), this is probably true. However, if there are multiple characteristics with same UUID within the database, then server probably has not sent all the characteristic value back yet, shall you check to see if the reading is really completed (comparing the handle), otherwise, issue another read_by_type_request with starting handle = attribute handle+1?

You are right. According to the spec it is necessary to iterate until
the server replies<<Attribute Not Found>>,
multiple characteristics can be split due the MTU value. However is
this the behavior that we need? gatttool is only a command line tool
implemented to allow the user to test some scenario that it is not
possible to test using a "real" client.

The user can issue another request using the gatttool and send the
Start Handle set to one greater that the last Attribute Handle.
I gonna implement this feature just keep the same approach of discover
all primary services in the gatttool.




>   static gboolean characteristics_read(gpointer user_data)
>   {
>   	GAttrib *attrib = user_data;
>
> +	if (opt_uuid != NULL) {
> +		gatt_read_char_by_uuid(attrib, opt_start, opt_end, opt_uuid,
> +						char_read_by_uuid_cb, attrib);
> +		return FALSE;
> +	}
> +
>   	if (opt_handle<= 0) {
>   		g_printerr("A valid handle is required\n");
>   		g_main_loop_quit(event_loop);


^ permalink raw reply

* Re: [PATCH 1/2] Do not increment mdl reference in reconnections
From: Johan Hedberg @ 2010-11-22 14:37 UTC (permalink / raw)
  To: Santiago Carot-Nemesio; +Cc: linux-bluetooth
In-Reply-To: <1290413446-5391-1-git-send-email-sancane@gmail.com>

Hi,

On Mon, Nov 22, 2010, Santiago Carot-Nemesio wrote:
> diff --git a/health/hdp.c b/health/hdp.c
> index 2e06a6b..769e300 100644
> --- a/health/hdp.c
> +++ b/health/hdp.c
> @@ -921,7 +921,8 @@ static void hdp_mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
>  		return;
>  
>  	chan = dev->ndc;
> -	chan->mdl = mcap_mdl_ref(mdl);
> +	if (!chan->mdl)
> +		chan->mdl = mcap_mdl_ref(mdl);
>  
>  	if (!g_slist_find(dev->channels, chan))
>  		dev->channels = g_slist_prepend(dev->channels,

Pushed upstream. Do try to be more verbose in your commit messages
please. Also have the summary lines of fix commits (like this one)
starting with "Fix ..." so they can be easily detected e.g. when doing
summaries for release changelogs.

Johan

^ permalink raw reply

* Re: [PATCH] Fix managing dbus filters depending on BT state
From: Johan Hedberg @ 2010-11-22 14:33 UTC (permalink / raw)
  To: Bartosz Szatkowski; +Cc: linux-bluetooth
In-Reply-To: <1290423382-5493-1-git-send-email-bulislaw@linux.com>

Hi Bartosz,

On Mon, Nov 22, 2010, Bartosz Szatkowski wrote:
> Previously even if BT was disabled, bluetoothd would handle some dbus
> singals (mostly connected with HFP). Now filters are added when
> BT is enabled and removed when BT is disabled.
> ---
>  audio/manager.c          |    4 ++--
>  audio/telephony-dummy.c  |   10 ++++++++++
>  audio/telephony-maemo5.c |   10 ++++++++++
>  audio/telephony-maemo6.c |   10 ++++++++++
>  audio/telephony-ofono.c  |   10 ++++++++++
>  audio/telephony.h        |    1 +
>  src/adapter.c            |    5 +++++
>  7 files changed, 48 insertions(+), 2 deletions(-)

Nack on this one. I understand the issue you're trying to fix but it
needs to be done differently.

> diff --git a/audio/manager.c b/audio/manager.c
> index 816c807..2fc7bf1 100644
> --- a/audio/manager.c
> +++ b/audio/manager.c
> @@ -1178,7 +1178,7 @@ proceed:
>  		btd_register_adapter_driver(&media_server_driver);
>  
>  	if (enabled.headset) {
> -		telephony_init();
> +		telephony_set_state(1);
>  		btd_register_adapter_driver(&headset_server_driver);
>  	}

If you're gonna call this "state" you should have proper defines or
enums for the values, however in this case it's essentially a boolean so
that's not necessary. In fact since it's a boolean you don't even need
to have any new function or variable at all for it: just use
telephony_init and telephony_exit.

> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -57,6 +57,7 @@
>  #include "glib-helper.h"
>  #include "agent.h"
>  #include "storage.h"
> +#include "../audio/telephony.h"
>  
>  #define IO_CAPABILITY_DISPLAYONLY	0x00
>  #define IO_CAPABILITY_DISPLAYYESNO	0x01
> @@ -2404,6 +2405,8 @@ int adapter_start(struct btd_adapter *adapter)
>  
>  	err = adapter_up(adapter, mode);
>  
> +	telephony_init();
> +

This is just wrong. The core daemon should never have direct access to
the telephony driver. Instead, you should have the audio plugin
(probably audio/manager.c or audio/headset.c) register a adapter powered
callback and then call telehony_init/exit from that callback.

Johan

^ permalink raw reply

* Re: [PATCH] Bluetooth: do not use assignment in if condition
From: Ville Tervo @ 2010-11-22 13:24 UTC (permalink / raw)
  To: ext Emeltchenko Andrei; +Cc: linux-bluetooth
In-Reply-To: <1290424897-32463-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Mon, Nov 22, 2010 at 01:21:37PM +0200, ext Emeltchenko Andrei wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
> 
> Fix checkpatch errors like:
> "ERROR: do not use assignment in if condition"
> Simplify code and fix one long line.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>

Looks good to me

Acked-by: Ville Tervo <ville.tervo@nokia.com>


> ---
>  net/bluetooth/hci_event.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 4165895..3c1957c 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -996,12 +996,14 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
>  
>  		hci_dev_lock(hdev);
>  
> -		if ((ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr)))
> +		ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
> +		if (ie)
>  			memcpy(ie->data.dev_class, ev->dev_class, 3);
>  
>  		conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
>  		if (!conn) {
> -			if (!(conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr))) {
> +			conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr);
> +			if (!conn) {
>  				BT_ERR("No memory for new connection");
>  				hci_dev_unlock(hdev);
>  				return;
> @@ -1608,7 +1610,8 @@ static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *sk
>  	if (conn && !ev->status) {
>  		struct inquiry_entry *ie;
>  
> -		if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst))) {
> +		ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
> +		if (ie) {
>  			ie->data.clock_offset = ev->clock_offset;
>  			ie->timestamp = jiffies;
>  		}
> @@ -1642,7 +1645,8 @@ static inline void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *
>  
>  	hci_dev_lock(hdev);
>  
> -	if ((ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr))) {
> +	ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
> +	if (ie) {
>  		ie->data.pscan_rep_mode = ev->pscan_rep_mode;
>  		ie->timestamp = jiffies;
>  	}
> @@ -1713,7 +1717,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
>  	if (!ev->status && ev->page == 0x01) {
>  		struct inquiry_entry *ie;
>  
> -		if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst)))
> +		ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
> +		if (ie)
>  			ie->data.ssp_mode = (ev->features[0] & 0x01);
>  
>  		conn->ssp_mode = (ev->features[0] & 0x01);
> @@ -1886,7 +1891,8 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
>  
>  	hci_dev_lock(hdev);
>  
> -	if ((ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr)))
> +	ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
> +	if (ie)
>  		ie->data.ssp_mode = (ev->features[0] & 0x01);
>  
>  	hci_dev_unlock(hdev);
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH] Fix fetching contact photo file name
From: Johan Hedberg @ 2010-11-22 13:00 UTC (permalink / raw)
  To: Bartosz Szatkowski; +Cc: linux-bluetooth
In-Reply-To: <1289828017-13412-1-git-send-email-bulislaw@linux.com>

Hi,

On Mon, Nov 15, 2010, Bartosz Szatkowski wrote:
> Previously photo id was fetched. File name may be further converted to
> binary data (actual image) if such behavior would be desired in the future.
> ---
>  plugins/phonebook-tracker.c |   60 ++++++++++++++++++++++++++++++++++++++----
>  1 files changed, 54 insertions(+), 6 deletions(-)

Sorry about the delay with this one (I simply missed it). The patch has
now been pushed upstream.

Johan

^ permalink raw reply

* [PATCH] Bluetooth: do not use assignment in if condition
From: Emeltchenko Andrei @ 2010-11-22 11:21 UTC (permalink / raw)
  To: linux-bluetooth

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

Fix checkpatch errors like:
"ERROR: do not use assignment in if condition"
Simplify code and fix one long line.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
 net/bluetooth/hci_event.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4165895..3c1957c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -996,12 +996,14 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
 
 		hci_dev_lock(hdev);
 
-		if ((ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr)))
+		ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
+		if (ie)
 			memcpy(ie->data.dev_class, ev->dev_class, 3);
 
 		conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
 		if (!conn) {
-			if (!(conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr))) {
+			conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr);
+			if (!conn) {
 				BT_ERR("No memory for new connection");
 				hci_dev_unlock(hdev);
 				return;
@@ -1608,7 +1610,8 @@ static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *sk
 	if (conn && !ev->status) {
 		struct inquiry_entry *ie;
 
-		if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst))) {
+		ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
+		if (ie) {
 			ie->data.clock_offset = ev->clock_offset;
 			ie->timestamp = jiffies;
 		}
@@ -1642,7 +1645,8 @@ static inline void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *
 
 	hci_dev_lock(hdev);
 
-	if ((ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr))) {
+	ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
+	if (ie) {
 		ie->data.pscan_rep_mode = ev->pscan_rep_mode;
 		ie->timestamp = jiffies;
 	}
@@ -1713,7 +1717,8 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
 	if (!ev->status && ev->page == 0x01) {
 		struct inquiry_entry *ie;
 
-		if ((ie = hci_inquiry_cache_lookup(hdev, &conn->dst)))
+		ie = hci_inquiry_cache_lookup(hdev, &conn->dst);
+		if (ie)
 			ie->data.ssp_mode = (ev->features[0] & 0x01);
 
 		conn->ssp_mode = (ev->features[0] & 0x01);
@@ -1886,7 +1891,8 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
 
 	hci_dev_lock(hdev);
 
-	if ((ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr)))
+	ie = hci_inquiry_cache_lookup(hdev, &ev->bdaddr);
+	if (ie)
 		ie->data.ssp_mode = (ev->features[0] & 0x01);
 
 	hci_dev_unlock(hdev);
-- 
1.7.1


^ permalink raw reply related

* [PATCH v6] Bluetooth: btwilink driver
From: pavan_savoy @ 2010-11-22 11:08 UTC (permalink / raw)
  To: marcel, padovan; +Cc: linux-bluetooth, linux-kernel, Pavan Savoy

From: Pavan Savoy <pavan_savoy@ti.com>

Marcel, Gustavo,

comments attended to from v5,

1. Inside ti_st_open, I previously only checked for EINPROGRESS & EPERM,
ow I handle for EINPROGRESS - which is not really an error and
return during all other error cases.

2. _write is still a function pointer and not an exported function, I
need to change the underlying driver's code for this.
However, previous lkml comments on the underlying driver's code
suggested it to be kept as a function pointer and not EXPORT.
Gustavo, Marcel - Please comment on this.
Is this absolutely required? If so why?

3. test_and_set_bit of HCI_RUNNING is done at beginning of
ti_st_open, and did not see issues during firmware download.
However ideally I would still like to set HCI_RUNNING once the firmware
download is done, because I don't want to allow a _send_frame during
firmware download - Marcel, Gustavo - Please comment.

4. test_and_clear of HCI_RUNNING now done @ beginning of close.

5. EAGAIN on failure of st_write is to suggest to try and write again.
I have never this happen - However only if UART goes bad this case may
occur.

6. ti_st_tx_complete is very similar to hci_ldisc's tx_complete - in
fact the code is pretty much borrowed from there.
Marcel, Gustavo - Please suggest where should it be done? If not here.

7. comments cleaned-up + hst memory leak fixed when hci_alloc_dev fails.

8. platform_driver registration inside module_init now is similar to
other drivers.

Thanks for the comments...
Sorry, for previously not being very clear on which comments were
handled and which were not.

-- patch description --

This is the bluetooth protocol driver for the TI WiLink7 chipsets.
Texas Instrument's WiLink chipsets combine wireless technologies
like BT, FM, GPS and WLAN onto a single chip.

This Bluetooth driver works on top of the TI_ST shared transport
line discipline driver which also allows other drivers like
FM V4L2 and GPS character driver to make use of the same UART interface.

Kconfig and Makefile modifications to enable the Bluetooth
driver for Texas Instrument's WiLink 7 chipset.

Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
---
 drivers/bluetooth/Kconfig    |   10 ++
 drivers/bluetooth/Makefile   |    1 +
 drivers/bluetooth/btwilink.c |  362 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 373 insertions(+), 0 deletions(-)
 create mode 100644 drivers/bluetooth/btwilink.c

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 02deef4..8e0de9a 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -219,4 +219,14 @@ config BT_ATH3K
 	  Say Y here to compile support for "Atheros firmware download driver"
 	  into the kernel or say M to compile it as module (ath3k).
 
+config BT_WILINK
+	tristate "Texas Instruments WiLink7 driver"
+	depends on TI_ST
+	help
+	  This enables the Bluetooth driver for Texas Instrument's BT/FM/GPS
+	  combo devices. This makes use of shared transport line discipline
+	  core driver to communicate with the BT core of the combo chip.
+
+	  Say Y here to compile support for Texas Instrument's WiLink7 driver
+	  into the kernel or say M to compile it as module.
 endmenu
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 71bdf13..f4460f4 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_BT_HCIBTSDIO)	+= btsdio.o
 obj-$(CONFIG_BT_ATH3K)		+= ath3k.o
 obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
+obj-$(CONFIG_BT_WILINK)		+= btwilink.o
 
 btmrvl-y			:= btmrvl_main.o
 btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
new file mode 100644
index 0000000..2b83a12
--- /dev/null
+++ b/drivers/bluetooth/btwilink.c
@@ -0,0 +1,362 @@
+/*
+ *  Texas Instrument's Bluetooth Driver For Shared Transport.
+ *
+ *  Bluetooth Driver acts as interface between HCI core and
+ *  TI Shared Transport Layer.
+ *
+ *  Copyright (C) 2009-2010 Texas Instruments
+ *  Author: Raja Mani <raja_mani@ti.com>
+ *	Pavan Savoy <pavan_savoy@ti.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include <linux/platform_device.h>
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#include <linux/ti_wilink_st.h>
+
+/* Bluetooth Driver Version */
+#define VERSION               "1.0"
+
+/* Number of seconds to wait for registration completion
+ * when ST returns PENDING status.
+ */
+#define BT_REGISTER_TIMEOUT   6000	/* 6 sec */
+
+/**
+ * struct ti_st - driver operation structure
+ * @hdev: hci device pointer which binds to bt driver
+ * @reg_status: ST registration callback status
+ * @st_write: write function provided by the ST driver
+ *	to be used by the driver during send_frame.
+ * @wait_reg_completion - completion sync between ti_st_open
+ *	and ti_st_registration_completion_cb.
+ */
+struct ti_st {
+	struct hci_dev *hdev;
+	char reg_status;
+	long (*st_write) (struct sk_buff *);
+	struct completion wait_reg_completion;
+};
+
+/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
+static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
+{
+	struct hci_dev *hdev = hst->hdev;
+
+	/* Update HCI stat counters */
+	switch (pkt_type) {
+	case HCI_COMMAND_PKT:
+		hdev->stat.cmd_tx++;
+		break;
+
+	case HCI_ACLDATA_PKT:
+		hdev->stat.acl_tx++;
+		break;
+
+	case HCI_SCODATA_PKT:
+		hdev->stat.sco_tx++;
+		break;
+	}
+}
+
+/* ------- Interfaces to Shared Transport ------ */
+
+/* Called by ST layer to indicate protocol registration completion
+ * status.ti_st_open() function will wait for signal from this
+ * API when st_register() function returns ST_PENDING.
+ */
+static void st_registration_completion_cb(void *priv_data, char data)
+{
+	struct ti_st *lhst = priv_data;
+
+	/* Save registration status for use in ti_st_open() */
+	lhst->reg_status = data;
+	/* complete the wait in ti_st_open() */
+	complete(&lhst->wait_reg_completion);
+}
+
+/* Called by Shared Transport layer when receive data is
+ * available */
+static long st_receive(void *priv_data, struct sk_buff *skb)
+{
+	struct ti_st *lhst = priv_data;
+	int err;
+
+	if (!skb)
+		return -EFAULT;
+
+	if (!lhst) {
+		kfree_skb(skb);
+		return -EFAULT;
+	}
+
+	skb->dev = (void *) lhst->hdev;
+
+	/* Forward skb to HCI core layer */
+	err = hci_recv_frame(skb);
+	if (err < 0) {
+		BT_ERR("Unable to push skb to HCI core(%d)", err);
+		return err;
+	}
+
+	lhst->hdev->stat.byte_rx += skb->len;
+
+	return 0;
+}
+
+/* ------- Interfaces to HCI layer ------ */
+/* protocol structure registered with shared transport */
+static struct st_proto_s ti_st_proto = {
+	.type = ST_BT,
+	.recv = st_receive,
+	.reg_complete_cb = st_registration_completion_cb,
+};
+
+/* Called from HCI core to initialize the device */
+static int ti_st_open(struct hci_dev *hdev)
+{
+	unsigned long timeleft;
+	struct ti_st *hst;
+	int err;
+
+	BT_DBG("%s %p", hdev->name, hdev);
+	if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) {
+		BT_ERR("btwilink already opened");
+		return -EBUSY;
+	}
+
+	/* provide contexts for callbacks from ST */
+	hst = hdev->driver_data;
+	ti_st_proto.priv_data = hst;
+
+	err = st_register(&ti_st_proto);
+	if (err == -EINPROGRESS) {
+		/* ST is busy with either protocol registration or firmware
+		 * download.
+		 */
+		/* Prepare wait-for-completion handler data structures.
+		 */
+		init_completion(&hst->wait_reg_completion);
+
+		/* Reset ST registration callback status flag , this value
+		 * will be updated in ti_st_registration_completion_cb()
+		 * function whenever it called from ST driver.
+		 */
+		hst->reg_status = -EINPROGRESS;
+
+		BT_DBG(" waiting for registration completion signal from ST");
+		timeleft = wait_for_completion_timeout
+			(&hst->wait_reg_completion,
+			 msecs_to_jiffies(BT_REGISTER_TIMEOUT));
+		if (!timeleft) {
+			clear_bit(HCI_RUNNING, &hdev->flags);
+			BT_ERR("Timeout(%d sec),didn't get reg "
+					"completion signal from ST",
+					BT_REGISTER_TIMEOUT / 1000);
+			return -ETIMEDOUT;
+		}
+
+		/* Is ST registration callback called with ERROR status? */
+		if (hst->reg_status != 0) {
+			clear_bit(HCI_RUNNING, &hdev->flags);
+			BT_ERR("ST registration completed with invalid "
+					"status %d", hst->reg_status);
+			return -EAGAIN;
+		}
+		err = 0;
+	} else if (err != 0) {
+		clear_bit(HCI_RUNNING, &hdev->flags);
+		BT_ERR("st_register failed %d", err);
+		return err;
+	}
+
+	/* ti_st_proto.write is filled up by the underlying shared
+	 * transport driver upon registration
+	 */
+	hst->st_write = ti_st_proto.write;
+	if (!hst->st_write) {
+		BT_ERR("undefined ST write function");
+		clear_bit(HCI_RUNNING, &hdev->flags);
+
+		/* Undo registration with ST */
+		err = st_unregister(ST_BT);
+		if (err)
+			BT_ERR("st_unregister() failed with error %d", err);
+
+		hst->st_write = NULL;
+		return err;
+	}
+
+	return err;
+}
+
+/* Close device */
+static int ti_st_close(struct hci_dev *hdev)
+{
+	int err;
+	struct ti_st *hst = hdev->driver_data;
+
+	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
+		return 0;
+
+	/* continue to unregister from transport */
+	err = st_unregister(ST_BT);
+	if (err)
+		BT_ERR("st_unregister() failed with error %d", err);
+
+	hst->st_write = NULL;
+
+	return err;
+}
+
+static int ti_st_send_frame(struct sk_buff *skb)
+{
+	struct hci_dev *hdev;
+	struct ti_st *hst;
+	long len;
+
+	hdev = (struct hci_dev *)skb->dev;
+
+	if (!test_bit(HCI_RUNNING, &hdev->flags))
+		return -EBUSY;
+
+	hst = hdev->driver_data;
+
+	/* Prepend skb with frame type */
+	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
+
+	BT_DBG(" %s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
+			skb->len);
+
+	/* Insert skb to shared transport layer's transmit queue.
+	 * Freeing skb memory is taken care in shared transport layer,
+	 * so don't free skb memory here.
+	 */
+	len = hst->st_write(skb);
+	if (len < 0) {
+		kfree_skb(skb);
+		BT_ERR(" ST write failed (%ld)", len);
+		/* Try Again, would only fail if UART has gone bad */
+		return -EAGAIN;
+	}
+
+	/* ST accepted our skb. So, Go ahead and do rest */
+	hdev->stat.byte_tx += len;
+	ti_st_tx_complete(hst, bt_cb(skb)->pkt_type);
+
+	return 0;
+}
+
+static void ti_st_destruct(struct hci_dev *hdev)
+{
+	BT_DBG("%s", hdev->name);
+	kfree(hdev->driver_data);
+}
+
+static int bt_ti_probe(struct platform_device *pdev)
+{
+	static struct ti_st *hst;
+	struct hci_dev *hdev;
+	int err;
+
+	hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
+	if (!hst)
+		return -ENOMEM;
+
+	/* Expose "hciX" device to user space */
+	hdev = hci_alloc_dev();
+	if (!hdev) {
+		kfree(hst);
+		return -ENOMEM;
+	}
+
+	BT_DBG("hdev %p", hdev);
+
+	hst->hdev = hdev;
+	hdev->bus = HCI_UART;
+	hdev->driver_data = hst;
+	hdev->open = ti_st_open;
+	hdev->close = ti_st_close;
+	hdev->flush = NULL;
+	hdev->send = ti_st_send_frame;
+	hdev->destruct = ti_st_destruct;
+	hdev->owner = THIS_MODULE;
+
+	err = hci_register_dev(hdev);
+	if (err < 0) {
+		BT_ERR("Can't register HCI device error %d", err);
+		hci_free_dev(hdev);
+		return err;
+	}
+
+	BT_DBG(" HCI device registered (hdev %p)", hdev);
+
+	dev_set_drvdata(&pdev->dev, hst);
+	return err;
+}
+
+static int bt_ti_remove(struct platform_device *pdev)
+{
+	struct hci_dev *hdev;
+	struct ti_st *hst = dev_get_drvdata(&pdev->dev);
+
+	if (!hst)
+		return -EFAULT;
+
+	hdev = hst->hdev;
+	ti_st_close(hdev);
+	hci_unregister_dev(hdev);
+
+	hci_free_dev(hdev);
+	kfree(hst);
+
+	dev_set_drvdata(&pdev->dev, NULL);
+	return 0;
+}
+
+static struct platform_driver btwilink_driver = {
+	.probe = bt_ti_probe,
+	.remove = bt_ti_remove,
+	.driver = {
+		.name = "btwilink",
+		.owner = THIS_MODULE,
+	},
+};
+
+/* ------- Module Init/Exit interfaces ------ */
+static int __init btwilink_init(void)
+{
+	BT_INFO(" Bluetooth Driver for TI WiLink - Version %s", VERSION);
+
+	return platform_driver_register(&btwilink_driver);
+}
+
+static void __exit btwilink_exit(void)
+{
+	platform_driver_unregister(&btwilink_driver);
+}
+
+module_init(btwilink_init);
+module_exit(btwilink_exit);
+
+/* ------ Module Info ------ */
+
+MODULE_AUTHOR("Raja Mani <raja_mani@ti.com>");
+MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
-- 
1.5.6.3

^ permalink raw reply related

* [PATCH] hciattach: download configuration at maximum baud rate possible
From: Suraj Sumangala @ 2010-11-22 10:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jothikumar.Mothilal, Suraj Sumangala

This patch support downloading configuration files for
Atheros AR300x HCI UART chip at user requested baud rate
instead of the initial baud rate.
---
 tools/hciattach.c       |    2 +-
 tools/hciattach.h       |    3 +-
 tools/hciattach_ath3k.c |   97 +++++++++++++++++++++++++++++++++-------------
 3 files changed, 72 insertions(+), 30 deletions(-)

diff --git a/tools/hciattach.c b/tools/hciattach.c
index fd53710..a47fa55 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -304,7 +304,7 @@ static int texasalt(int fd, struct uart_t *u, struct termios *ti)
 
 static int ath3k_ps(int fd, struct uart_t *u, struct termios *ti)
 {
-	return ath3k_init(fd, u->bdaddr, u->speed);
+	return ath3k_init(fd, u->speed, u->init_speed, u->bdaddr, ti);
 }
 
 static int ath3k_pm(int fd, struct uart_t *u, struct termios *ti)
diff --git a/tools/hciattach.h b/tools/hciattach.h
index 2d26b77..fed0d11 100644
--- a/tools/hciattach.h
+++ b/tools/hciattach.h
@@ -50,6 +50,7 @@ int texas_post(int fd, struct termios *ti);
 int texasalt_init(int fd, int speed, struct termios *ti);
 int stlc2500_init(int fd, bdaddr_t *bdaddr);
 int bgb2xx_init(int dd, bdaddr_t *bdaddr);
-int ath3k_init(int fd, char *bdaddr, int speed);
+int ath3k_init(int fd, int speed, int init_speed, char *bdaddr,
+						struct termios *ti);
 int ath3k_post(int fd, int pm);
 int qualcomm_init(int fd, int speed, struct termios *ti, const char *bdaddr);
diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index 70ade30..5df20d8 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -922,14 +922,49 @@ int ath3k_post(int fd, int pm)
 #define WRITE_BAUD_CMD_LEN   6
 #define MAX_CMD_LEN          WRITE_BDADDR_CMD_LEN
 
+static int set_cntrlr_baud(int fd, int speed)
+{
+	int baud;
+	struct timespec tm = { 0, 500000 };
+	unsigned char cmd[MAX_CMD_LEN], rsp[HCI_MAX_EVENT_SIZE];
+	unsigned char *ptr = cmd + 1;
+	hci_command_hdr *ch = (void *)ptr;
+
+	cmd[0] = HCI_COMMAND_PKT;
+
+	/* set controller baud rate to user specified value */
+	ptr = cmd + 1;
+	ch->opcode = htobs(cmd_opcode_pack(HCI_VENDOR_CMD_OGF,
+						HCI_CHG_BAUD_CMD_OCF));
+	ch->plen = 2;
+	ptr += HCI_COMMAND_HDR_SIZE;
+
+	baud = speed/100;
+	ptr[0] = (char)baud;
+	ptr[1] = (char)(baud >> 8);
+
+	if (write(fd, cmd, WRITE_BAUD_CMD_LEN) != WRITE_BAUD_CMD_LEN) {
+		perror("Failed to write change baud rate command");
+		return -ETIMEDOUT;
+	}
+
+	nanosleep(&tm, NULL);
+
+	if (read_hci_event(fd, rsp, sizeof(rsp)) < 0)
+		return -ETIMEDOUT;
+
+	return 0;
+}
+
 /*
  * Atheros AR300x specific initialization and configuration file
  * download
  */
-int ath3k_init(int fd, char *bdaddr, int speed)
+int ath3k_init(int fd, int speed, int init_speed, char *bdaddr,
+						struct termios *ti)
 {
 	int r;
-	int baud;
+	int err = 0;
 	struct timespec tm = { 0, 500000 };
 	unsigned char cmd[MAX_CMD_LEN], rsp[HCI_MAX_EVENT_SIZE];
 	unsigned char *ptr = cmd + 1;
@@ -937,11 +972,22 @@ int ath3k_init(int fd, char *bdaddr, int speed)
 
 	cmd[0] = HCI_COMMAND_PKT;
 
+	/* set both controller and host baud rate to maximum possible value */
+	err = set_cntrlr_baud(fd, speed);
+	if (err < 0)
+		return err;
+
+	if (set_speed(fd, ti, speed) < 0) {
+		perror("Can't set required baud rate");
+		return -1;
+	}
+
 	/* Download PS and patch */
 	r = ath_ps_download(fd);
 	if (r < 0) {
 		perror("Failed to Download configuration");
-		return -ETIMEDOUT;
+		err = -ETIMEDOUT;
+		goto exit;
 	}
 
 	/* Write BDADDR */
@@ -960,12 +1006,14 @@ int ath3k_init(int fd, char *bdaddr, int speed)
 		if (write(fd, cmd, WRITE_BDADDR_CMD_LEN) !=
 					WRITE_BDADDR_CMD_LEN) {
 			perror("Failed to write BD_ADDR command\n");
-			return -ETIMEDOUT;
+			err = -ETIMEDOUT;
+			goto exit;
 		}
 
 		if (read_hci_event(fd, rsp, sizeof(rsp)) < 0) {
 			perror("Failed to set BD_ADDR\n");
-			return -ETIMEDOUT;
+			err = -ETIMEDOUT;
+			goto exit;
 		}
 	}
 
@@ -975,33 +1023,26 @@ int ath3k_init(int fd, char *bdaddr, int speed)
 	cmd[3] = 0x00;
 
 	r = write(fd, cmd, 4);
-	if (r != 4)
-		return -ETIMEDOUT;
+	if (r != 4) {
+		err = -ETIMEDOUT;
+		goto exit;
+	}
 
 	nanosleep(&tm, NULL);
-	if (read_hci_event(fd, rsp, sizeof(rsp)) < 0)
-		return -ETIMEDOUT;
-
-	/* set controller baud rate to user specified value */
-	ptr = cmd + 1;
-	ch->opcode = htobs(cmd_opcode_pack(HCI_VENDOR_CMD_OGF,
-						HCI_CHG_BAUD_CMD_OCF));
-	ch->plen = 2;
-	ptr += HCI_COMMAND_HDR_SIZE;
-
-	baud = speed/100;
-	ptr[0] = (char)baud;
-	ptr[1] = (char)(baud >> 8);
-
-	if (write(fd, cmd, WRITE_BAUD_CMD_LEN) != WRITE_BAUD_CMD_LEN) {
-		perror("Failed to write change baud rate command");
-		return -ETIMEDOUT;
+	if (read_hci_event(fd, rsp, sizeof(rsp)) < 0) {
+		err = -ETIMEDOUT;
+		goto exit;
 	}
 
-	nanosleep(&tm, NULL);
+	err = set_cntrlr_baud(fd, speed);
+	if (err < 0)
+		return err;
 
-	if (read_hci_event(fd, rsp, sizeof(rsp)) < 0)
-		return -ETIMEDOUT;
+exit:
+	if (err < 0) {
+		set_cntrlr_baud(fd, init_speed);
+		set_speed(fd, ti, init_speed);
+	}
 
-	return 0;
+	return err;
 }
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH v2] Bluetooth: Fix error handling for l2cap_init()
From: Anderson Lizardo @ 2010-11-22 10:57 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: padovan, Anderson Lizardo

create_singlethread_workqueue() may fail with errors such as -ENOMEM. If
this happens, the return value is not set to a negative value and the
module load will succeed. It will then crash on module unload because of
a destroy_workqueue() call on a NULL pointer.

Additionally, the _busy_wq workqueue is not being destroyed if any
errors happen on l2cap_init().

Signed-off-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
---
 net/bluetooth/l2cap.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 18a802c..7980e24 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -4875,8 +4875,10 @@ static int __init l2cap_init(void)
 		return err;
 
 	_busy_wq = create_singlethread_workqueue("l2cap");
-	if (!_busy_wq)
-		goto error;
+	if (!_busy_wq) {
+		err = -ENOMEM;
+		goto error_busy_wq;
+	}
 
 	err = bt_sock_register(BTPROTO_L2CAP, &l2cap_sock_family_ops);
 	if (err < 0) {
@@ -4904,6 +4906,8 @@ static int __init l2cap_init(void)
 	return 0;
 
 error:
+	destroy_workqueue(_busy_wq);
+error_busy_wq:
 	proto_unregister(&l2cap_proto);
 	return err;
 }
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH] Fix managing dbus filters depending on BT state
From: Bartosz Szatkowski @ 2010-11-22 10:56 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bartosz Szatkowski

Previously even if BT was disabled, bluetoothd would handle some dbus
singals (mostly connected with HFP). Now filters are added when
BT is enabled and removed when BT is disabled.
---
 audio/manager.c          |    4 ++--
 audio/telephony-dummy.c  |   10 ++++++++++
 audio/telephony-maemo5.c |   10 ++++++++++
 audio/telephony-maemo6.c |   10 ++++++++++
 audio/telephony-ofono.c  |   10 ++++++++++
 audio/telephony.h        |    1 +
 src/adapter.c            |    5 +++++
 7 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/audio/manager.c b/audio/manager.c
index 816c807..2fc7bf1 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -1178,7 +1178,7 @@ proceed:
 		btd_register_adapter_driver(&media_server_driver);
 
 	if (enabled.headset) {
-		telephony_init();
+		telephony_set_state(1);
 		btd_register_adapter_driver(&headset_server_driver);
 	}
 
@@ -1220,7 +1220,7 @@ void audio_manager_exit(void)
 
 	if (enabled.headset) {
 		btd_unregister_adapter_driver(&headset_server_driver);
-		telephony_exit();
+		telephony_set_state(0);
 	}
 
 	if (enabled.gateway)
diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c
index 06cb798..ef7c5fa 100644
--- a/audio/telephony-dummy.c
+++ b/audio/telephony-dummy.c
@@ -57,6 +57,8 @@ static gboolean events_enabled = FALSE;
  */
 static int response_and_hold = -1;
 
+static int telephony_state = 0;
+
 static struct indicator dummy_indicators[] =
 {
 	{ "battchg",	"0-5",	5,	TRUE },
@@ -411,8 +413,16 @@ static GDBusSignalTable dummy_signals[] = {
 	{ }
 };
 
+int telephony_set_state(int state)
+{
+	telephony_state = state;
+}
+
 int telephony_init(void)
 {
+	if (telephony_state == 0)
+		return;
+
 	uint32_t features = AG_FEATURE_REJECT_A_CALL |
 				AG_FEATURE_ENHANCED_CALL_STATUS |
 				AG_FEATURE_EXTENDED_ERROR_RESULT_CODES;
diff --git a/audio/telephony-maemo5.c b/audio/telephony-maemo5.c
index 4d0134c..1dd5449 100644
--- a/audio/telephony-maemo5.c
+++ b/audio/telephony-maemo5.c
@@ -222,6 +222,8 @@ static char *last_dialed_number = NULL;
 /* Timer for tracking call creation requests */
 static guint create_request_timer = 0;
 
+static int telephony_state = 0;
+
 static struct indicator maemo_indicators[] =
 {
 	{ "battchg",	"0-5",	5,	TRUE },
@@ -2044,8 +2046,16 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,
 	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
+int telephony_set_state(int state)
+{
+	telephony_state = state;
+}
+
 int telephony_init(void)
 {
+	if (telephony_state == 0)
+		return;
+
 	const char *battery_cap = "battery";
 	uint32_t features = AG_FEATURE_EC_ANDOR_NR |
 				AG_FEATURE_INBAND_RINGTONE |
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index 72c8e36..916dcb8 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -181,6 +181,8 @@ static char *last_dialed_number = NULL;
 /* Timer for tracking call creation requests */
 static guint create_request_timer = 0;
 
+static int telephony_state = 0;
+
 static struct indicator maemo_indicators[] =
 {
 	{ "battchg",	"0-5",	5,	TRUE },
@@ -1937,8 +1939,16 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,
 	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
+int telephony_set_state(int state)
+{
+	telephony_state = state;
+}
+
 int telephony_init(void)
 {
+	if (telephony_state == 0)
+		return;
+
 	const char *battery_cap = "battery";
 	uint32_t features = AG_FEATURE_EC_ANDOR_NR |
 				AG_FEATURE_INBAND_RINGTONE |
diff --git a/audio/telephony-ofono.c b/audio/telephony-ofono.c
index 693207c..fe3ae19 100644
--- a/audio/telephony-ofono.c
+++ b/audio/telephony-ofono.c
@@ -96,6 +96,8 @@ static gboolean events_enabled = FALSE;
  */
 static int response_and_hold = -1;
 
+static int telephony_state = 0;
+
 static struct indicator ofono_indicators[] =
 {
 	{ "battchg",	"0-5",	5,	TRUE },
@@ -1062,8 +1064,16 @@ done:
 	dbus_message_unref(reply);
 }
 
+int telephony_set_state(int state)
+{
+	telephony_state = state;
+}
+
 int telephony_init(void)
 {
+	if (telephony_state == 0)
+		return;
+
 	const char *battery_cap = "battery";
 	int ret;
 
diff --git a/audio/telephony.h b/audio/telephony.h
index 5343e8c..9b80e56 100644
--- a/audio/telephony.h
+++ b/audio/telephony.h
@@ -232,5 +232,6 @@ static inline int telephony_get_indicator(const struct indicator *indicators,
 	return -ENOENT;
 }
 
+int telephony_set_active(int state);
 int telephony_init(void);
 void telephony_exit(void);
diff --git a/src/adapter.c b/src/adapter.c
index 6b4a354..8ed2040 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -57,6 +57,7 @@
 #include "glib-helper.h"
 #include "agent.h"
 #include "storage.h"
+#include "../audio/telephony.h"
 
 #define IO_CAPABILITY_DISPLAYONLY	0x00
 #define IO_CAPABILITY_DISPLAYYESNO	0x01
@@ -2404,6 +2405,8 @@ int adapter_start(struct btd_adapter *adapter)
 
 	err = adapter_up(adapter, mode);
 
+	telephony_init();
+
 	info("Adapter %s has been enabled", adapter->path);
 
 	return err;
@@ -2533,6 +2536,8 @@ int adapter_stop(struct btd_adapter *adapter)
 
 	call_adapter_powered_callbacks(adapter, FALSE);
 
+	telephony_exit();
+
 	info("Adapter %s has been disabled", adapter->path);
 
 	set_mode_complete(adapter);
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH 1/2] Do not increment mdl reference in reconnections
From: Santiago Carot-Nemesio @ 2010-11-22  8:10 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Santiago Carot-Nemesio

diff --git a/health/hdp.c b/health/hdp.c
index 2e06a6b..769e300 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -921,7 +921,8 @@ static void hdp_mcap_mdl_connected_cb(struct mcap_mdl *mdl, void *data)
 		return;
 
 	chan = dev->ndc;
-	chan->mdl = mcap_mdl_ref(mdl);
+	if (!chan->mdl)
+		chan->mdl = mcap_mdl_ref(mdl);
 
 	if (!g_slist_find(dev->channels, chan))
 		dev->channels = g_slist_prepend(dev->channels,
-- 
1.7.3.2


^ permalink raw reply related

* [PATCH 2/2] Increment reference counter when a io_watcher is added
From: Jose Antonio Santos Cadenas @ 2010-11-22  8:07 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
In-Reply-To: <1290413446-5391-1-git-send-email-sancane@gmail.com>

Also a destroy function is added in order to avoid memory leaks
---
 health/mcap.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/health/mcap.c b/health/mcap.c
index 8ecdc68..81fd8df 100644
--- a/health/mcap.c
+++ b/health/mcap.c
@@ -1638,8 +1638,11 @@ static void mcap_connect_mdl_cb(GIOChannel *chan, GError *conn_err,
 	}
 
 	mdl->state = MDL_CONNECTED;
-	mdl->wid = g_io_add_watch(mdl->dc, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-						(GIOFunc) mdl_event_cb, mdl);
+	mdl->wid = g_io_add_watch_full(mdl->dc, G_PRIORITY_DEFAULT,
+					G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+					(GIOFunc) mdl_event_cb,
+					mcap_mdl_ref(mdl),
+					(GDestroyNotify) mcap_mdl_unref);
 
 	cb(mdl, conn_err, user_data);
 }
@@ -1774,9 +1777,11 @@ static void mcap_connect_mcl_cb(GIOChannel *chan, GError *conn_err,
 							mcap_mcl_ref(mcl));
 	}
 
-	mcl->wid = g_io_add_watch(mcl->cc,
+	mcl->wid = g_io_add_watch_full(mcl->cc, G_PRIORITY_DEFAULT,
 				G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-				(GIOFunc) mcl_control_cb, mcl);
+				(GIOFunc) mcl_control_cb,
+				mcap_mcl_ref(mcl),
+				(GDestroyNotify) mcap_mcl_unref);
 	connect_cb(mcl, gerr, data);
 }
 
@@ -1786,8 +1791,11 @@ static void set_mdl_properties(GIOChannel *chan, struct mcap_mdl *mdl)
 
 	mdl->state = MDL_CONNECTED;
 	mdl->dc = g_io_channel_ref(chan);
-	mdl->wid = g_io_add_watch(mdl->dc, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-						(GIOFunc) mdl_event_cb, mdl);
+	mdl->wid = g_io_add_watch_full(mdl->dc, G_PRIORITY_DEFAULT,
+					G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+					(GIOFunc) mdl_event_cb,
+					mcap_mdl_ref(mdl),
+					(GDestroyNotify) mcap_mdl_unref);
 
 	mcl->state = MCL_ACTIVE;
 	mcl->cb->mdl_connected(mdl, mcl->cb->user_data);
@@ -1919,9 +1927,11 @@ static void set_mcl_conf(GIOChannel *chan, struct mcap_mcl *mcl)
 		mcl->mi->mcls = g_slist_prepend(mcl->mi->mcls,
 							mcap_mcl_ref(mcl));
 
-	mcl->wid = g_io_add_watch(mcl->cc,
-			G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
-			(GIOFunc) mcl_control_cb, mcl);
+	mcl->wid = g_io_add_watch_full(mcl->cc, G_PRIORITY_DEFAULT,
+				G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+				(GIOFunc) mcl_control_cb,
+				mcap_mcl_ref(mcl),
+				(GDestroyNotify) mcap_mcl_unref);
 
 	/* Callback to report new MCL */
 	if (reconn)
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH 2/2] Bluetooth: Automate remote name requests
From: Johan Hedberg @ 2010-11-22  7:12 UTC (permalink / raw)
  To: Arun K. Singh; +Cc: linux-bluetooth
In-Reply-To: <AANLkTinMq-3K09y-bCWM1Z254FsWoRuZ=QEuZM11WPMb@mail.gmail.com>

Hi Arun,

On Mon, Nov 22, 2010, Arun K. Singh wrote:
> > The code will work sub-optimally with userspace versions that still
> > do the name requesting themselves (it shouldn't break anything
> > though) so it is recommended to combine this with a userspace
> > software version that doesn't have automated name requests.
> 
> Could you be bit more explicit about such user space versions that you
> recommend? Would latest bluez versions such as 4.80 qualify for your
> recommendation?

The automated name requests upon "connect complete" events were removed
in 4.78 so any version from there onwards would qualify.

Johan

^ permalink raw reply


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