* [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
@ 2013-11-05 14:18 Szymon Janc
2013-11-05 14:18 ` [PATCH 2/5] android: Require at least 1.3 version of mgmt interface Szymon Janc
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This will be also used in Android daemon.
---
src/adapter.c | 1 -
src/shared/mgmt.h | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 30bcc4d..d904a56 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -99,7 +99,6 @@ static GSList *adapters = NULL;
static struct mgmt *mgmt_master = NULL;
-#define MGMT_VERSION(v, r) ((v << 16) + (r))
static uint8_t mgmt_version = 0;
static uint8_t mgmt_revision = 0;
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index 60a2128..99ea96f 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -24,6 +24,8 @@
#include <stdbool.h>
#include <stdint.h>
+#define MGMT_VERSION(v, r) ((v << 16) + (r))
+
typedef void (*mgmt_destroy_func_t)(void *user_data);
struct mgmt;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] android: Require at least 1.3 version of mgmt interface
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
@ 2013-11-05 14:18 ` Szymon Janc
2013-11-05 14:18 ` [PATCH 3/5] android: Remove mgmt_version and mgmt_revision static variables Szymon Janc
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Android daemon is not providing old kernels compatibility features.
---
android/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/main.c b/android/main.c
index 7d36976..7ee47fc 100644
--- a/android/main.c
+++ b/android/main.c
@@ -608,8 +608,8 @@ static void read_version_complete(uint8_t status, uint16_t length,
info("Bluetooth management interface %u.%u initialized",
mgmt_version, mgmt_revision);
- if (mgmt_version < 1) {
- error("Version 1.0 or later of management interface required");
+ if (MGMT_VERSION(mgmt_version, mgmt_revision) < MGMT_VERSION(1, 3)) {
+ error("Version 1.3 or later of management interface required");
return;
}
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] android: Remove mgmt_version and mgmt_revision static variables
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
2013-11-05 14:18 ` [PATCH 2/5] android: Require at least 1.3 version of mgmt interface Szymon Janc
@ 2013-11-05 14:18 ` Szymon Janc
2013-11-05 14:18 ` [PATCH 4/5] android: Stop mainloop if reading version failed Szymon Janc
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
There is no need to keep those as Android daemon is expecting new
enough kernel to operate.
---
android/main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/android/main.c b/android/main.c
index 7ee47fc..d68abe1 100644
--- a/android/main.c
+++ b/android/main.c
@@ -68,9 +68,6 @@
static GMainLoop *event_loop;
static struct mgmt *mgmt_if = NULL;
-static uint8_t mgmt_version = 0;
-static uint8_t mgmt_revision = 0;
-
static uint16_t adapter_index = MGMT_INDEX_NONE;
static guint adapter_timeout = 0;
@@ -588,6 +585,7 @@ static void read_version_complete(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
const struct mgmt_rp_read_version *rp = param;
+ uint8_t mgmt_version, mgmt_revision;
DBG("");
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] android: Stop mainloop if reading version failed
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
2013-11-05 14:18 ` [PATCH 2/5] android: Require at least 1.3 version of mgmt interface Szymon Janc
2013-11-05 14:18 ` [PATCH 3/5] android: Remove mgmt_version and mgmt_revision static variables Szymon Janc
@ 2013-11-05 14:18 ` Szymon Janc
2013-11-05 14:18 ` [PATCH 5/5] android: Stop mainloop if reading index list failed Szymon Janc
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
If reading mgmt version failed or kernel supported version is to old
mainloop should be stopped.
---
android/main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/android/main.c b/android/main.c
index d68abe1..4bb5101 100644
--- a/android/main.c
+++ b/android/main.c
@@ -592,12 +592,12 @@ static void read_version_complete(uint8_t status, uint16_t length,
if (status) {
error("Failed to read version information: %s (0x%02x)",
mgmt_errstr(status), status);
- return;
+ goto error;
}
if (length < sizeof(*rp)) {
error("Wrong size response");
- return;
+ goto error;
}
mgmt_version = rp->version;
@@ -608,7 +608,7 @@ static void read_version_complete(uint8_t status, uint16_t length,
if (MGMT_VERSION(mgmt_version, mgmt_revision) < MGMT_VERSION(1, 3)) {
error("Version 1.3 or later of management interface required");
- return;
+ goto error;
}
mgmt_send(mgmt_if, MGMT_OP_READ_COMMANDS, MGMT_INDEX_NONE, 0, NULL,
@@ -624,6 +624,9 @@ static void read_version_complete(uint8_t status, uint16_t length,
return;
error("Failed to read controller index list");
+
+error:
+ g_main_loop_quit(event_loop);
}
static bool init_mgmt_interface(void)
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] android: Stop mainloop if reading index list failed
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
` (2 preceding siblings ...)
2013-11-05 14:18 ` [PATCH 4/5] android: Stop mainloop if reading version failed Szymon Janc
@ 2013-11-05 14:18 ` Szymon Janc
2013-11-05 16:57 ` [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Marcel Holtmann
2013-11-05 18:22 ` [PATCH v2 " Szymon Janc
5 siblings, 0 replies; 8+ messages in thread
From: Szymon Janc @ 2013-11-05 14:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
If reading index list failed mainloop should be stopped since adapter
init guard timer is not yet running.
---
android/main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/android/main.c b/android/main.c
index 4bb5101..72e47f2 100644
--- a/android/main.c
+++ b/android/main.c
@@ -528,12 +528,12 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
if (status) {
error("%s: Failed to read index list: %s (0x%02x)",
__func__, mgmt_errstr(status), status);
- return;
+ goto error;
}
if (length < sizeof(*rp)) {
error("%s: Wrong size of read index list response", __func__);
- return;
+ goto error;
}
num = btohs(rp->num_controllers);
@@ -542,7 +542,7 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
if (num * sizeof(uint16_t) + sizeof(*rp) != length) {
error("%s: Incorrect pkt size for index list rsp", __func__);
- return;
+ goto error;
}
if (adapter_index != MGMT_INDEX_NONE)
@@ -553,13 +553,17 @@ static void read_index_list_complete(uint8_t status, uint16_t length,
adapter_timeout_handler, NULL);
if (adapter_timeout == 0) {
error("%s: Failed init timeout", __func__);
- g_main_loop_quit(event_loop);
+ goto error;
}
return;
}
adapter_index = btohs(rp->index[0]);
bt_adapter_init(adapter_index, mgmt_if, adapter_ready);
+ return;
+
+error:
+ g_main_loop_quit(event_loop);
}
static void read_commands_complete(uint8_t status, uint16_t length,
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
` (3 preceding siblings ...)
2013-11-05 14:18 ` [PATCH 5/5] android: Stop mainloop if reading index list failed Szymon Janc
@ 2013-11-05 16:57 ` Marcel Holtmann
2013-11-05 18:22 ` [PATCH v2 " Szymon Janc
5 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2013-11-05 16:57 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org development
Hi Szymon,
> This will be also used in Android daemon.
> ---
> src/adapter.c | 1 -
> src/shared/mgmt.h | 2 ++
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 30bcc4d..d904a56 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -99,7 +99,6 @@ static GSList *adapters = NULL;
>
> static struct mgmt *mgmt_master = NULL;
>
> -#define MGMT_VERSION(v, r) ((v << 16) + (r))
> static uint8_t mgmt_version = 0;
> static uint8_t mgmt_revision = 0;
>
> diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
> index 60a2128..99ea96f 100644
> --- a/src/shared/mgmt.h
> +++ b/src/shared/mgmt.h
> @@ -24,6 +24,8 @@
> #include <stdbool.h>
> #include <stdint.h>
>
> +#define MGMT_VERSION(v, r) ((v << 16) + (r))
you also need (v) here.
Regards
Marcel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
` (4 preceding siblings ...)
2013-11-05 16:57 ` [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Marcel Holtmann
@ 2013-11-05 18:22 ` Szymon Janc
2013-11-06 8:13 ` Johan Hedberg
5 siblings, 1 reply; 8+ messages in thread
From: Szymon Janc @ 2013-11-05 18:22 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This will be also used in Android daemon.
---
v2: fixed missing brackets around 'v' as suggested by Marcel
src/adapter.c | 1 -
src/shared/mgmt.h | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 30bcc4d..d904a56 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -99,7 +99,6 @@ static GSList *adapters = NULL;
static struct mgmt *mgmt_master = NULL;
-#define MGMT_VERSION(v, r) ((v << 16) + (r))
static uint8_t mgmt_version = 0;
static uint8_t mgmt_revision = 0;
diff --git a/src/shared/mgmt.h b/src/shared/mgmt.h
index 60a2128..e23cc7d 100644
--- a/src/shared/mgmt.h
+++ b/src/shared/mgmt.h
@@ -24,6 +24,8 @@
#include <stdbool.h>
#include <stdint.h>
+#define MGMT_VERSION(v, r) (((v) << 16) + (r))
+
typedef void (*mgmt_destroy_func_t)(void *user_data);
struct mgmt;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/5] adapter: Move MGMT_VERSION macro to mgmt.h
2013-11-05 18:22 ` [PATCH v2 " Szymon Janc
@ 2013-11-06 8:13 ` Johan Hedberg
0 siblings, 0 replies; 8+ messages in thread
From: Johan Hedberg @ 2013-11-06 8:13 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
Hi Szymon,
On Tue, Nov 05, 2013, Szymon Janc wrote:
> This will be also used in Android daemon.
> ---
>
> v2: fixed missing brackets around 'v' as suggested by Marcel
>
> src/adapter.c | 1 -
> src/shared/mgmt.h | 2 ++
> 2 files changed, 2 insertions(+), 1 deletion(-)
All five patches have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-11-06 8:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-05 14:18 [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Szymon Janc
2013-11-05 14:18 ` [PATCH 2/5] android: Require at least 1.3 version of mgmt interface Szymon Janc
2013-11-05 14:18 ` [PATCH 3/5] android: Remove mgmt_version and mgmt_revision static variables Szymon Janc
2013-11-05 14:18 ` [PATCH 4/5] android: Stop mainloop if reading version failed Szymon Janc
2013-11-05 14:18 ` [PATCH 5/5] android: Stop mainloop if reading index list failed Szymon Janc
2013-11-05 16:57 ` [PATCH 1/5] adapter: Move MGMT_VERSION macro to mgmt.h Marcel Holtmann
2013-11-05 18:22 ` [PATCH v2 " Szymon Janc
2013-11-06 8:13 ` Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.