Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] Update Adapter API documentation
From: Dmitriy Paliy @ 2011-03-28 14:21 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1301322117-22724-1-git-send-email-dmitriy.paliy@nokia.com>

RequestSession and ReleaseSession description is updated in adapter
API.
---
 doc/adapter-api.txt |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 5272d74..f34d58f 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -31,15 +31,25 @@ Methods		dict GetProperties()
 
 		void RequestSession()
 
-			This method will request a client session that
-			provides operational Bluetooth. A possible mode
-			change must be confirmed by the user via the agent.
+			This method requests a client session that provides
+			operational Bluetooth. A possible mode change must be
+			confirmed by the user via the agent.
+
+			Clients may request multiple sessions. All sessions
+			are released when adapter's mode is changed to off
+			state.
 
 			Possible Errors: org.bluez.Error.Rejected
 
 		void ReleaseSession()
 
-			Release a previous requested session.
+			Release a previously requested session. It sets
+			adapter to the mode in use on the moment of session
+			request.
+
+			SetProperty method call changes adapter's mode
+			persistently, such that session release will not
+			modify it.
 
 			Possible Errors: org.bluez.Error.DoesNotExist
 
-- 
1.7.1


^ permalink raw reply related

* [PATCH 2/2] Update Media API documentation
From: Dmitriy Paliy @ 2011-03-28 14:21 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1301322117-22724-1-git-send-email-dmitriy.paliy@nokia.com>

Possible error responses are added to RegisterEndpoint.
---
 doc/media-api.txt |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/doc/media-api.txt b/doc/media-api.txt
index 84903d6..b2f239a 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -35,6 +35,11 @@ Methods		void RegisterEndpoint(object endpoint, dict properties)
 					Capabilities blob, it is used as it is
 					so the size and byte order must match.
 
+			Possible Errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.NotSupported - emitted
+					 when interface for the end-point is
+					 disabled.
+
 		void UnregisterEndpoint(object endpoint)
 
 			Unregister sender end point.
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH 0/2 v2] Update Adapter API documentation
From: Johan Hedberg @ 2011-03-28 14:26 UTC (permalink / raw)
  To: Dmitriy Paliy; +Cc: linux-bluetooth
In-Reply-To: <1301322117-22724-1-git-send-email-dmitriy.paliy@nokia.com>

Hi Dmitriy,

On Mon, Mar 28, 2011, Dmitriy Paliy wrote:
> This is a new proposal to make it more readable.

Thanks. Both patches have been pushed upstream.

Johan

^ permalink raw reply

* Re: [PATCH v3] Clean and fix copyright header in test/sap-client
From: Johan Hedberg @ 2011-03-28 14:26 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz; +Cc: linux-bluetooth
In-Reply-To: <1301322494-10611-1-git-send-email-waldemar.rymarkiewicz@tieto.com>

Hi Waldek,

On Mon, Mar 28, 2011, Waldemar Rymarkiewicz wrote:
> ST-Ericsson is the copyright holder of test/sap-client.
> ---
>  test/sap-client |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply

* [PATCH v3] Clean and fix copyright header in test/sap-client
From: Waldemar Rymarkiewicz @ 2011-03-28 14:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Johan Hedberg, Waldemar Rymarkiewicz

ST-Ericsson is the copyright holder of test/sap-client.
---
 test/sap-client |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/sap-client b/test/sap-client
index 5a0c711..b12d455 100644
--- a/test/sap-client
+++ b/test/sap-client
@@ -1,7 +1,6 @@
-""" Copyright (C) 2011 Tieto """
+""" Copyright (C) 2010-2011 ST-Ericsson SA """
 
-""" Szymon Janc <szymon.janc@tieto.com> """
-""" Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> """
+""" Author: Szymon Janc <szymon.janc@tieto.com> for ST-Ericsson. """
 
 """ This program is free software; you can redistribute it and/or modify """
 """ it under the terms of the GNU General Public License as published by """
-- 
1.7.1


^ permalink raw reply related

* RE: [PATCH v2 2/2] mach-ux500: Add CG2900 devices
From: Par-Gunnar HJALMDAHL @ 2011-03-28 14:29 UTC (permalink / raw)
  To: Greg KH, Arnd Bergmann
  Cc: devel@driverdev.osuosl.org, Linus Walleij,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	Pavan Savoy, Vitaly Wool, Alan Cox, Marcel Holtmann,
	Lukasz Rymanowski, Linus WALLEIJ, Par-Gunnar Hjalmdahl, Lee Jones,
	Mathieu Poirier
In-Reply-To: <20110328141237.GB19350@suse.de>

> >
> > Not exactly what I had in mind, but probably good enough for a start.
> > This adds a dependency from core code to the staging driver now,
> > which shouldn't be there. I suppose we can add
> >
> > "Clean up device registration path to register the main device from
> board code"
> >
> > to the TODO file.
>=20
> No, please do not make any core code dependant on a staging driver,
> this
> isn't ok, it needs to be stand-alone, or at the least, the rest of the
> kernel needs to be able to be built with no staging drivers enabled.
>=20
> thanks,
>=20
> greg k-h

But how should I then do this? As I understood it I was told that I should
call an init function, but I was not allowed to add any staging folder
inclusion in the board config makefile. And now I can't do any extern
declaration either. I don't really see how I could do it then.

The only thing I can think of is to use platform device and driver for
the cg2900_init. But I wouldn't call that to call an init-function, but tha=
t
might be OK for this purpose?

Thanks,
P-G

^ permalink raw reply

* Re: [PATCH v2 2/2] mach-ux500: Add CG2900 devices
From: Greg KH @ 2011-03-28 14:39 UTC (permalink / raw)
  To: Par-Gunnar HJALMDAHL
  Cc: Arnd Bergmann, devel@driverdev.osuosl.org, Linus Walleij,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	Pavan Savoy, Vitaly Wool, Alan Cox, Marcel Holtmann,
	Lukasz Rymanowski, Linus WALLEIJ, Par-Gunnar Hjalmdahl, Lee Jones,
	Mathieu Poirier
In-Reply-To: <AFCDDB4A3EA003429EEF1E7B211FDBBA3377B51A1F@EXDCVYMBSTM005.EQ1STM.local>

On Mon, Mar 28, 2011 at 04:29:44PM +0200, Par-Gunnar HJALMDAHL wrote:
> > >
> > > Not exactly what I had in mind, but probably good enough for a start.
> > > This adds a dependency from core code to the staging driver now,
> > > which shouldn't be there. I suppose we can add
> > >
> > > "Clean up device registration path to register the main device from
> > board code"
> > >
> > > to the TODO file.
> > 
> > No, please do not make any core code dependant on a staging driver,
> > this
> > isn't ok, it needs to be stand-alone, or at the least, the rest of the
> > kernel needs to be able to be built with no staging drivers enabled.
> > 
> > thanks,
> > 
> > greg k-h
> 
> But how should I then do this? As I understood it I was told that I should
> call an init function, but I was not allowed to add any staging folder
> inclusion in the board config makefile. And now I can't do any extern
> declaration either. I don't really see how I could do it then.

Why can't you add a staging folder inclusion?  You could do that, and
properly set up your .h file so that if the driver is not built, your
code still properly builds and runs.

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH v2 2/2] mach-ux500: Add CG2900 devices
From: Vitaly Wool @ 2011-03-28 14:40 UTC (permalink / raw)
  To: Par-Gunnar Hjalmdahl
  Cc: Greg Kroah-Hartman, devel, Linus Walleij, linux-kernel,
	linux-bluetooth, Pavan Savoy, Alan Cox, Arnd Bergmann,
	Marcel Holtmann, Lukasz Rymanowski, Linus Walleij,
	Par-Gunnar Hjalmdahl, Lee Jones, Mathieu Poirier
In-Reply-To: <1301302992-10671-1-git-send-email-par-gunnar.p.hjalmdahl@stericsson.com>

On Mon, Mar 28, 2011 at 11:03 AM, Par-Gunnar Hjalmdahl
<par-gunnar.p.hjalmdahl@stericsson.com> wrote:
>
> +/* Function located in drivers/staging/cg2900 */
> +extern void cg2900_init_board(void);
> +

I'm confused. Where in the drivers/staging is this function? Couldn't
find it in the previous patch.

~Vitaly

^ permalink raw reply

* Re: [PATCH v2 2/2] mach-ux500: Add CG2900 devices
From: Arnd Bergmann @ 2011-03-28 14:47 UTC (permalink / raw)
  To: Par-Gunnar HJALMDAHL
  Cc: Greg KH, devel@driverdev.osuosl.org, Linus Walleij,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	Pavan Savoy, Vitaly Wool, Alan Cox, Marcel Holtmann,
	Lukasz Rymanowski, Linus WALLEIJ, Par-Gunnar Hjalmdahl, Lee Jones,
	Mathieu Poirier
In-Reply-To: <AFCDDB4A3EA003429EEF1E7B211FDBBA3377B51A1F@EXDCVYMBSTM005.EQ1STM.local>

On Monday 28 March 2011, Par-Gunnar HJALMDAHL wrote:
> But how should I then do this? As I understood it I was told that I should
> call an init function, but I was not allowed to add any staging folder
> inclusion in the board config makefile. And now I can't do any extern
> declaration either. I don't really see how I could do it then.
> 
> The only thing I can think of is to use platform device and driver for
> the cg2900_init. But I wouldn't call that to call an init-function, but that
> might be OK for this purpose?

There are at least two ways to do it:

* As Linus Walleij explained, use an initcall instead of calling a
  function from the board init code. "initcall" here refers to the
  interfaces from include/linux/init.h, e.g. module_init(). This
  will result in the function getting called at module load time,
  or at some point during bootup when it's built into the kernel.
  This initcall needs to check if you are running on the right board,
  using machine_is_xxx().

* As I explained, register a simple platform_device with the resources
  for the entire cg2900 device from the board code in a way that
  is independent of the actual driver. The driver code can then
  register all the subdevices from the cg2900_probe function.
  The code in the architecture would consist out of a single
  call to platform_device_register_simple() plus the resources.

Either way is fine with me.

	Arnd

^ permalink raw reply

* Re: [PATCH v2 2/2] mach-ux500: Add CG2900 devices
From: Arnd Bergmann @ 2011-03-28 14:49 UTC (permalink / raw)
  To: Vitaly Wool
  Cc: Par-Gunnar Hjalmdahl, Greg Kroah-Hartman, devel, Linus Walleij,
	linux-kernel, linux-bluetooth, Pavan Savoy, Alan Cox,
	Marcel Holtmann, Lukasz Rymanowski, Linus Walleij,
	Par-Gunnar Hjalmdahl, Lee Jones, Mathieu Poirier
In-Reply-To: <AANLkTimhcFNDdq0FCP2rVdDJ5V_YP+E82+80OavsuAS=@mail.gmail.com>

On Monday 28 March 2011, Vitaly Wool wrote:
> On Mon, Mar 28, 2011 at 11:03 AM, Par-Gunnar Hjalmdahl
> <par-gunnar.p.hjalmdahl@stericsson.com> wrote:
> >
> > +/* Function located in drivers/staging/cg2900 */
> > +extern void cg2900_init_board(void);
> > +
> 
> I'm confused. Where in the drivers/staging is this function? Couldn't
> find it in the previous patch.

It's in v2 of patch 2/2, in

drivers/staging/cg2900/board-mop500-cg2900.c

	Arnd

^ permalink raw reply

* Re: [PATCH] Simplify media_owner_remove
From: Johan Hedberg @ 2011-03-28 14:51 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1301327540-5699-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Mon, Mar 28, 2011, Luiz Augusto von Dentz wrote:
> Since there is only one pending request and is directly acessible via
> owner pointer there is no need for media_owner_remove to take the
> request as parameter.
> ---
>  audio/transport.c |   23 ++++++++++++-----------
>  1 files changed, 12 insertions(+), 11 deletions(-)

Thanks. All three of your patches have been pushed upstream.

Johan

^ permalink raw reply

* Re: [PATCH v2 2/2] mach-ux500: Add CG2900 devices
From: Arnd Bergmann @ 2011-03-28 14:59 UTC (permalink / raw)
  To: Greg KH
  Cc: Par-Gunnar HJALMDAHL, devel@driverdev.osuosl.org, Linus Walleij,
	linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
	Pavan Savoy, Vitaly Wool, Alan Cox, Marcel Holtmann,
	Lukasz Rymanowski, Linus WALLEIJ, Par-Gunnar Hjalmdahl, Lee Jones,
	Mathieu Poirier
In-Reply-To: <20110328143955.GB23892@suse.de>

On Monday 28 March 2011, Greg KH wrote:
> > 
> > But how should I then do this? As I understood it I was told that I should
> > call an init function, but I was not allowed to add any staging folder
> > inclusion in the board config makefile. And now I can't do any extern
> > declaration either. I don't really see how I could do it then.
> 
> Why can't you add a staging folder inclusion?  You could do that, and
> properly set up your .h file so that if the driver is not built, your
> code still properly builds and runs.

That would work as well, along with the two solutions I suggested.

I believe Pär-Gunnar was trying to avoid #ifdefs, and the patch actually
contains alternative files implementing cg2900_init_board as a stub
when CONFIG_CG2900 is set, so the intent was clearly there:

@@ -0,0 +1,18 @@
+#
+# Makefile for ST-Ericsson CG2900 connectivity combo controller
+#
+
+ccflags-y :=                                   \
+       -Idrivers/staging/cg2900/include \
+       -Iarch/arm/mach-ux500
+
+ifeq ($(CONFIG_CG2900),n)
+obj-y  += board-mop500-nocg2900.o
+export-objs                    := board-mop500-nocg2900.o
+else
+obj-$(CONFIG_CG2900)   += board-mop500-cg2900.o devices-cg2900.o
+export-objs                    := board-mop500-cg2900.o
+endif
+

I don't think that this works though, because the directory
is ignored when CONFIG_CG2900 is not set, and if it did work,
it would cause an empty function to be included in every
single kernel, not even limited to the ARM architecture.

	Arnd

^ permalink raw reply

* [PATCH] Fix not replying Acquire request when resume fails
From: Luiz Augusto von Dentz @ 2011-03-28 15:27 UTC (permalink / raw)
  To: linux-bluetooth

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

Request must be replied before removed.
---
 audio/transport.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/audio/transport.c b/audio/transport.c
index 3442e5f..795b794 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -191,6 +191,10 @@ static void media_transport_remove(struct media_transport *transport,
 
 	media_transport_release(transport, owner->accesstype);
 
+	/* Reply if owner has a pending request */
+	if (owner->pending)
+		media_request_reply(owner->pending, transport->conn, EIO);
+
 	transport->owners = g_slist_remove(transport->owners, owner);
 
 	if (owner->watch)
@@ -313,6 +317,7 @@ static void a2dp_suspend_complete(struct avdtp *session,
 	if (owner->pending) {
 		owner->pending->id = 0;
 		media_request_reply(owner->pending, transport->conn, 0);
+		media_owner_remove(owner, owner->pending);
 	}
 
 	a2dp_sep_unlock(sep, transport->session);
@@ -413,6 +418,7 @@ static void headset_suspend_complete(struct audio_device *dev, void *user_data)
 	if (owner->pending) {
 		owner->pending->id = 0;
 		media_request_reply(owner->pending, transport->conn, 0);
+		media_owner_remove(owner, owner->pending);
 	}
 
 	headset_unlock(dev, HEADSET_LOCK_READ | HEADSET_LOCK_WRITE);
-- 
1.7.1


^ permalink raw reply related

* [PATCH] Fix crash when receiving avdtp close command
From: Luiz Augusto von Dentz @ 2011-03-28 15:31 UTC (permalink / raw)
  To: linux-bluetooth

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

If there are pending start or suspend requests they should all fail since
once close indication return the state will be changed to closing and
remote stack can then disconnect cleanly.

This also follow what specs says about connection release:

"When the Upper Layer has completed releasing all resources allocated to
the stream, an AVDTP_CLOSE_RSP is sent back to the INT."
---
 audio/a2dp.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/audio/a2dp.c b/audio/a2dp.c
index 88c280a..9d9c61d 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -252,6 +252,16 @@ static gboolean finalize_resume(struct a2dp_setup *s)
 	return FALSE;
 }
 
+static gboolean finalize_resume_errno(struct a2dp_setup *s, int err)
+{
+	struct avdtp_error avdtp_err;
+
+	avdtp_error_init(&avdtp_err, AVDTP_ERRNO, -err);
+	s->err = err ? &avdtp_err : NULL;
+
+	return finalize_resume(s);
+}
+
 static gboolean finalize_suspend(struct a2dp_setup *s)
 {
 	GSList *l;
@@ -1044,12 +1054,20 @@ static gboolean close_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 				void *user_data)
 {
 	struct a2dp_sep *a2dp_sep = user_data;
+	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
 		DBG("Sink %p: Close_Ind", sep);
 	else
 		DBG("Source %p: Close_Ind", sep);
 
+	setup = find_setup_by_session(session);
+	if (!setup)
+		return TRUE;
+
+	finalize_suspend_errno(setup, -ECONNRESET);
+	finalize_resume_errno(setup, -ECONNRESET);
+
 	return TRUE;
 }
 
-- 
1.7.1


^ permalink raw reply related

* Re: [pulseaudio-discuss] [PATCH] sbc_math.h: add explicit check for ARMv6 instructions
From: Luiz Augusto von Dentz @ 2011-03-28 15:41 UTC (permalink / raw)
  To: General PulseAudio Discussion
  Cc: Paul Menzel, Siarhei Siamashka, linux-bluetooth
In-Reply-To: <1301052849.7592.15.camel@mattotaupa>

[-- Attachment #1: Type: text/plain, Size: 998 bytes --]

Hi,

On Fri, Mar 25, 2011 at 1:34 PM, Paul Menzel
<paulepanter@users.sourceforge.net> wrote:
> Dear Arun,
>
>
> Am Samstag, den 19.03.2011, 16:14 +0530 schrieb Arun Raghavan:
>
>> On Wed, 2011-02-23 at 01:07 +0530, Arun Raghavan wrote:
>> [...]
>> > The correct fix for this, imo, is in bluez (there is a new
>> > sbc_primitives_armv6.h that can probably be used at least as a
>> > template). We need to do an sbc-udpate on the PA side anyway, and can
>> > pull this when we do.
>>
>> Could you see if the attached patch works for you? If it does, I can
>> push this to the bluez folks.
>
> My tag on the other thread [1] is ambiguous. The error is indeed caused
> by your patch. I will try to implement your recommended changes but will
> probably not get to it before Sunday.

Im including Siarhei Siamashka since he did most, if not all, of this
code and linux-bluetooth to cc.

Btw, the sbc subdir should be in sync with sbc subdir in BlueZ tree.


-- 
Luiz Augusto von Dentz
Computer Engineer

[-- Attachment #2: thumb2-fix.patch --]
[-- Type: text/x-patch, Size: 1361 bytes --]

diff --git a/src/modules/bluetooth/sbc/sbc_math.h b/src/modules/bluetooth/sbc/sbc_math.h
index b87bc81..35d5dcc 100644
--- a/src/modules/bluetooth/sbc/sbc_math.h
+++ b/src/modules/bluetooth/sbc/sbc_math.h
@@ -23,6 +23,8 @@
  *
  */
 
+#include "sbc_primitives_armv6.h"
+
 #define fabs(x) ((x) < 0 ? -(x) : (x))
 /* C does not provide an explicit arithmetic shift right but this will
    always be correct and every compiler *should* generate optimal code */
@@ -47,7 +49,7 @@ typedef int32_t sbc_fixed_t;
 
 #define SBC_FIXED_0(val) { val = 0; }
 #define MUL(a, b)        ((a) * (b))
-#ifdef __arm__
+#ifdef SBC_HAVE_THUMB2
 #define MULA(a, b, res) ({				\
 		int tmp = res;			\
 		__asm__(				\
diff --git a/src/modules/bluetooth/sbc/sbc_primitives_armv6.h b/src/modules/bluetooth/sbc/sbc_primitives_armv6.h
index 1862aed..e70469a 100644
--- a/src/modules/bluetooth/sbc/sbc_primitives_armv6.h
+++ b/src/modules/bluetooth/sbc/sbc_primitives_armv6.h
@@ -38,6 +38,12 @@
 #define SBC_HAVE_ARMV6 1
 #endif
 
+#if defined(__ARM_ARCH_6T2__ ) || defined(__ARM_ARCH_7__) || \
+	defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || \
+	defined(__ARM_ARCH_7M__)
+#define SBC_HAVE_THUMB2 1
+#endif
+
 #if !defined(SBC_HIGH_PRECISION) && (SCALE_OUT_BITS == 15) && \
 	defined(__GNUC__) && defined(SBC_HAVE_ARMV6) && \
 	defined(__ARM_EABI__) && !defined(__thumb__) && \

^ permalink raw reply related

* [PATCH] Simplify media_owner_remove
From: Luiz Augusto von Dentz @ 2011-03-28 15:52 UTC (permalink / raw)
  To: linux-bluetooth

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

Since there is only one pending request and is directly acessible via
owner pointer there is no need for media_owner_remove to take the
request as parameter.
---
 audio/transport.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/audio/transport.c b/audio/transport.c
index 795b794..8ff6c85 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -154,10 +154,13 @@ static gboolean media_transport_release(struct media_transport *transport,
 	return TRUE;
 }
 
-static void media_owner_remove(struct media_owner *owner,
-						struct media_request *req)
+static void media_owner_remove(struct media_owner *owner)
 {
 	struct media_transport *transport = owner->transport;
+	struct media_request *req = owner->pending;
+
+	if (!req)
+		return;
 
 	DBG("Owner %s Request %s", owner->name,
 					dbus_message_get_member(req->msg));
@@ -176,8 +179,7 @@ static void media_owner_free(struct media_owner *owner)
 {
 	DBG("Owner %s", owner->name);
 
-	if (owner->pending)
-		media_owner_remove(owner, owner->pending);
+	media_owner_remove(owner);
 
 	g_free(owner->name);
 	g_free(owner->accesstype);
@@ -272,7 +274,7 @@ static void a2dp_resume_complete(struct avdtp *session,
 	if (ret == FALSE)
 		goto fail;
 
-	media_owner_remove(owner, req);
+	media_owner_remove(owner);
 
 	return;
 
@@ -317,7 +319,7 @@ static void a2dp_suspend_complete(struct avdtp *session,
 	if (owner->pending) {
 		owner->pending->id = 0;
 		media_request_reply(owner->pending, transport->conn, 0);
-		media_owner_remove(owner, owner->pending);
+		media_owner_remove(owner);
 	}
 
 	a2dp_sep_unlock(sep, transport->session);
@@ -383,7 +385,7 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)
 	if (ret == FALSE)
 		goto fail;
 
-	media_owner_remove(owner, req);
+	media_owner_remove(owner);
 
 	return;
 
@@ -418,7 +420,7 @@ static void headset_suspend_complete(struct audio_device *dev, void *user_data)
 	if (owner->pending) {
 		owner->pending->id = 0;
 		media_request_reply(owner->pending, transport->conn, 0);
-		media_owner_remove(owner, owner->pending);
+		media_owner_remove(owner);
 	}
 
 	headset_unlock(dev, HEADSET_LOCK_READ | HEADSET_LOCK_WRITE);
@@ -451,8 +453,7 @@ static void media_owner_exit(DBusConnection *connection, void *user_data)
 
 	owner->watch = 0;
 
-	if (owner->pending != NULL)
-		media_owner_remove(owner, owner->pending);
+	media_owner_remove(owner);
 
 	media_transport_remove(owner->transport, owner);
 }
@@ -615,7 +616,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
 			member = dbus_message_get_member(owner->pending->msg);
 			/* Cancel Acquire request if that exist */
 			if (g_str_equal(member, "Acquire"))
-				media_owner_remove(owner, owner->pending);
+				media_owner_remove(owner);
 			else
 				return btd_error_in_progress(msg);
 		}
-- 
1.7.1


^ permalink raw reply related

* Re: [pulseaudio-discuss] [PATCH] sbc_math.h: add explicit check for ARMv6 instructions
From: Siarhei Siamashka @ 2011-03-28 16:42 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: General PulseAudio Discussion, Paul Menzel, Siarhei Siamashka,
	linux-bluetooth
In-Reply-To: <AANLkTi=wTkJ654Zo0SEuzLi3MBjvee54HvToxmeYGMF1@mail.gmail.com>

On Mon, Mar 28, 2011 at 6:41 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi,
>
> On Fri, Mar 25, 2011 at 1:34 PM, Paul Menzel
> <paulepanter@users.sourceforge.net> wrote:
>> Dear Arun,
>>
>>
>> Am Samstag, den 19.03.2011, 16:14 +0530 schrieb Arun Raghavan:
>>
>>> On Wed, 2011-02-23 at 01:07 +0530, Arun Raghavan wrote:
>>> [...]
>>> > The correct fix for this, imo, is in bluez (there is a new
>>> > sbc_primitives_armv6.h that can probably be used at least as a
>>> > template). We need to do an sbc-udpate on the PA side anyway, and can
>>> > pull this when we do.
>>>
>>> Could you see if the attached patch works for you? If it does, I can
>>> push this to the bluez folks.

-#ifdef __arm__
+#ifdef SBC_HAVE_THUMB2

I think this check can be just changed to
#if defined(__arm__) && (!defined(__thumb__) || defined(__thumb2__))

MLA instruction is available on all ARM processors at least since
armv4, unless compiling code for thumb1. A similar modification can be
also added to armv6 sbc encoder optimizations. Right now armv6
assembly optimizations are disabled for both thumb1 and thumb2, while
they could be still used with thumb2.

-- 
Best regards,
Siarhei Siamashka

^ permalink raw reply

* Re: [PATCH 0/6] Move Attrib client (including: should we disconnect or not?)
From: Vinicius Costa Gomes @ 2011-03-28 20:33 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1301097673-5262-1-git-send-email-vinicius.gomes@openbossa.org>

Hi Johan,

On 21:01 Fri 25 Mar, Vinicius Costa Gomes wrote:
> Hi,
> 
> The move itself is pretty simple, but when implementing it, I took a decision
> and I would like to hear your opinion about it.

There were problems with some useless includes. I will send another version
soon. But the question below remains.

> 
> With this patch series, the behaviour is that we never disconnect from
> a LE device unless we are told so, i.e. org.bluez.Device.Disconnect(),
> is that what is expected from us?
> 
> 
> Cheers,
> --
> 
> Vinicius Costa Gomes (6):
>   Move Attrib client to the core
>   Register Attrib interface when loading device from storage
>   Register Attrib interface after Primary Service discovery
>   Remove _init and _exit methods from Attrib client
>   Add support for re-using the attrib channel
>   Fix disconnecting when primary service discovery is done
> 
>  Makefile.am      |    4 ++--
>  attrib/client.c  |   49 ++++++++++++++++++-------------------------------
>  attrib/client.h  |    6 +++---
>  attrib/manager.c |   47 -----------------------------------------------
>  src/adapter.c    |    5 +++++
>  src/device.c     |   20 +++++++++++++-------
>  6 files changed, 41 insertions(+), 90 deletions(-)
> 
> --
> 1.7.4.1
> 

Cheers,
-- 
Vinicius

^ permalink raw reply

* Re: [PATCH 0/6] Move Attrib client (including: should we disconnect or not?)
From: Claudio Takahasi @ 2011-03-28 20:40 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20110328203346.GA2664@piper>

Hi Vinicius,

On Mon, Mar 28, 2011 at 8:33 PM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
> Hi Johan,
>
> On 21:01 Fri 25 Mar, Vinicius Costa Gomes wrote:
>> Hi,
>>
>> The move itself is pretty simple, but when implementing it, I took a decision
>> and I would like to hear your opinion about it.
>
> There were problems with some useless includes. I will send another version
> soon. But the question below remains.
>
>>
>> With this patch series, the behaviour is that we never disconnect from
>> a LE device unless we are told so, i.e. org.bluez.Device.Disconnect(),
>> is that what is expected from us?

In my opinion, the profiles should define how to manage connections.
For LE re-connections should be avoided since the remote disables the
advertising when the connection is established.
Keep the link up seems to be acceptable for now, but for the final
solution we need to disconnect based on the registered "watchers" and
profile inputs. Some profiles such as proximity keeps the devices
always connected and auto-reconnect, others require user interaction.

Cheers,
Claudio.

>>
>>
>> Cheers,
>> --
>>
>> Vinicius Costa Gomes (6):
>>   Move Attrib client to the core
>>   Register Attrib interface when loading device from storage
>>   Register Attrib interface after Primary Service discovery
>>   Remove _init and _exit methods from Attrib client
>>   Add support for re-using the attrib channel
>>   Fix disconnecting when primary service discovery is done
>>
>>  Makefile.am      |    4 ++--
>>  attrib/client.c  |   49 ++++++++++++++++++-------------------------------
>>  attrib/client.h  |    6 +++---
>>  attrib/manager.c |   47 -----------------------------------------------
>>  src/adapter.c    |    5 +++++
>>  src/device.c     |   20 +++++++++++++-------
>>  6 files changed, 41 insertions(+), 90 deletions(-)
>>
>> --
>> 1.7.4.1
>>
>
> Cheers,
> --
> Vinicius
> --
> 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 0/6] Move Attrib client (including: should we disconnect or not?)
From: Johan Hedberg @ 2011-03-28 20:48 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: Vinicius Costa Gomes, linux-bluetooth
In-Reply-To: <AANLkTin8et-m0pczJKm9y3z-EHqQdN-49KkAXGGm8jqO@mail.gmail.com>

Hi Claudio & Vinicius,

> >> The move itself is pretty simple, but when implementing it, I took a decision
> >> and I would like to hear your opinion about it.
> >
> > There were problems with some useless includes. I will send another version
> > soon. But the question below remains.
> >
> >>
> >> With this patch series, the behaviour is that we never disconnect from
> >> a LE device unless we are told so, i.e. org.bluez.Device.Disconnect(),
> >> is that what is expected from us?
> 
> In my opinion, the profiles should define how to manage connections.
> For LE re-connections should be avoided since the remote disables the
> advertising when the connection is established.
> Keep the link up seems to be acceptable for now, but for the final
> solution we need to disconnect based on the registered "watchers" and
> profile inputs. Some profiles such as proximity keeps the devices
> always connected and auto-reconnect, others require user interaction.

Sounds good enough to me, i.e. let's keep "connected until an explicit
disconnect request from the user" the default for now.

Johan

^ permalink raw reply

* [PATCH v2 0/6] Attrib client move
From: Vinicius Costa Gomes @ 2011-03-28 22:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

Hi,

This patch series moves the Attrib client to the core, this move is
more related to the build system than with code being moved.

Things left to be done (that will be done in later patches):
 - Remove the attrib plugin;
 - Use SDP information to register primary services;

--
Cheers,


Vinicius Costa Gomes (6):
  Move Attrib client to the core
  Register Attrib interface when loading device from storage
  Register Attrib interface after Primary Service discovery
  Remove _init and _exit methods from Attrib client
  Add support for re-using the attrib channel
  Fix disconnecting when primary service discovery is done

 Makefile.am      |    4 +-
 attrib/client.c  |   49 +++++++++++++++---------------------------
 attrib/client.h  |    6 ++--
 attrib/main.c    |   14 +-----------
 attrib/manager.c |   62 ++---------------------------------------------------
 attrib/manager.h |    2 +-
 src/adapter.c    |    5 ++++
 src/device.c     |   20 +++++++++++------
 8 files changed, 46 insertions(+), 116 deletions(-)

--
1.7.4.1


^ permalink raw reply

* [PATCH v2 1/6] Move Attrib client to the core
From: Vinicius Costa Gomes @ 2011-03-28 22:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1301352051-12046-1-git-send-email-vinicius.gomes@openbossa.org>

---
 Makefile.am      |    4 +-
 attrib/main.c    |   14 +-----------
 attrib/manager.c |   62 ++---------------------------------------------------
 attrib/manager.h |    2 +-
 4 files changed, 7 insertions(+), 75 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a23cc60..77b9b7d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -89,7 +89,8 @@ endif
 endif
 
 attrib_sources = attrib/att.h attrib/att.c attrib/gatt.h attrib/gatt.c \
-		attrib/gattrib.h attrib/gattrib.c
+		attrib/gattrib.h attrib/gattrib.c attrib/client.h \
+		attrib/client.c
 
 gdbus_sources = gdbus/gdbus.h gdbus/mainloop.c gdbus/watch.c \
 					gdbus/object.c gdbus/polkit.c
@@ -204,7 +205,6 @@ endif
 builtin_modules += attrib
 builtin_sources += attrib/main.c \
 		attrib/manager.h attrib/manager.c \
-		attrib/client.h attrib/client.c \
 		attrib/example.h attrib/example.c
 endif
 
diff --git a/attrib/main.c b/attrib/main.c
index 6c946be..91ddab1 100644
--- a/attrib/main.c
+++ b/attrib/main.c
@@ -28,32 +28,20 @@
 
 #include <errno.h>
 
-#include <gdbus.h>
-
 #include "plugin.h"
 #include "manager.h"
 
-static DBusConnection *connection;
-
 static int attrib_init(void)
 {
-	connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-	if (connection == NULL)
+	if (attrib_manager_init() < 0)
 		return -EIO;
 
-	if (attrib_manager_init(connection) < 0) {
-		dbus_connection_unref(connection);
-		return -EIO;
-	}
-
 	return 0;
 }
 
 static void attrib_exit(void)
 {
 	attrib_manager_exit();
-
-	dbus_connection_unref(connection);
 }
 
 BLUETOOTH_PLUGIN_DEFINE(attrib, VERSION,
diff --git a/attrib/manager.c b/attrib/manager.c
index a5a7de4..7c05720 100644
--- a/attrib/manager.c
+++ b/attrib/manager.c
@@ -26,66 +26,16 @@
 #include <config.h>
 #endif
 
-#include <bluetooth/bluetooth.h>
-#include <bluetooth/sdp.h>
-#include <bluetooth/sdp_lib.h>
+#include <stdint.h>
+#include <glib.h>
 
-#include "../src/adapter.h"
-#include "../src/device.h"
 #include "hcid.h"
 
 #include "manager.h"
-#include "client.h"
 #include "example.h"
 
-#define GATT_UUID	"00001801-0000-1000-8000-00805f9b34fb"
-
-static DBusConnection *connection;
-
-static int client_probe(struct btd_device *device, GSList *uuids)
+int attrib_manager_init(void)
 {
-	const sdp_record_t *rec;
-	int psm = -1;
-
-	rec = btd_device_get_record(device, GATT_UUID);
-	if (rec) {
-		sdp_list_t *list;
-		if (sdp_get_access_protos(rec, &list) < 0)
-			return -1;
-
-		psm = sdp_get_proto_port(list, L2CAP_UUID);
-
-		sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
-		sdp_list_free(list, NULL);
-
-		if (psm < 0)
-			return -1;
-	}
-
-	return attrib_client_register(device, psm);
-}
-
-static void client_remove(struct btd_device *device)
-{
-	attrib_client_unregister(device);
-}
-
-static struct btd_device_driver client_driver = {
-	.name = "gatt-client",
-	.uuids = BTD_UUIDS(GATT_UUID),
-	.probe = client_probe,
-	.remove = client_remove,
-};
-
-int attrib_manager_init(DBusConnection *conn)
-{
-	connection = dbus_connection_ref(conn);
-
-	attrib_client_init(connection);
-
-	btd_register_device_driver(&client_driver);
-
-
 	if (main_opts.attrib_server)
 		return server_example_init();
 
@@ -94,12 +44,6 @@ int attrib_manager_init(DBusConnection *conn)
 
 void attrib_manager_exit(void)
 {
-	btd_unregister_device_driver(&client_driver);
-
 	if (main_opts.attrib_server)
 		server_example_exit();
-
-	attrib_client_exit();
-
-	dbus_connection_unref(connection);
 }
diff --git a/attrib/manager.h b/attrib/manager.h
index fabf342..19dc539 100644
--- a/attrib/manager.h
+++ b/attrib/manager.h
@@ -22,5 +22,5 @@
  *
  */
 
-int attrib_manager_init(DBusConnection *conn);
+int attrib_manager_init(void);
 void attrib_manager_exit(void);
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH v2 2/6] Register Attrib interface when loading device from storage
From: Vinicius Costa Gomes @ 2011-03-28 22:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1301352051-12046-1-git-send-email-vinicius.gomes@openbossa.org>

Now that the GATT client functionality is being moved to the
core we need to register the interface when the device is created.
---
 attrib/client.c |    3 +--
 attrib/client.h |    2 +-
 src/adapter.c   |    4 ++++
 src/device.c    |    3 +++
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 54bdc79..590f33b 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -1044,12 +1044,11 @@ static void register_primaries(struct gatt_service *gatt, GSList *primaries)
 	}
 }
 
-int attrib_client_register(struct btd_device *device, int psm)
+int attrib_client_register(struct btd_device *device, int psm, GSList *primaries)
 {
 	struct btd_adapter *adapter = device_get_adapter(device);
 	const char *path = device_get_path(device);
 	struct gatt_service *gatt;
-	GSList *primaries = btd_device_get_primaries(device);
 	bdaddr_t sba, dba;
 
 	adapter_get_address(adapter, &sba);
diff --git a/attrib/client.h b/attrib/client.h
index 50e2b5f..2bee84c 100644
--- a/attrib/client.h
+++ b/attrib/client.h
@@ -24,5 +24,5 @@
 
 int attrib_client_init(DBusConnection *conn);
 void attrib_client_exit(void);
-int attrib_client_register(struct btd_device *device, int psm);
+int attrib_client_register(struct btd_device *device, int psm, GSList *primaries);
 void attrib_client_unregister(struct btd_device *device);
diff --git a/src/adapter.c b/src/adapter.c
index 5894146..dad427f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -58,6 +58,7 @@
 #include "storage.h"
 #include "attrib-server.h"
 #include "att.h"
+#include "attrib/client.h"
 
 /* Flags Descriptions */
 #define EIR_LIM_DISC                0x01 /* LE Limited Discoverable Mode */
@@ -2180,6 +2181,9 @@ static void create_stored_device_from_primary(char *key, char *value,
 		device_add_primary(device, prim);
 	}
 
+	/* FIXME: Need the correct psm */
+	attrib_client_register(device, -1, services);
+
 	device_probe_drivers(device, uuids);
 
 	g_slist_free(services);
diff --git a/src/device.c b/src/device.c
index 771a908..9a3202f 100644
--- a/src/device.c
+++ b/src/device.c
@@ -60,6 +60,7 @@
 #include "sdp-xml.h"
 #include "storage.h"
 #include "btio.h"
+#include "attrib/client.h"
 
 #define DISCONNECT_TIMER	2
 #define DISCOVERY_TIMER		2
@@ -1030,6 +1031,8 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
 	g_slist_free(device->drivers);
 	device->drivers = NULL;
 
+	attrib_client_unregister(device);
+
 	btd_device_unref(device);
 }
 
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH v2 3/6] Register Attrib interface after Primary Service discovery
From: Vinicius Costa Gomes @ 2011-03-28 22:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1301352051-12046-1-git-send-email-vinicius.gomes@openbossa.org>

---
 src/device.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/device.c b/src/device.c
index 9a3202f..1d7094b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1546,6 +1546,10 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
 	}
 
 	device_probe_drivers(device, uuids);
+
+	/* FIXME: Need the correct psm */
+	attrib_client_register(device, -1, services);
+
 	g_slist_free(uuids);
 
 	create_device_reply(device, req);
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH v2 4/6] Remove _init and _exit methods from Attrib client
From: Vinicius Costa Gomes @ 2011-03-28 22:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1301352051-12046-1-git-send-email-vinicius.gomes@openbossa.org>

Now that Attrib client is being moved to the core, there's no
need to have explicit _init and _exit methods.

This also means that we need to pass the DBusConnection explicitly
to the registration method.
---
 attrib/client.c |   44 ++++++++++++++------------------------------
 attrib/client.h |    5 ++---
 src/adapter.c   |    2 +-
 src/device.c    |    2 +-
 4 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 590f33b..acd35f9 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -52,6 +52,7 @@
 
 struct gatt_service {
 	struct btd_device *dev;
+	DBusConnection *conn;
 	bdaddr_t sba;
 	bdaddr_t dba;
 	char *path;
@@ -108,8 +109,6 @@ struct watcher {
 
 static GSList *gatt_services = NULL;
 
-static DBusConnection *connection;
-
 static void characteristic_free(void *user_data)
 {
 	struct characteristic *chr = user_data;
@@ -138,7 +137,7 @@ static void primary_free(void *user_data)
 
 	for (l = prim->watchers; l; l = l->next) {
 		struct watcher *watcher = l->data;
-		g_dbus_remove_watch(connection, watcher->id);
+		g_dbus_remove_watch(prim->gatt->conn, watcher->id);
 	}
 
 	g_slist_foreach(prim->chars, (GFunc) characteristic_free, NULL);
@@ -156,6 +155,7 @@ static void gatt_service_free(void *user_data)
 	g_attrib_unref(gatt->attrib);
 	g_free(gatt->path);
 	btd_device_unref(gatt->dev);
+	dbus_connection_unref(gatt->conn);
 	g_free(gatt);
 }
 
@@ -249,6 +249,7 @@ static void update_watchers(gpointer data, gpointer user_data)
 {
 	struct watcher *w = data;
 	struct characteristic *chr = user_data;
+	DBusConnection *conn = w->prim->gatt->conn;
 	DBusMessage *msg;
 
 	msg = dbus_message_new_method_call(w->name, w->path,
@@ -261,7 +262,7 @@ static void update_watchers(gpointer data, gpointer user_data)
 			&chr->value, chr->vlen, DBUS_TYPE_INVALID);
 
 	dbus_message_set_no_reply(msg, TRUE);
-	g_dbus_send_message(connection, msg);
+	g_dbus_send_message(conn, msg);
 }
 
 static void events_handler(const uint8_t *pdu, uint16_t len,
@@ -337,7 +338,7 @@ static void connect_cb(GIOChannel *chan, GError *gerr, gpointer user_data)
 		if (gatt->msg) {
 			DBusMessage *reply = btd_error_failed(gatt->msg,
 							gerr->message);
-			g_dbus_send_message(connection, reply);
+			g_dbus_send_message(gatt->conn, reply);
 		}
 
 		error("%s", gerr->message);
@@ -592,7 +593,7 @@ static void register_characteristics(struct primary *prim)
 
 	for (lc = prim->chars; lc; lc = lc->next) {
 		struct characteristic *chr = lc->data;
-		g_dbus_register_interface(connection, chr->path,
+		g_dbus_register_interface(prim->gatt->conn, chr->path,
 				CHAR_INTERFACE, char_methods,
 				NULL, NULL, chr, NULL);
 		DBG("Registered: %s", chr->path);
@@ -936,7 +937,7 @@ static void char_discovered_cb(GSList *characteristics, guint8 status,
 	g_slist_foreach(prim->chars, update_all_chars, prim);
 
 fail:
-	g_dbus_send_message(connection, reply);
+	g_dbus_send_message(gatt->conn, reply);
 	g_attrib_unref(gatt->attrib);
 	g_free(current);
 }
@@ -1033,7 +1034,7 @@ static void register_primaries(struct gatt_service *gatt, GSList *primaries)
 		prim->path = g_strdup_printf("%s/service%04x", gatt->path,
 								att->start);
 
-		g_dbus_register_interface(connection, prim->path,
+		g_dbus_register_interface(gatt->conn, prim->path,
 				CHAR_INTERFACE, prim_methods,
 				NULL, NULL, prim, NULL);
 		DBG("Registered: %s", prim->path);
@@ -1044,7 +1045,8 @@ static void register_primaries(struct gatt_service *gatt, GSList *primaries)
 	}
 }
 
-int attrib_client_register(struct btd_device *device, int psm, GSList *primaries)
+int attrib_client_register(DBusConnection *connection,
+		struct btd_device *device, int psm, GSList *primaries)
 {
 	struct btd_adapter *adapter = device_get_adapter(device);
 	const char *path = device_get_path(device);
@@ -1056,6 +1058,7 @@ int attrib_client_register(struct btd_device *device, int psm, GSList *primaries
 
 	gatt = g_new0(struct gatt_service, 1);
 	gatt->dev = btd_device_ref(device);
+	gatt->conn = dbus_connection_ref(connection);
 	gatt->listen = FALSE;
 	gatt->path = g_strdup(path);
 	bacpy(&gatt->sba, &sba);
@@ -1085,31 +1088,12 @@ void attrib_client_unregister(struct btd_device *device)
 		struct primary *prim = lp->data;
 		for (lc = prim->chars; lc; lc = lc->next) {
 			struct characteristic *chr = lc->data;
-			g_dbus_unregister_interface(connection, chr->path,
+			g_dbus_unregister_interface(gatt->conn, chr->path,
 								CHAR_INTERFACE);
 		}
-		g_dbus_unregister_interface(connection, prim->path,
+		g_dbus_unregister_interface(gatt->conn, prim->path,
 								CHAR_INTERFACE);
 	}
 
 	gatt_service_free(gatt);
 }
-
-int attrib_client_init(DBusConnection *conn)
-{
-
-	connection = dbus_connection_ref(conn);
-
-	/*
-	 * FIXME: if the adapter supports BLE start scanning. Temporary
-	 * solution, this approach doesn't allow to control scanning based
-	 * on the discoverable property.
-	 */
-
-	return 0;
-}
-
-void attrib_client_exit(void)
-{
-	dbus_connection_unref(connection);
-}
diff --git a/attrib/client.h b/attrib/client.h
index 2bee84c..650b0c1 100644
--- a/attrib/client.h
+++ b/attrib/client.h
@@ -22,7 +22,6 @@
  *
  */
 
-int attrib_client_init(DBusConnection *conn);
-void attrib_client_exit(void);
-int attrib_client_register(struct btd_device *device, int psm, GSList *primaries);
+int attrib_client_register(DBusConnection *connection,
+		struct btd_device *device, int psm, GSList *primaries);
 void attrib_client_unregister(struct btd_device *device);
diff --git a/src/adapter.c b/src/adapter.c
index dad427f..da13f69 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2182,7 +2182,7 @@ static void create_stored_device_from_primary(char *key, char *value,
 	}
 
 	/* FIXME: Need the correct psm */
-	attrib_client_register(device, -1, services);
+	attrib_client_register(connection, device, -1, services);
 
 	device_probe_drivers(device, uuids);
 
diff --git a/src/device.c b/src/device.c
index 1d7094b..511c9d0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1548,7 +1548,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
 	device_probe_drivers(device, uuids);
 
 	/* FIXME: Need the correct psm */
-	attrib_client_register(device, -1, services);
+	attrib_client_register(req->conn, device, -1, services);
 
 	g_slist_free(uuids);
 
-- 
1.7.4.1


^ 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