* [PATCH BlueZ] AVRCP: Fix not handling commands while browsing is connecting
From: Luiz Augusto von Dentz @ 2013-01-27 22:37 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With introdution of browsing channel the .init callback is called when
browsing channel connection completes, but in the meantime the remote
device can send commands over control channel.
To fix this the init callaback of control and browsing channel are now
separated into .init_control and .init_browsing so the handler can be
register as soon the respective channel connection completes.
---
v2: Separate control and browsing inits and use handler id to track if channel
has been initialized or not.
profiles/audio/avrcp.c | 73 +++++++++++++++++++++++++++++---------------------
1 file changed, 42 insertions(+), 31 deletions(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 4965b0c..6b61664 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -190,9 +190,9 @@ struct avrcp {
gboolean target;
uint16_t version;
int features;
- bool initialized;
- void (*init) (struct avrcp *session);
+ void (*init_control) (struct avrcp *session);
+ void (*init_browsing) (struct avrcp *session);
void (*destroy) (struct avrcp *sesion);
const struct control_pdu_handler *control_handlers;
@@ -2165,14 +2165,23 @@ static struct avrcp *find_session(GSList *list, struct audio_device *dev)
return NULL;
}
-static void session_tg_init(struct avrcp *session)
+static void session_tg_init_browsing(struct avrcp *session)
+{
+ session->browsing_id = avctp_register_browsing_pdu_handler(
+ session->conn,
+ handle_browsing_pdu,
+ session);
+}
+
+static void session_tg_init_control(struct avrcp *session)
{
struct avrcp_server *server = session->server;
struct avrcp_player *player;
- DBG("%p version 0x%04x", session, session->version);
+ if (session->version < 0x0103)
+ return;
- session->initialized = true;
+ DBG("%p version 0x%04x", session, session->version);
player = g_slist_nth_data(server->players, 0);
if (player != NULL) {
@@ -2180,6 +2189,10 @@ static void session_tg_init(struct avrcp *session)
player->sessions = g_slist_prepend(player->sessions, session);
}
+ session->control_id = avctp_register_pdu_handler(session->conn,
+ AVC_OP_VENDORDEP,
+ handle_vendordep_pdu,
+ session);
session->control_handlers = tg_control_handlers;
session->supported_events = (1 << AVRCP_EVENT_STATUS_CHANGED) |
(1 << AVRCP_EVENT_TRACK_CHANGED) |
@@ -2190,36 +2203,31 @@ static void session_tg_init(struct avrcp *session)
if (session->version >= 0x0104)
avrcp_register_notification(session,
AVRCP_EVENT_VOLUME_CHANGED);
+}
- session->control_id = avctp_register_pdu_handler(session->conn,
- AVC_OP_VENDORDEP,
- handle_vendordep_pdu,
- session);
+static void session_ct_init_browsing(struct avrcp *session)
+{
session->browsing_id = avctp_register_browsing_pdu_handler(
session->conn,
handle_browsing_pdu,
session);
}
-static void session_ct_init(struct avrcp *session)
+static void session_ct_init_control(struct avrcp *session)
{
struct avrcp_player *player;
struct media_player *mp;
const char *path;
- session->control_handlers = ct_control_handlers;
-
- if (session->version >= 0x0104)
- session->supported_events = (1 << AVRCP_EVENT_VOLUME_CHANGED);
-
DBG("%p version 0x%04x", session, session->version);
- session->initialized = true;
-
session->control_id = avctp_register_pdu_handler(session->conn,
AVC_OP_VENDORDEP,
handle_vendordep_pdu,
session);
+ session->control_handlers = ct_control_handlers;
+ if (session->version >= 0x0104)
+ session->supported_events = (1 << AVRCP_EVENT_VOLUME_CHANGED);
player = g_new0(struct avrcp_player, 1);
player->sessions = g_slist_prepend(player->sessions, session);
@@ -2316,11 +2324,13 @@ static struct avrcp *session_create(struct avrcp_server *server,
session->target = FALSE;
if (session->target) {
- session->init = session_tg_init;
+ session->init_control = session_tg_init_control;
+ session->init_browsing = session_tg_init_browsing;
session->destroy = session_tg_destroy;
rec = btd_device_get_record(dev->btd_dev, AVRCP_REMOTE_UUID);
} else {
- session->init = session_ct_init;
+ session->init_control = session_ct_init_control;
+ session->init_browsing = session_ct_init_browsing;
session->destroy = session_ct_destroy;
rec = btd_device_get_record(dev->btd_dev, AVRCP_TARGET_UUID);
}
@@ -2368,26 +2378,27 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
break;
case AVCTP_STATE_CONNECTED:
- if (session == NULL || session->initialized)
+ if (session == NULL)
break;
- /* Initialize session if browsing cannot be used */
- if (session->version <= 0x0103 ||
- old_state == AVCTP_STATE_BROWSING_CONNECTING ||
- !(session->features & AVRCP_FEATURE_BROWSING)) {
- session->init(session);
- break;
- }
+ if (session->browsing_id > 0)
+ session->browsing_id = 0;
+
+ if (session->control_id > 0)
+ return;
+
+ session->init_control(session);
- if (avctp_connect_browsing(session->conn) != 0)
- session->init(session);
+ if (session->version >= 0x0104 &&
+ session->features & AVRCP_FEATURE_BROWSING)
+ avctp_connect_browsing(session->conn);
break;
case AVCTP_STATE_BROWSING_CONNECTED:
- if (session == NULL || session->initialized)
+ if (session == NULL || session->browsing_id > 0)
break;
- session->init(session);
+ session->init_browsing(session);
break;
default:
return;
--
1.8.1
^ permalink raw reply related
* [PATCH BlueZ] AVRCP: Fix not handling commands while browsing is connecting
From: Luiz Augusto von Dentz @ 2013-01-27 21:03 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With introdution of browsing channel the .init callback is called when
browsing channel connection completes, but in the meantime the remote
device can send commands over control channel.
To fix this a new callback .connect is introduced to register the PDU
handlers as soon as the control connection completes leaving .init with
only command initialization.
---
profiles/audio/avrcp.c | 59 ++++++++++++++++++++++++++++++++------------------
1 file changed, 38 insertions(+), 21 deletions(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 4965b0c..8c92968 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -192,6 +192,7 @@ struct avrcp {
int features;
bool initialized;
+ void (*connect) (struct avrcp *session);
void (*init) (struct avrcp *session);
void (*destroy) (struct avrcp *sesion);
@@ -2165,6 +2166,28 @@ static struct avrcp *find_session(GSList *list, struct audio_device *dev)
return NULL;
}
+static void session_tg_connect(struct avrcp *session)
+{
+ if (session->control_id > 0)
+ return;
+
+ session->control_handlers = tg_control_handlers;
+ session->supported_events = (1 << AVRCP_EVENT_STATUS_CHANGED) |
+ (1 << AVRCP_EVENT_TRACK_CHANGED) |
+ (1 << AVRCP_EVENT_TRACK_REACHED_START) |
+ (1 << AVRCP_EVENT_TRACK_REACHED_END) |
+ (1 << AVRCP_EVENT_SETTINGS_CHANGED);
+
+ session->control_id = avctp_register_pdu_handler(session->conn,
+ AVC_OP_VENDORDEP,
+ handle_vendordep_pdu,
+ session);
+ session->browsing_id = avctp_register_browsing_pdu_handler(
+ session->conn,
+ handle_browsing_pdu,
+ session);
+}
+
static void session_tg_init(struct avrcp *session)
{
struct avrcp_server *server = session->server;
@@ -2180,25 +2203,25 @@ static void session_tg_init(struct avrcp *session)
player->sessions = g_slist_prepend(player->sessions, session);
}
- session->control_handlers = tg_control_handlers;
- session->supported_events = (1 << AVRCP_EVENT_STATUS_CHANGED) |
- (1 << AVRCP_EVENT_TRACK_CHANGED) |
- (1 << AVRCP_EVENT_TRACK_REACHED_START) |
- (1 << AVRCP_EVENT_TRACK_REACHED_END) |
- (1 << AVRCP_EVENT_SETTINGS_CHANGED);
-
if (session->version >= 0x0104)
avrcp_register_notification(session,
AVRCP_EVENT_VOLUME_CHANGED);
+}
+
+static void session_ct_connect(struct avrcp *session)
+{
+ if (session->control_id > 0)
+ return;
+ session->control_handlers = ct_control_handlers;
session->control_id = avctp_register_pdu_handler(session->conn,
AVC_OP_VENDORDEP,
handle_vendordep_pdu,
session);
- session->browsing_id = avctp_register_browsing_pdu_handler(
- session->conn,
- handle_browsing_pdu,
- session);
+ if (session->version < 0x0103)
+ return;
+
+ session->supported_events = (1 << AVRCP_EVENT_VOLUME_CHANGED);
}
static void session_ct_init(struct avrcp *session)
@@ -2207,20 +2230,10 @@ static void session_ct_init(struct avrcp *session)
struct media_player *mp;
const char *path;
- session->control_handlers = ct_control_handlers;
-
- if (session->version >= 0x0104)
- session->supported_events = (1 << AVRCP_EVENT_VOLUME_CHANGED);
-
DBG("%p version 0x%04x", session, session->version);
session->initialized = true;
- session->control_id = avctp_register_pdu_handler(session->conn,
- AVC_OP_VENDORDEP,
- handle_vendordep_pdu,
- session);
-
player = g_new0(struct avrcp_player, 1);
player->sessions = g_slist_prepend(player->sessions, session);
session->player = player;
@@ -2316,10 +2329,12 @@ static struct avrcp *session_create(struct avrcp_server *server,
session->target = FALSE;
if (session->target) {
+ session->connect = session_tg_connect;
session->init = session_tg_init;
session->destroy = session_tg_destroy;
rec = btd_device_get_record(dev->btd_dev, AVRCP_REMOTE_UUID);
} else {
+ session->connect = session_ct_connect;
session->init = session_ct_init;
session->destroy = session_ct_destroy;
rec = btd_device_get_record(dev->btd_dev, AVRCP_TARGET_UUID);
@@ -2371,6 +2386,8 @@ static void state_changed(struct audio_device *dev, avctp_state_t old_state,
if (session == NULL || session->initialized)
break;
+ session->connect(session);
+
/* Initialize session if browsing cannot be used */
if (session->version <= 0x0103 ||
old_state == AVCTP_STATE_BROWSING_CONNECTING ||
--
1.8.1
^ permalink raw reply related
* Re: [PATCH 2/2 v2] Bluetooth: Increment Management interface revision
From: Marcel Holtmann @ 2013-01-27 14:37 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359297121-9022-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch increments the management interface revision due to the
> various fixes, improvements and other changes that have gone in lately.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/2 v2] Bluetooth: Fix link security setting when powering on
From: Marcel Holtmann @ 2013-01-27 14:36 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359297121-9022-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> If a controller is powered on while the HCI_AUTO_OFF flag is set the
> link security setting (HCI_LINK_SECURITY) might not be in sync with the
> actual state of the controller (HCI_AUTH). This patch fixes the issue by
> checking for inequality between the intended and actual settings and
> sends a HCI_Write_Auth_Enable command if necessary.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* [PATCH 2/2 v2] Bluetooth: Increment Management interface revision
From: Johan Hedberg @ 2013-01-27 14:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359297121-9022-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch increments the management interface revision due to the
various fixes, improvements and other changes that have gone in lately.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ae7585d..3bd4c41 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -35,7 +35,7 @@
bool enable_hs;
#define MGMT_VERSION 1
-#define MGMT_REVISION 2
+#define MGMT_REVISION 3
static const u16 mgmt_commands[] = {
MGMT_OP_READ_INDEX_LIST,
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/2 v2] Bluetooth: Fix link security setting when powering on
From: Johan Hedberg @ 2013-01-27 14:32 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
If a controller is powered on while the HCI_AUTO_OFF flag is set the
link security setting (HCI_LINK_SECURITY) might not be in sync with the
actual state of the controller (HCI_AUTH). This patch fixes the issue by
checking for inequality between the intended and actual settings and
sends a HCI_Write_Auth_Enable command if necessary.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fbc8edf..ae7585d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3073,6 +3073,8 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, settings_rsp, &match);
if (powered) {
+ u8 link_sec;
+
if (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) &&
!lmp_host_ssp_capable(hdev)) {
u8 ssp = 1;
@@ -3096,6 +3098,11 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
sizeof(cp), &cp);
}
+ link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
+ if (link_sec != test_bit(HCI_AUTH, &hdev->flags))
+ hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
+ sizeof(link_sec), &link_sec);
+
if (lmp_bredr_capable(hdev)) {
set_bredr_scan(hdev);
update_class(hdev);
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH] Bluetooth: btmrvl_sdio: look for sd8688 firmware in alternate place
From: Lubomir Rintel @ 2013-01-27 11:21 UTC (permalink / raw)
To: Ben Hutchings
Cc: Marcel Holtmann, David Woodhouse, Bing Zhao,
libertas-dev@lists.infradead.org, linux-bluetooth@vger.kernel.org,
Gustavo Padovan, Johan Hedberg, linux-kernel@vger.kernel.org
In-Reply-To: <1358730733.24121.228.camel@deadeye.wl.decadent.org.uk>
On Mon, 2013-01-21 at 01:12 +0000, Ben Hutchings wrote:
> On Fri, 2013-01-18 at 08:33 +0100, Lubomir Rintel wrote:
> > On Tue, 2013-01-08 at 22:35 -0800, Marcel Holtmann wrote:
> > > Hi Lubomir,
> > >
> > > > > > > linux-firmware ships the sd8688* firmware images that are shared with
> > > > > > > libertas_sdio WiFi driver under libertas/. libertas_sdio looks in both places
> > > > > > > and so should we.
> > > > > > >
> > > > > > > Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
> > > > > > > ---
> > > > > > > drivers/bluetooth/btmrvl_sdio.c | 24 ++++++++++++++++++++++--
> > > > > > > drivers/bluetooth/btmrvl_sdio.h | 6 ++++--
> > > > > > > 2 files changed, 26 insertions(+), 4 deletions(-)
> > > > > >
> > > > > > NAK from me on this one. I do not want the driver to check two
> > > > > > locations. That is what userspace can work around.
> > > > > >
> > > > > > If we want to unify the location between the WiFi driver and the
> > > > > > Bluetooth driver, I am fine with that, but seriously, just pick one over
> > > > > > the other. I do not care which one.
> > > > >
> > > > > The unified location is mrvl/ directory.
> > > > >
> > > > > We can probably move SD8688 firmware & helper binaries to mrvl/ and have both drivers grab the images there?
> > > >
> > > > That would break existing setups, wouldn't it?
> > > >
> > > > I was under impression (commit 3d32a58b) that we care about
> > > > compatibility here. Do we?
> > >
> > > that is what symlinks are for.
> >
> > David, Ben: please pull the following branch then:
> > git pull git://github.com/lkundrak/linux-firmware.git sd8688-move
> >
> > Thank you!
>
> The symlinks are broken, and you didn't update WHENCE.
Oops, sorry for that. Fixed now, please pull:
git pull git://github.com/lkundrak/linux-firmware.git sd8688-move
Thank you!
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Fix link security setting when powering on
From: Marcel Holtmann @ 2013-01-27 3:15 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359239630-3579-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> If a controller is powered on while the HCI_AUTO_OFF flag is set the
> link security setting (HCI_LINK_SECURITY) might not be in sync with the
> actual state of the controller (HCI_AUTH). This patch fixes the issue by
> checking for inequality between the intended and actual settings and
> sends a HCI_Write_Auth_Enable command if necessary.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index fbc8edf..f6ef8ff 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -3096,6 +3096,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
> sizeof(cp), &cp);
> }
>
> + if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags) !=
> + test_bit(HCI_AUTH, &hdev->flags)) {
> + u8 val = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
> + hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
> + sizeof(val), &val);
> + }
why not actually just test for the value and store its result, then
compare and then use the value. Testing HCI_LINK_SECURITY twice seems a
bit too much.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 3/9 v4] Bluetooth: Keep track of UUID type upon addition
From: Marcel Holtmann @ 2013-01-27 3:14 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359239495-3444-4-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> The primary purpose of the UUIDs is to enable generation of EIR and AD
> data. In these data formats the UUIDs are split into separate fields
> based on whether they're 16, 32 or 128 bit UUIDs. To make the generation
> of these data fields simpler this patch adds a type member to the
> bt_uuid struct and assigns a value to it as soon as the UUID is added to
> the kernel. This way the type doesn't need to be calculated each time
> the UUID list is later iterated.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/mgmt.c | 48 ++++++++++++++++++--------------------
> 2 files changed, 24 insertions(+), 25 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index bcf8ffe..90cf75a 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -86,6 +86,7 @@ struct bdaddr_list {
> struct bt_uuid {
> struct list_head list;
> u8 uuid[16];
> + u8 size;
> u8 svc_hint;
> };
seems you just went for the size approach. Fine with me as well.
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ] avctp: Handle Vol Up/Down operations
From: Luiz Augusto von Dentz @ 2013-01-26 23:05 UTC (permalink / raw)
To: João Paulo Rechi Vita; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1359136498-18725-1-git-send-email-jprvita@openbossa.org>
Hi Joao,
On Fri, Jan 25, 2013 at 7:54 PM, João Paulo Rechi Vita
<jprvita@openbossa.org> wrote:
> The AVRCP spec mandates to support 'volume up' and 'volume down'
> operations when claiming support for Category 2 TG.
> ---
> profiles/audio/avctp.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
> index d2dce3e..28c414d 100644
> --- a/profiles/audio/avctp.c
> +++ b/profiles/audio/avctp.c
> @@ -213,6 +213,8 @@ static struct {
> uint8_t avc;
> uint16_t uinput;
> } key_map[] = {
> + { "VOLUME UP", AVC_VOLUME_UP, KEY_VOLUMEUP},
> + { "VOLUME DOWN", AVC_VOLUME_DOWN, KEY_VOLUMEDOWN},
> { "PLAY", AVC_PLAY, KEY_PLAYCD },
> { "STOP", AVC_STOP, KEY_STOPCD },
> { "PAUSE", AVC_PAUSE, KEY_PAUSECD },
> --
> 1.7.11.7
>
Applied, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* [PATCH 2/2] Bluetooth: Increment Management interface revision
From: Johan Hedberg @ 2013-01-26 22:33 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239630-3579-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The fixing of several mgmt issues, such as the correct handling of 32
and 128 bit UUIDs means that it is now safe for user space to send such
commands. However, user space needs a way to detect that it is safe, so
increment the mgmt revision so that it can be checked against.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f6ef8ff..8e69d89 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -35,7 +35,7 @@
bool enable_hs;
#define MGMT_VERSION 1
-#define MGMT_REVISION 2
+#define MGMT_REVISION 3
static const u16 mgmt_commands[] = {
MGMT_OP_READ_INDEX_LIST,
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/2] Bluetooth: Fix link security setting when powering on
From: Johan Hedberg @ 2013-01-26 22:33 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
If a controller is powered on while the HCI_AUTO_OFF flag is set the
link security setting (HCI_LINK_SECURITY) might not be in sync with the
actual state of the controller (HCI_AUTH). This patch fixes the issue by
checking for inequality between the intended and actual settings and
sends a HCI_Write_Auth_Enable command if necessary.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fbc8edf..f6ef8ff 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3096,6 +3096,13 @@ int mgmt_powered(struct hci_dev *hdev, u8 powered)
sizeof(cp), &cp);
}
+ if (test_bit(HCI_LINK_SECURITY, &hdev->dev_flags) !=
+ test_bit(HCI_AUTH, &hdev->flags)) {
+ u8 val = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
+ hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE,
+ sizeof(val), &val);
+ }
+
if (lmp_bredr_capable(hdev)) {
set_bredr_scan(hdev);
update_class(hdev);
--
1.7.10.4
^ permalink raw reply related
* [PATCH 9/9 v4] Bluetooth: Add support for 128-bit UUIDs in EIR data
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds the necessary code for encoding a list of 128-bit UUIDs
into the EIR data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 0110a75..fbc8edf 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -510,6 +510,39 @@ static u8 *create_uuid32_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
return ptr;
}
+static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
+{
+ u8 *ptr = data, *uuids_start = NULL;
+ struct bt_uuid *uuid;
+
+ if (len < 18)
+ return ptr;
+
+ list_for_each_entry(uuid, &hdev->uuids, list) {
+ if (uuid->size != 128)
+ continue;
+
+ if (!uuids_start) {
+ uuids_start = ptr;
+ uuids_start[0] = 1;
+ uuids_start[1] = EIR_UUID128_ALL;
+ ptr += 2;
+ }
+
+ /* Stop if not enough space to put next UUID */
+ if ((ptr - data) + 16 > len) {
+ uuids_start[1] = EIR_UUID128_SOME;
+ break;
+ }
+
+ memcpy(ptr, uuid->uuid, 16);
+ ptr += 16;
+ uuids_start[0] += 16;
+ }
+
+ return ptr;
+}
+
static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
@@ -555,6 +588,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
ptr = create_uuid32_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
+ ptr = create_uuid128_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
}
static int update_eir(struct hci_dev *hdev)
--
1.7.10.4
^ permalink raw reply related
* [PATCH 8/9 v4] Bluetooth: Add support for 32-bit UUIDs in EIR data
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds the necessary code for inserting a list of 32-bit UUIDs
into the EIR data.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 497928d..0110a75 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -477,6 +477,39 @@ static u8 *create_uuid16_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
return ptr;
}
+static u8 *create_uuid32_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
+{
+ u8 *ptr = data, *uuids_start = NULL;
+ struct bt_uuid *uuid;
+
+ if (len < 6)
+ return ptr;
+
+ list_for_each_entry(uuid, &hdev->uuids, list) {
+ if (uuid->size != 32)
+ continue;
+
+ if (!uuids_start) {
+ uuids_start = ptr;
+ uuids_start[0] = 1;
+ uuids_start[1] = EIR_UUID32_ALL;
+ ptr += 2;
+ }
+
+ /* Stop if not enough space to put next UUID */
+ if ((ptr - data) + sizeof(u32) > len) {
+ uuids_start[1] = EIR_UUID32_SOME;
+ break;
+ }
+
+ memcpy(ptr, &uuid->uuid[12], sizeof(u32));
+ ptr += sizeof(u32);
+ uuids_start[0] += sizeof(u32);
+ }
+
+ return ptr;
+}
+
static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
@@ -521,6 +554,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
}
ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
+ ptr = create_uuid32_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
}
static int update_eir(struct hci_dev *hdev)
--
1.7.10.4
^ permalink raw reply related
* [PATCH 7/9 v4] Bluetooth: Refactor UUID-16 list generation into its own function
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We will need to create three separate UUID lists in the EIR data (for
16, 32 and 128 bit UUIDs) so the code is easier to follow if each list
is generated in their own function.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 78 ++++++++++++++++++++++++++++----------------------
1 file changed, 43 insertions(+), 35 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5e18d5a..497928d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -435,11 +435,51 @@ static u32 get_current_settings(struct hci_dev *hdev)
#define PNP_INFO_SVCLASS_ID 0x1200
+static u8 *create_uuid16_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
+{
+ u8 *ptr = data, *uuids_start = NULL;
+ struct bt_uuid *uuid;
+
+ if (len < 4)
+ return ptr;
+
+ list_for_each_entry(uuid, &hdev->uuids, list) {
+ u16 uuid16;
+
+ if (uuid->size != 16)
+ continue;
+
+ uuid16 = get_unaligned_le16(&uuid->uuid[12]);
+ if (uuid16 < 0x1100)
+ continue;
+
+ if (uuid16 == PNP_INFO_SVCLASS_ID)
+ continue;
+
+ if (!uuids_start) {
+ uuids_start = ptr;
+ uuids_start[0] = 1;
+ uuids_start[1] = EIR_UUID16_ALL;
+ ptr += 2;
+ }
+
+ /* Stop if not enough space to put next UUID */
+ if ((ptr - data) + sizeof(u16) > len) {
+ uuids_start[1] = EIR_UUID16_SOME;
+ break;
+ }
+
+ *ptr++ = (uuid16 & 0x00ff);
+ *ptr++ = (uuid16 & 0xff00) >> 8;
+ uuids_start[0] += sizeof(uuid16);
+ }
+
+ return ptr;
+}
+
static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
- u8 *uuids_start;
- struct bt_uuid *uuid;
size_t name_len;
name_len = strlen(hdev->dev_name);
@@ -480,39 +520,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr += 10;
}
- uuids_start = NULL;
-
- /* Group all UUID16 types */
- list_for_each_entry(uuid, &hdev->uuids, list) {
- u16 uuid16;
-
- if (uuid->size != 16)
- continue;
-
- uuid16 = get_unaligned_le16(&uuid->uuid[12]);
- if (uuid16 < 0x1100)
- continue;
-
- if (uuid16 == PNP_INFO_SVCLASS_ID)
- continue;
-
- if (!uuids_start) {
- uuids_start = ptr;
- uuids_start[0] = 1;
- uuids_start[1] = EIR_UUID16_ALL;
- ptr += 2;
- }
-
- /* Stop if not enough space to put next UUID */
- if ((ptr - data) + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
- uuids_start[1] = EIR_UUID16_SOME;
- break;
- }
-
- *ptr++ = (uuid16 & 0x00ff);
- *ptr++ = (uuid16 & 0xff00) >> 8;
- uuids_start[0] += sizeof(uuid16);
- }
+ ptr = create_uuid16_list(hdev, ptr, HCI_MAX_EIR_LENGTH - (ptr - data));
}
static int update_eir(struct hci_dev *hdev)
--
1.7.10.4
^ permalink raw reply related
* [PATCH 6/9 v4] Bluetooth: Remove useless eir_len variable from EIR creation
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The amount of data encoded so far in the create_eir() function can be
calculated simply through the difference between the data and ptr
pointer variables. The eir_len variable then becomes essentially
useless.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 02827af..5e18d5a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -439,7 +439,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
u8 *uuids_start;
- u16 eir_len = 0;
struct bt_uuid *uuid;
size_t name_len;
@@ -458,7 +457,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
memcpy(ptr + 2, hdev->dev_name, name_len);
- eir_len += (name_len + 2);
ptr += (name_len + 2);
}
@@ -467,7 +465,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr[1] = EIR_TX_POWER;
ptr[2] = (u8) hdev->inq_tx_power;
- eir_len += 3;
ptr += 3;
}
@@ -480,7 +477,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
put_unaligned_le16(hdev->devid_product, ptr + 6);
put_unaligned_le16(hdev->devid_version, ptr + 8);
- eir_len += 10;
ptr += 10;
}
@@ -505,18 +501,16 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
uuids_start[0] = 1;
uuids_start[1] = EIR_UUID16_ALL;
ptr += 2;
- eir_len += 2;
}
/* Stop if not enough space to put next UUID */
- if (eir_len + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
+ if ((ptr - data) + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
uuids_start[1] = EIR_UUID16_SOME;
break;
}
*ptr++ = (uuid16 & 0x00ff);
*ptr++ = (uuid16 & 0xff00) >> 8;
- eir_len += sizeof(uuid16);
uuids_start[0] += sizeof(uuid16);
}
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 5/9 v4] Bluetooth: Simplify UUID16 list generation for EIR
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
There's no need to use two separate loops to generate a UUID list for
the EIR data. This patch merges the two loops previously used for the
16-bit UUID list generation into a single loop, thus simplifying the
code a great deal.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 46 +++++++++++++++-------------------------------
1 file changed, 15 insertions(+), 31 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 1e906d8..02827af 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -438,9 +438,8 @@ static u32 get_current_settings(struct hci_dev *hdev)
static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
+ u8 *uuids_start;
u16 eir_len = 0;
- u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)];
- int i, truncated = 0;
struct bt_uuid *uuid;
size_t name_len;
@@ -485,7 +484,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr += 10;
}
- memset(uuid16_list, 0, sizeof(uuid16_list));
+ uuids_start = NULL;
/* Group all UUID16 types */
list_for_each_entry(uuid, &hdev->uuids, list) {
@@ -501,39 +500,24 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
if (uuid16 == PNP_INFO_SVCLASS_ID)
continue;
+ if (!uuids_start) {
+ uuids_start = ptr;
+ uuids_start[0] = 1;
+ uuids_start[1] = EIR_UUID16_ALL;
+ ptr += 2;
+ eir_len += 2;
+ }
+
/* Stop if not enough space to put next UUID */
if (eir_len + 2 + sizeof(u16) > HCI_MAX_EIR_LENGTH) {
- truncated = 1;
+ uuids_start[1] = EIR_UUID16_SOME;
break;
}
- /* Check for duplicates */
- for (i = 0; uuid16_list[i] != 0; i++)
- if (uuid16_list[i] == uuid16)
- break;
-
- if (uuid16_list[i] == 0) {
- uuid16_list[i] = uuid16;
- eir_len += sizeof(u16);
- }
- }
-
- if (uuid16_list[0] != 0) {
- u8 *length = ptr;
-
- /* EIR Data type */
- ptr[1] = truncated ? EIR_UUID16_SOME : EIR_UUID16_ALL;
-
- ptr += 2;
- eir_len += 2;
-
- for (i = 0; uuid16_list[i] != 0; i++) {
- *ptr++ = (uuid16_list[i] & 0x00ff);
- *ptr++ = (uuid16_list[i] & 0xff00) >> 8;
- }
-
- /* EIR Data length */
- *length = (i * sizeof(u16)) + 1;
+ *ptr++ = (uuid16 & 0x00ff);
+ *ptr++ = (uuid16 & 0xff00) >> 8;
+ eir_len += sizeof(uuid16);
+ uuids_start[0] += sizeof(uuid16);
}
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 4/9 v4] Bluetooth: Simplify UUID removal code
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The UUID removal code can be simplified by using
list_for_each_entry_safe instead of list_for_each_safe.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 8de6d57..1e906d8 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1372,7 +1372,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
{
struct mgmt_cp_remove_uuid *cp = data;
struct pending_cmd *cmd;
- struct list_head *p, *n;
+ struct bt_uuid *match, *tmp;
u8 bt_uuid_any[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int err, found;
@@ -1400,9 +1400,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
found = 0;
- list_for_each_safe(p, n, &hdev->uuids) {
- struct bt_uuid *match = list_entry(p, struct bt_uuid, list);
-
+ list_for_each_entry_safe(match, tmp, &hdev->uuids, list) {
if (memcmp(match->uuid, cp->uuid, 16) != 0)
continue;
--
1.7.10.4
^ permalink raw reply related
* [PATCH 3/9 v4] Bluetooth: Keep track of UUID type upon addition
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The primary purpose of the UUIDs is to enable generation of EIR and AD
data. In these data formats the UUIDs are split into separate fields
based on whether they're 16, 32 or 128 bit UUIDs. To make the generation
of these data fields simpler this patch adds a type member to the
bt_uuid struct and assigns a value to it as soon as the UUID is added to
the kernel. This way the type doesn't need to be calculated each time
the UUID list is later iterated.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/mgmt.c | 48 ++++++++++++++++++--------------------
2 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index bcf8ffe..90cf75a 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -86,6 +86,7 @@ struct bdaddr_list {
struct bt_uuid {
struct list_head list;
u8 uuid[16];
+ u8 size;
u8 svc_hint;
};
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4fd45a3..8de6d57 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -435,28 +435,6 @@ static u32 get_current_settings(struct hci_dev *hdev)
#define PNP_INFO_SVCLASS_ID 0x1200
-static u8 bluetooth_base_uuid[] = {
- 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
- 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-static u16 get_uuid16(u8 *uuid128)
-{
- u32 val;
- int i;
-
- for (i = 0; i < 12; i++) {
- if (bluetooth_base_uuid[i] != uuid128[i])
- return 0;
- }
-
- val = get_unaligned_le32(&uuid128[12]);
- if (val > 0xffff)
- return 0;
-
- return (u16) val;
-}
-
static void create_eir(struct hci_dev *hdev, u8 *data)
{
u8 *ptr = data;
@@ -513,10 +491,10 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
list_for_each_entry(uuid, &hdev->uuids, list) {
u16 uuid16;
- uuid16 = get_uuid16(uuid->uuid);
- if (uuid16 == 0)
- return;
+ if (uuid->size != 16)
+ continue;
+ uuid16 = get_unaligned_le16(&uuid->uuid[12]);
if (uuid16 < 0x1100)
continue;
@@ -1304,6 +1282,25 @@ unlock:
return err;
}
+static const u8 bluetooth_base_uuid[] = {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static u8 get_uuid_size(const u8 *uuid)
+{
+ u32 val;
+
+ if (memcmp(uuid, bluetooth_base_uuid, 12))
+ return 128;
+
+ val = get_unaligned_le32(&uuid[12]);
+ if (val > 0xffff)
+ return 32;
+
+ return 16;
+}
+
static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
{
struct mgmt_cp_add_uuid *cp = data;
@@ -1329,6 +1326,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
memcpy(uuid->uuid, cp->uuid, 16);
uuid->svc_hint = cp->svc_hint;
+ uuid->size = get_uuid_size(cp->uuid);
list_add_tail(&uuid->list, &hdev->uuids);
--
1.7.10.4
^ permalink raw reply related
* [PATCH 2/9 v4] Bluetooth: Simplify UUIDs clearing code
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
The code for clearing the UUIDs list can be simplified by using
list_for_each_entry_safe instead of list_for_each_safe.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/hci_core.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e061b35..618ca1a 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1183,14 +1183,10 @@ static void hci_discov_off(struct work_struct *work)
int hci_uuids_clear(struct hci_dev *hdev)
{
- struct list_head *p, *n;
-
- list_for_each_safe(p, n, &hdev->uuids) {
- struct bt_uuid *uuid;
+ struct bt_uuid *uuid, *tmp;
- uuid = list_entry(p, struct bt_uuid, list);
-
- list_del(p);
+ list_for_each_entry_safe(uuid, tmp, &hdev->uuids, list) {
+ list_del(&uuid->list);
kfree(uuid);
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/9 v4] Bluetooth: Store UUIDs in the same order that they were added
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1359239495-3444-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
We should be encoding UUIDs to the EIR data in the same order that they
were added to the kernel, i.e. each UUID should be added to the end of
the UUIDs list. This patch fixes the issue by using list_add_tail
instead of list_add for storing the UUIDs.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/mgmt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e7f944f..4fd45a3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1330,7 +1330,7 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
memcpy(uuid->uuid, cp->uuid, 16);
uuid->svc_hint = cp->svc_hint;
- list_add(&uuid->list, &hdev->uuids);
+ list_add_tail(&uuid->list, &hdev->uuids);
err = update_class(hdev);
if (err < 0)
--
1.7.10.4
^ permalink raw reply related
* [PATCH 0/9 v4] Bluetooth: Add 32 and 128 bit EIR UUID support
From: Johan Hedberg @ 2013-01-26 22:31 UTC (permalink / raw)
To: linux-bluetooth
Hi,
Hopefully the last revision of this set with change suggestions from
Marcel made to patch 3/9.
Johan
^ permalink raw reply
* Re: [PATCH 9/9 v3] Bluetooth: Add support for 128-bit UUIDs in EIR data
From: Marcel Holtmann @ 2013-01-26 17:15 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359194924-3151-10-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch adds the necessary code for encoding a list of 128-bit UUIDs
> into the EIR data.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 8/9 v3] Bluetooth: Add support for 32-bit UUIDs in EIR data
From: Marcel Holtmann @ 2013-01-26 17:14 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359194924-3151-9-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch adds the necessary code for inserting a list of 32-bit UUIDs
> into the EIR data.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 7/9 v3] Bluetooth: Refactor UUID-16 list generation into its own function
From: Marcel Holtmann @ 2013-01-26 17:13 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1359194924-3151-8-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> We will need to create three separate UUID lists in the EIR data (for
> 16, 32 and 128 bit UUIDs) so the code is easier to follow if each list
> is generated in their own function.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/mgmt.c | 78 ++++++++++++++++++++++++++++----------------------
> 1 file changed, 43 insertions(+), 35 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox