* [PATCH bluetooth-next] Bluetooth: Add support for BCM20702A0 [0a5c, 21e6]
From: Dan Aloni @ 2013-09-03 11:42 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-bluetooth, linux-kernel, Gustavo Padovan, Johan Hedberg
Tested with this patch and a Bluetooth mouse on 3.10.10, on ThinkPad W530.
Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 [ThinkPad]
T: Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0a5c ProdID=21e6 Rev=01.12
S: Manufacturer=Broadcom Corp
S: Product=BCM20702A0
S: SerialNumber=F4B7E2F6E438
C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=btusb
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
Signed-off-by: Dan Aloni <alonid@postram.com>
---
drivers/bluetooth/btusb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index de4cf4d..e6313f8 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -104,6 +104,7 @@ static struct usb_device_id btusb_table[] = {
{ USB_DEVICE(0x0b05, 0x17b5) },
{ USB_DEVICE(0x04ca, 0x2003) },
{ USB_DEVICE(0x0489, 0xe042) },
+ { USB_DEVICE(0x0a5c, 0x21e6) },
{ USB_DEVICE(0x413c, 0x8197) },
/* Foxconn - Hon Hai */
--
1.8.1.4
^ permalink raw reply related
* [PATCH BlueZ 10/10 v3] obexd: Make use of g_dbus_send_message*
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replaces dbus_connection_send* with g_dbus_send_message* which do
not alter message order.
---
obexd/plugins/bluetooth.c | 2 +-
obexd/plugins/pcsuite.c | 5 ++---
obexd/plugins/syncevolution.c | 6 +++---
obexd/src/manager.c | 3 +--
4 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index e4d518e..10f5e4f 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -317,7 +317,7 @@ static int register_profile(struct bluetooth_profile *profile)
}
dbus_message_iter_close_container(&iter, &opt);
- if (!dbus_connection_send_with_reply(connection, msg, &call, -1)) {
+ if (!g_dbus_send_message_with_reply(connection, msg, &call, -1)) {
ret = -1;
unregister_profile(profile);
goto failed;
diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
index 4ce2fe4..6460aa9 100644
--- a/obexd/plugins/pcsuite.c
+++ b/obexd/plugins/pcsuite.c
@@ -351,7 +351,7 @@ static gboolean send_backup_dbus_message(const char *oper,
DBUS_TYPE_INVALID);
if (strcmp(oper, "open") == 0) {
- ret = dbus_connection_send_with_reply(conn, msg, &pending_call,
+ ret = g_dbus_send_message_with_reply(conn, msg, &pending_call,
BACKUP_DBUS_TIMEOUT);
dbus_message_unref(msg);
if (ret) {
@@ -363,8 +363,7 @@ static gboolean send_backup_dbus_message(const char *oper,
} else
dbus_connection_unref(conn);
} else {
- ret = dbus_connection_send(conn, msg, NULL);
- dbus_message_unref(msg);
+ g_dbus_send_message(conn, msg);
dbus_connection_unref(conn);
}
diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c
index 2d25d28..edc00c8 100644
--- a/obexd/plugins/syncevolution.c
+++ b/obexd/plugins/syncevolution.c
@@ -314,7 +314,7 @@ static int synce_close(void *object)
dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &normal,
DBUS_TYPE_STRING, &error, DBUS_TYPE_INVALID);
- dbus_connection_send_with_reply(context->dbus_conn, msg, &call, -1);
+ g_dbus_send_message_with_reply(context->dbus_conn, msg, &call, -1);
dbus_pending_call_set_notify(call, close_cb, NULL, NULL);
dbus_message_unref(msg);
dbus_pending_call_unref(call);
@@ -380,7 +380,7 @@ static ssize_t synce_read(void *object, void *buf, size_t count)
dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &authenticate,
DBUS_TYPE_STRING, &session, DBUS_TYPE_INVALID);
- if (!dbus_connection_send_with_reply(conn, msg, &call, -1)) {
+ if (!g_dbus_send_message_with_reply(conn, msg, &call, -1)) {
error("D-Bus call to %s failed.", SYNCE_SERVER_INTERFACE);
dbus_message_unref(msg);
return -EPERM;
@@ -424,7 +424,7 @@ static ssize_t synce_write(void *object, const void *buf, size_t count)
dbus_message_append_args(msg, DBUS_TYPE_STRING, &type,
DBUS_TYPE_INVALID);
- if (!dbus_connection_send_with_reply(context->dbus_conn, msg,
+ if (!g_dbus_send_message_with_reply(context->dbus_conn, msg,
&call, -1)) {
error("D-Bus call to %s failed.", SYNCE_CONN_INTERFACE);
dbus_message_unref(msg);
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index dbfbef8..f64b7b9 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -776,8 +776,7 @@ int manager_request_authorization(struct obex_transfer *transfer, int32_t time,
dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &transfer->path,
DBUS_TYPE_INVALID);
- if (!dbus_connection_send_with_reply(connection,
- msg, &call, TIMEOUT)) {
+ if (!g_dbus_send_message_with_reply(connection, msg, &call, TIMEOUT)) {
dbus_message_unref(msg);
return -EPERM;
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 09/10 v3] audio/media: Make use of g_dbus_send_message_with_reply
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replaces dbus_connection_send_with_reply with
g_dbus_send_message_with_reply which does not alter message order.
---
profiles/audio/media.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 5a06b99..9c72b8d 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -325,7 +325,7 @@ static gboolean media_endpoint_async_call(DBusMessage *msg,
request = g_new0(struct endpoint_request, 1);
/* Timeout should be less than avdtp request timeout (4 seconds) */
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(),
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(),
msg, &request->call,
REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 08/10 v3] neard: Make use of g_dbus_send_message_with_reply
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replaces dbus_connection_send_with_reply with
g_dbus_send_message_with_reply which does not alter message order.
---
plugins/neard.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index e4a4d71..ea91c4d 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -158,7 +158,7 @@ static void register_agent(bool append_carrier)
dbus_message_append_args(message, DBUS_TYPE_STRING, &carrier,
DBUS_TYPE_INVALID);
- if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
+ if (!g_dbus_send_message_with_reply(btd_get_dbus_connection(),
message, &call, -1)) {
dbus_message_unref(message);
error("D-Bus send failed");
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 07/10 v3] core: Make use of g_dbus_send_message_with_reply
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This replaces dbus_connection_send_with_reply with
g_dbus_send_message_with_reply which does not alter message order.
---
src/agent.c | 12 ++++++------
src/profile.c | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/agent.c b/src/agent.c
index b9e6e8c..7880ba6 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -370,7 +370,7 @@ static int agent_call_authorize_service(struct agent_request *req,
DBUS_TYPE_STRING, &uuid,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(),
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(),
req->msg, &req->call,
REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
@@ -480,7 +480,7 @@ static int pincode_request_new(struct agent_request *req, const char *device_pat
dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
@@ -574,7 +574,7 @@ static int passkey_request_new(struct agent_request *req,
dbus_message_append_args(req->msg, DBUS_TYPE_OBJECT_PATH, &device_path,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
@@ -632,7 +632,7 @@ static int confirmation_request_new(struct agent_request *req,
DBUS_TYPE_UINT32, &passkey,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
@@ -689,7 +689,7 @@ static int authorization_request_new(struct agent_request *req,
DBUS_TYPE_OBJECT_PATH, &device_path,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
@@ -823,7 +823,7 @@ static int display_pincode_request_new(struct agent_request *req,
DBUS_TYPE_STRING, &pincode,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(btd_get_dbus_connection(), req->msg,
+ if (g_dbus_send_message_with_reply(btd_get_dbus_connection(), req->msg,
&req->call, REQUEST_TIMEOUT) == FALSE) {
error("D-Bus send failed");
return -EIO;
diff --git a/src/profile.c b/src/profile.c
index 90c3535..57aead7 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -938,7 +938,7 @@ static bool send_new_connection(struct ext_profile *ext, struct ext_io *conn)
dbus_message_iter_close_container(&iter, &dict);
- if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
+ if (!g_dbus_send_message_with_reply(btd_get_dbus_connection(),
msg, &conn->pending, -1)) {
error("%s: sending NewConnection failed", ext->name);
dbus_message_unref(msg);
@@ -1682,7 +1682,7 @@ static int send_disconn_req(struct ext_profile *ext, struct ext_io *conn)
dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
- if (!dbus_connection_send_with_reply(btd_get_dbus_connection(),
+ if (!g_dbus_send_message_with_reply(btd_get_dbus_connection(),
msg, &conn->pending, -1)) {
error("%s: sending RequestDisconnection failed", ext->name);
dbus_message_unref(msg);
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 06/10 v3] gdbus: Fix emitting PropertiesChanged twice
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fixes double emission of PropertiesChanged introduced by flushing
changes, the flushing can happen during the pending processing so the
pending_prop flag needs to be updated in the beginning and the list of
properties can be freed before g_dbus_send_message as it is not required
anymore.
---
gdbus/object.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index c4cf724..0822fe8 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1642,6 +1642,8 @@ static void process_properties_from_interface(struct generic_data *data,
DBusMessageIter iter, dict, array;
GSList *invalidated;
+ data->pending_prop = FALSE;
+
if (iface->pending_prop == NULL)
return;
@@ -1708,8 +1710,6 @@ static void process_property_changes(struct generic_data *data)
process_properties_from_interface(data, iface);
}
-
- data->pending_prop = FALSE;
}
void g_dbus_emit_property_changed(DBusConnection *connection,
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 05/10 v3] gdbus: Avoid calling dbus_connection_send*
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
dbus_connection_send* should not be called directly except by
g_dbus_send_message.
---
gdbus/client.c | 14 ++++-----
gdbus/object.c | 92 ++++++++++++++++++++++------------------------------------
2 files changed, 42 insertions(+), 64 deletions(-)
diff --git a/gdbus/client.c b/gdbus/client.c
index d80e252..8ebfaad 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -100,7 +100,7 @@ static gboolean modify_match(DBusConnection *conn, const char *member,
dbus_message_append_args(msg, DBUS_TYPE_STRING, &rule,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(conn, msg, &call, -1) == FALSE) {
+ if (g_dbus_send_message_with_reply(conn, msg, &call, -1) == FALSE) {
dbus_message_unref(msg);
return FALSE;
}
@@ -319,7 +319,7 @@ static void get_all_properties(GDBusProxy *proxy)
dbus_message_append_args(msg, DBUS_TYPE_STRING, &proxy->interface,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+ if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
&call, -1) == FALSE) {
dbus_message_unref(msg);
return;
@@ -575,7 +575,7 @@ gboolean g_dbus_proxy_refresh_property(GDBusProxy *proxy, const char *name)
&proxy->interface);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &name);
- if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+ if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
&call, -1) == FALSE) {
dbus_message_unref(msg);
refresh_property_free(data);
@@ -668,7 +668,7 @@ gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy,
dbus_message_iter_append_basic(&variant, type, value);
dbus_message_iter_close_container(&iter, &variant);
- if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+ if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
&call, -1) == FALSE) {
dbus_message_unref(msg);
g_free(data);
@@ -742,7 +742,7 @@ gboolean g_dbus_proxy_method_call(GDBusProxy *proxy, const char *method,
setup(&iter, data->user_data);
}
- if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+ if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
&call, METHOD_CALL_TIMEOUT) == FALSE) {
dbus_message_unref(msg);
g_free(data);
@@ -1038,7 +1038,7 @@ static void get_managed_objects(GDBusClient *client)
dbus_message_append_args(msg, DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+ if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
&client->get_objects_call, -1) == FALSE) {
dbus_message_unref(msg);
return;
@@ -1102,7 +1102,7 @@ static void get_name_owner(GDBusClient *client, const char *name)
dbus_message_append_args(msg, DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID);
- if (dbus_connection_send_with_reply(client->dbus_conn, msg,
+ if (g_dbus_send_message_with_reply(client->dbus_conn, msg,
&client->pending_call, -1) == FALSE) {
dbus_message_unref(msg);
return;
diff --git a/gdbus/object.c b/gdbus/object.c
index 773128c..c4cf724 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -272,8 +272,7 @@ static DBusHandlerResult process_message(DBusConnection *connection,
if (reply == NULL)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- dbus_connection_send(connection, reply, NULL);
- dbus_message_unref(reply);
+ g_dbus_send_message(connection, reply);
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -313,19 +312,14 @@ void g_dbus_pending_error_valist(DBusConnection *connection,
for (list = pending_security; list; list = list->next) {
struct security_data *secdata = list->data;
- DBusMessage *reply;
if (secdata->pending != pending)
continue;
pending_security = g_slist_remove(pending_security, secdata);
- reply = g_dbus_create_error_valist(secdata->message,
+ g_dbus_send_error_valist(connection, secdata->message,
name, format, args);
- if (reply != NULL) {
- dbus_connection_send(connection, reply, NULL);
- dbus_message_unref(reply);
- }
dbus_message_unref(secdata->message);
g_free(secdata);
@@ -470,18 +464,13 @@ void g_dbus_pending_property_error_valist(GDBusPendingReply id,
va_list args)
{
struct property_data *propdata;
- DBusMessage *reply;
propdata = remove_pending_property_data(id);
if (propdata == NULL)
return;
- reply = g_dbus_create_error_valist(propdata->message, name, format,
- args);
- if (reply != NULL) {
- dbus_connection_send(propdata->conn, reply, NULL);
- dbus_message_unref(reply);
- }
+ g_dbus_send_error_valist(propdata->conn, propdata->message, name,
+ format, args);
dbus_message_unref(propdata->message);
g_free(propdata);
@@ -1339,45 +1328,6 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
return FALSE;
}
-static dbus_bool_t emit_signal_valist(DBusConnection *conn,
- const char *path,
- const char *interface,
- const char *name,
- int first,
- va_list var_args)
-{
- DBusMessage *signal;
- dbus_bool_t ret;
- const GDBusArgInfo *args;
-
- if (!check_signal(conn, path, interface, name, &args))
- return FALSE;
-
- signal = dbus_message_new_signal(path, interface, name);
- if (signal == NULL) {
- error("Unable to allocate new %s.%s signal", interface, name);
- return FALSE;
- }
-
- ret = dbus_message_append_args_valist(signal, first, var_args);
- if (!ret)
- goto fail;
-
- if (g_dbus_args_have_signature(args, signal) == FALSE) {
- error("%s.%s: got unexpected signature '%s'", interface, name,
- dbus_message_get_signature(signal));
- ret = FALSE;
- goto fail;
- }
-
- ret = dbus_connection_send(conn, signal, NULL);
-
-fail:
- dbus_message_unref(signal);
-
- return ret;
-}
-
gboolean g_dbus_register_interface(DBusConnection *connection,
const char *path, const char *name,
const GDBusMethodTable *methods,
@@ -1640,7 +1590,7 @@ gboolean g_dbus_emit_signal(DBusConnection *connection,
va_start(args, type);
- result = emit_signal_valist(connection, path, interface,
+ result = g_dbus_emit_signal_valist(connection, path, interface,
name, type, args);
va_end(args);
@@ -1652,8 +1602,36 @@ gboolean g_dbus_emit_signal_valist(DBusConnection *connection,
const char *path, const char *interface,
const char *name, int type, va_list args)
{
- return emit_signal_valist(connection, path, interface,
- name, type, args);
+ DBusMessage *signal;
+ dbus_bool_t ret;
+ const GDBusArgInfo *args_info;
+
+ if (!check_signal(connection, path, interface, name, &args_info))
+ return FALSE;
+
+ signal = dbus_message_new_signal(path, interface, name);
+ if (signal == NULL) {
+ error("Unable to allocate new %s.%s signal", interface, name);
+ return FALSE;
+ }
+
+ ret = dbus_message_append_args_valist(signal, type, args);
+ if (!ret)
+ goto fail;
+
+ if (g_dbus_args_have_signature(args_info, signal) == FALSE) {
+ error("%s.%s: got unexpected signature '%s'", interface, name,
+ dbus_message_get_signature(signal));
+ ret = FALSE;
+ goto fail;
+ }
+
+ return g_dbus_send_message(connection, signal);
+
+fail:
+ dbus_message_unref(signal);
+
+ return ret;
}
static void process_properties_from_interface(struct generic_data *data,
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 04/10 v3] gdbus: Add g_dbus_send_message_with_reply
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
g_dbus_send_message_with_reply flushes pending signals before calling
dbus_connection_send_with_reply so it does not alter the message order
---
gdbus/gdbus.h | 3 +++
gdbus/object.c | 11 +++++++++++
2 files changed, 14 insertions(+)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 8b13393..9542109 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -250,6 +250,9 @@ DBusMessage *g_dbus_create_reply_valist(DBusMessage *message,
int type, va_list args);
gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message);
+gboolean g_dbus_send_message_with_reply(DBusConnection *connection,
+ DBusMessage *message,
+ DBusPendingCall **call, int timeout);
gboolean g_dbus_send_error(DBusConnection *connection, DBusMessage *message,
const char *name, const char *format, ...)
__attribute__((format(printf, 4, 5)));
diff --git a/gdbus/object.c b/gdbus/object.c
index 83fc4e6..773128c 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1556,6 +1556,17 @@ out:
return result;
}
+gboolean g_dbus_send_message_with_reply(DBusConnection *connection,
+ DBusMessage *message,
+ DBusPendingCall **call, int timeout)
+{
+ /* Flush pending signal to guarantee message order */
+ g_dbus_flush(connection);
+
+ return dbus_connection_send_with_reply(connection, message, call,
+ timeout);
+}
+
gboolean g_dbus_send_error_valist(DBusConnection *connection,
DBusMessage *message, const char *name,
const char *format, va_list args)
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 03/10 v3] gdbus: Fix sending ObjectManager/Properties signals out of order
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In some cases the order of the messages is altered when a message is
sent without processing the pending signals first, currently this affect
client_check_order unit test:
/gdbus/client_check_order: **
ERROR:unit/test-gdbus-client.c:795:property_check_order: assertion failed: (g_strcmp0(string, "value1") == 0)
As can be observed the value of the property is not yet updated because the
signal it is still pending, once this fix is applied the test pass:
/gdbus/client_check_order: OK
Note that the flushing only works when g_dbus_send_message is used so
places where dbus_connection_send and other variants are called directly
may still change the order.
---
gdbus/object.c | 69 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 53 insertions(+), 16 deletions(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index 2f8ef45..83fc4e6 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -86,6 +86,7 @@ struct property_data {
static int global_flags = 0;
static struct generic_data *root;
+static GSList *pending = NULL;
static gboolean process_changes(gpointer user_data);
static void process_properties_from_interface(struct generic_data *data,
@@ -599,7 +600,9 @@ static void emit_interfaces_added(struct generic_data *data)
dbus_message_iter_close_container(&iter, &array);
- g_dbus_send_message(data->conn, signal);
+ /* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */
+ dbus_connection_send(data->conn, signal, NULL);
+ dbus_message_unref(signal);
}
static struct interface_data *find_interface(GSList *interfaces,
@@ -640,6 +643,16 @@ static gboolean g_dbus_args_have_signature(const GDBusArgInfo *args,
return TRUE;
}
+static void add_pending(struct generic_data *data)
+{
+ if (data->process_id > 0)
+ return;
+
+ data->process_id = g_idle_add(process_changes, data);
+
+ pending = g_slist_append(pending, data);
+}
+
static gboolean remove_interface(struct generic_data *data, const char *name)
{
struct interface_data *iface;
@@ -677,10 +690,7 @@ static gboolean remove_interface(struct generic_data *data, const char *name)
data->removed = g_slist_prepend(data->removed, iface->name);
g_free(iface);
- if (data->process_id > 0)
- return TRUE;
-
- data->process_id = g_idle_add(process_changes, data);
+ add_pending(data);
return TRUE;
}
@@ -976,14 +986,26 @@ static void emit_interfaces_removed(struct generic_data *data)
dbus_message_iter_close_container(&iter, &array);
- g_dbus_send_message(data->conn, signal);
+ /* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */
+ dbus_connection_send(data->conn, signal, NULL);
+ dbus_message_unref(signal);
+}
+
+static void remove_pending(struct generic_data *data)
+{
+ if (data->process_id > 0) {
+ g_source_remove(data->process_id);
+ data->process_id = 0;
+ }
+
+ pending = g_slist_remove(pending, data);
}
static gboolean process_changes(gpointer user_data)
{
struct generic_data *data = user_data;
- data->process_id = 0;
+ remove_pending(data);
if (data->added != NULL)
emit_interfaces_added(data);
@@ -1211,10 +1233,8 @@ done:
return TRUE;
data->added = g_slist_append(data->added, iface);
- if (data->process_id > 0)
- return TRUE;
- data->process_id = g_idle_add(process_changes, data);
+ add_pending(data);
return TRUE;
}
@@ -1494,6 +1514,21 @@ DBusMessage *g_dbus_create_reply(DBusMessage *message, int type, ...)
return reply;
}
+static void g_dbus_flush(DBusConnection *connection)
+{
+ GSList *l;
+
+ for (l = pending; l;) {
+ struct generic_data *data = l->data;
+
+ l = l->next;
+ if (data->conn != connection)
+ continue;
+
+ process_changes(data);
+ }
+}
+
gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
{
dbus_bool_t result = FALSE;
@@ -1510,6 +1545,9 @@ gboolean g_dbus_send_message(DBusConnection *connection, DBusMessage *message)
goto out;
}
+ /* Flush pending signal to guarantee message order */
+ g_dbus_flush(connection);
+
result = dbus_connection_send(connection, message, NULL);
out:
@@ -1664,10 +1702,12 @@ static void process_properties_from_interface(struct generic_data *data,
g_slist_free(invalidated);
dbus_message_iter_close_container(&iter, &array);
- g_dbus_send_message(data->conn, signal);
-
g_slist_free(iface->pending_prop);
iface->pending_prop = NULL;
+
+ /* Use dbus_connection_send to avoid recursive calls to g_dbus_flush */
+ dbus_connection_send(data->conn, signal, NULL);
+ dbus_message_unref(signal);
}
static void process_property_changes(struct generic_data *data)
@@ -1723,10 +1763,7 @@ void g_dbus_emit_property_changed(DBusConnection *connection,
iface->pending_prop = g_slist_prepend(iface->pending_prop,
(void *) property);
- if (!data->process_id) {
- data->process_id = g_idle_add(process_changes, data);
- return;
- }
+ add_pending(data);
}
gboolean g_dbus_get_properties(DBusConnection *connection, const char *path,
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 02/10 v3] unit: Add gdbus/client_check_order
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
unit/test-gdbus-client.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/unit/test-gdbus-client.c b/unit/test-gdbus-client.c
index a594384..488d4ec 100644
--- a/unit/test-gdbus-client.c
+++ b/unit/test-gdbus-client.c
@@ -35,6 +35,7 @@ struct context {
GMainLoop *main_loop;
DBusConnection *dbus_conn;
GDBusClient *dbus_client;
+ GDBusProxy *proxy;
void *data;
guint timeout_source;
};
@@ -779,6 +780,74 @@ static void client_string_changed(void)
destroy_context(context);
}
+static void property_check_order(const DBusError *err, void *user_data)
+{
+ struct context *context = user_data;
+ GDBusProxy *proxy = context->proxy;
+ DBusMessageIter iter;
+ const char *string;
+
+ g_assert(!dbus_error_is_set(err));
+
+ g_assert(g_dbus_proxy_get_property(proxy, "String", &iter));
+
+ dbus_message_iter_get_basic(&iter, &string);
+ g_assert(g_strcmp0(string, "value1") == 0);
+
+ g_dbus_client_unref(context->dbus_client);
+}
+
+static void proxy_check_order(GDBusProxy *proxy, void *user_data)
+{
+ struct context *context = user_data;
+ const char *string;
+
+ if (g_test_verbose())
+ g_print("proxy %s found\n",
+ g_dbus_proxy_get_interface(proxy));
+
+ context->proxy = proxy;
+ string = "value1";
+ g_assert(g_dbus_proxy_set_property_basic(proxy, "String",
+ DBUS_TYPE_STRING, &string,
+ property_check_order, context,
+ NULL));
+}
+
+static void client_check_order(void)
+{
+ struct context *context = create_context();
+ static const GDBusPropertyTable string_properties[] = {
+ { "String", "s", get_string, set_string, string_exists },
+ { },
+ };
+
+ if (context == NULL)
+ return;
+
+ context->data = g_strdup("value");
+ g_dbus_register_interface(context->dbus_conn,
+ SERVICE_PATH, SERVICE_NAME,
+ methods, signals, string_properties,
+ context, NULL);
+
+ context->dbus_client = g_dbus_client_new(context->dbus_conn,
+ SERVICE_NAME, SERVICE_PATH);
+
+ g_dbus_client_set_disconnect_watch(context->dbus_client,
+ disconnect_handler, context);
+ g_dbus_client_set_proxy_handlers(context->dbus_client,
+ proxy_check_order, NULL, NULL,
+ context);
+
+ g_main_loop_run(context->main_loop);
+
+ g_dbus_unregister_interface(context->dbus_conn,
+ SERVICE_PATH, SERVICE_NAME);
+
+ destroy_context(context);
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
@@ -809,5 +878,7 @@ int main(int argc, char *argv[])
g_test_add_func("/gdbus/client_string_changed",
client_string_changed);
+ g_test_add_func("/gdbus/client_check_order", client_check_order);
+
return g_test_run();
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 01/10 v3] build: Fix not rebuilding bluetoothd if gdbus changes
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1378207279-14557-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
src_bluetoothd_DEPENDENCIES should list all local libraries including gdbus
otherwise it does not get relinked whenever gdbus changes.
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 61daec4..4e4b1c5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -157,7 +157,7 @@ src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
-Wl,--version-script=$(srcdir)/src/bluetooth.ver
src_bluetoothd_DEPENDENCIES = lib/libbluetooth-internal.la \
- src/bluetooth.service
+ gdbus/libgdbus-internal.la src/bluetooth.service
src_bluetoothd_CFLAGS = $(AM_CFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
-DPLUGINDIR=\""$(build_plugindir)"\"
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ 00/10 v3] Fix message order
From: Luiz Augusto von Dentz @ 2013-09-03 11:21 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
s set fixes a couple of issues introduced with the use of ObjectManager due
the processing of signals on idle to group changes, this has been causing
issues with external components such as ofono and pulseaudio that sometimes
receives connections from devices objects that have pending signals thus
cannot be properly processed or have to be assumed paired and with certain
UUIDs which is not ideal.
v2: Fixes some commit messages as suggested by Lucas Demarchi, in addition to
that rework flush mechanism to honor the order of the pending signals and make
it work with any connection.
v3: Add comments regarding the use of dbus_connection_send to prevent recursive
calls to g_dbus_flush.
Luiz Augusto von Dentz (10):
build: Fix not rebuilding bluetoothd if gdbus changes
unit: Add gdbus/client_check_order
gdbus: Fix sending ObjectManager/Properties signals out of order
gdbus: Add g_dbus_send_message_with_reply
gdbus: Avoid calling dbus_connection_send*
gdbus: Fix emitting PropertiesChanged twice
core: Make use of g_dbus_send_message_with_reply
neard: Make use of g_dbus_send_message_with_reply
audio/media: Make use of g_dbus_send_message_with_reply
obexd: Make use of g_dbus_send_message*
Makefile.am | 2 +-
gdbus/client.c | 14 ++--
gdbus/gdbus.h | 3 +
gdbus/object.c | 176 ++++++++++++++++++++++++------------------
obexd/plugins/bluetooth.c | 2 +-
obexd/plugins/pcsuite.c | 5 +-
obexd/plugins/syncevolution.c | 6 +-
obexd/src/manager.c | 3 +-
plugins/neard.c | 2 +-
profiles/audio/media.c | 2 +-
src/agent.c | 12 +--
src/profile.c | 4 +-
unit/test-gdbus-client.c | 71 +++++++++++++++++
13 files changed, 200 insertions(+), 102 deletions(-)
--
1.8.3.1
^ permalink raw reply
* Re: Compatible Kernels of a certain BlueZ version
From: wei junping @ 2013-09-03 3:14 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Marcel Holtmann, Gustavo Padovan, linux-bluetooth@vger.kernel.org
In-Reply-To: <CABBYNZ+L4h4Gt+pC3A3wJRgsyMkeKjbh-=SnXAKtVBeen-4VzQ@mail.gmail.com>
Hi Luiz,
2013/9/3 Luiz Augusto von Dentz <luiz.dentz@gmail.com>:
> Hi wei,
>
> On Mon, Sep 2, 2013 at 10:59 AM, wei junping <junping.wei@gmail.com> wrote:
>> Hi Marcel,
>>
>> Thank you for your reply.
>>
>> But what do you mean by "refrain from top posting on this mailing
>> list"? Do you mean I should not have posted this question here? If so,
>> where should new comers of BlueZ ask for help?
>
> He was referring to post style: http://en.wikipedia.org/wiki/Posting_style
>
> Please use inline/interleaved like Im doing right now.
Thank you for your reply. So it should be like this?
Best Regards,
Tim Wei
^ permalink raw reply
* Re: Compatible Kernels of a certain BlueZ version
From: Luiz Augusto von Dentz @ 2013-09-02 20:27 UTC (permalink / raw)
To: wei junping
Cc: Marcel Holtmann, Gustavo Padovan, linux-bluetooth@vger.kernel.org
In-Reply-To: <CAKCXgJ1xYtfQqus+jxkgJpvPm7qqE=usWNVcNB=NqkoOXgDKhQ@mail.gmail.com>
Hi wei,
On Mon, Sep 2, 2013 at 10:59 AM, wei junping <junping.wei@gmail.com> wrote:
> Hi Marcel,
>
> Thank you for your reply.
>
> But what do you mean by "refrain from top posting on this mailing
> list"? Do you mean I should not have posted this question here? If so,
> where should new comers of BlueZ ask for help?
He was referring to post style: http://en.wikipedia.org/wiki/Posting_style
Please use inline/interleaved like Im doing right now.
^ permalink raw reply
* [PATCH] Bluetooth: Add support creating virtual AMP controllers
From: Marcel Holtmann @ 2013-09-02 17:41 UTC (permalink / raw)
To: linux-bluetooth
So far the only option to create a virtual AMP controller was by
setting a module parameter for the hci_vhci driver. This patch adds
the functionality to define inline to create either a BR/EDR or an
AMP controller.
In addition the client will be informed which HCI controller index
it got assigned. That is especially useful for automated end-to-end
testing.
To keep backwards compatibility with existing userspace, the command
for creating a controller type needs to be send right after opening
the device node. If the command is not send, it defaults back to
automatically creating a BR/EDR controller.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
drivers/bluetooth/hci_vhci.c | 169 +++++++++++++++++++++++++++++++------------
1 file changed, 123 insertions(+), 46 deletions(-)
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index a1ea5b1..c04a3e6 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -24,6 +24,7 @@
*/
#include <linux/module.h>
+#include <asm/unaligned.h>
#include <linux/kernel.h>
#include <linux/init.h>
@@ -39,17 +40,17 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
-#define VERSION "1.3"
+#define VERSION "1.4"
static bool amp;
struct vhci_data {
struct hci_dev *hdev;
- unsigned long flags;
-
wait_queue_head_t read_wait;
struct sk_buff_head readq;
+
+ struct delayed_work open_timeout;
};
static int vhci_open_dev(struct hci_dev *hdev)
@@ -99,16 +100,62 @@ static int vhci_send_frame(struct sk_buff *skb)
skb_queue_tail(&data->readq, skb);
wake_up_interruptible(&data->read_wait);
+ return 0;
+}
+
+static int vhci_create_device(struct vhci_data *data, __u8 dev_type)
+{
+ struct hci_dev *hdev;
+ struct sk_buff *skb;
+
+ skb = bt_skb_alloc(4, GFP_KERNEL);
+ if (!skb)
+ return -ENOMEM;
+
+ hdev = hci_alloc_dev();
+ if (!hdev) {
+ kfree_skb(skb);
+ return -ENOMEM;
+ }
+
+ data->hdev = hdev;
+
+ hdev->bus = HCI_VIRTUAL;
+ hdev->dev_type = dev_type;
+ hci_set_drvdata(hdev, data);
+
+ hdev->open = vhci_open_dev;
+ hdev->close = vhci_close_dev;
+ hdev->flush = vhci_flush;
+ hdev->send = vhci_send_frame;
+ if (hci_register_dev(hdev) < 0) {
+ BT_ERR("Can't register HCI device");
+ hci_free_dev(hdev);
+ data->hdev = NULL;
+ kfree_skb(skb);
+ return -EBUSY;
+ }
+
+ bt_cb(skb)->pkt_type = HCI_VENDOR_PKT;
+
+ *skb_put(skb, 1) = 0xff;
+ *skb_put(skb, 1) = dev_type;
+ put_unaligned_le16(hdev->id, skb_put(skb, 2));
+ skb_queue_tail(&data->readq, skb);
+
+ wake_up_interruptible(&data->read_wait);
return 0;
}
static inline ssize_t vhci_get_user(struct vhci_data *data,
- const char __user *buf, size_t count)
+ const char __user *buf, size_t count)
{
struct sk_buff *skb;
+ __u8 pkt_type, dev_type;
+ int ret;
- if (count > HCI_MAX_FRAME_SIZE)
+ if (count < 2 || count > HCI_MAX_FRAME_SIZE)
return -EINVAL;
skb = bt_skb_alloc(count, GFP_KERNEL);
@@ -120,27 +167,70 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
return -EFAULT;
}
- skb->dev = (void *) data->hdev;
- bt_cb(skb)->pkt_type = *((__u8 *) skb->data);
+ pkt_type = *((__u8 *) skb->data);
skb_pull(skb, 1);
- hci_recv_frame(skb);
+ switch (pkt_type) {
+ case HCI_EVENT_PKT:
+ case HCI_ACLDATA_PKT:
+ case HCI_SCODATA_PKT:
+ if (!data->hdev) {
+ kfree_skb(skb);
+ return -ENODEV;
+ }
+
+ skb->dev = (void *) data->hdev;
+ bt_cb(skb)->pkt_type = pkt_type;
+
+ ret = hci_recv_frame(skb);
+ break;
+
+ case HCI_VENDOR_PKT:
+ if (data->hdev) {
+ kfree_skb(skb);
+ return -EBADFD;
+ }
- return count;
+ cancel_delayed_work_sync(&data->open_timeout);
+
+ dev_type = *((__u8 *) skb->data);
+ skb_pull(skb, 1);
+
+ if (skb->len > 0) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ kfree_skb(skb);
+
+ if (dev_type != HCI_BREDR && dev_type != HCI_AMP)
+ return -EINVAL;
+
+ ret = vhci_create_device(data, dev_type);
+ break;
+
+ default:
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ return (ret < 0) ? ret : count;
}
static inline ssize_t vhci_put_user(struct vhci_data *data,
- struct sk_buff *skb, char __user *buf, int count)
+ struct sk_buff *skb,
+ char __user *buf, int count)
{
char __user *ptr = buf;
- int len, total = 0;
+ int len;
len = min_t(unsigned int, skb->len, count);
if (copy_to_user(ptr, skb->data, len))
return -EFAULT;
- total += len;
+ if (!data->hdev)
+ return len;
data->hdev->stat.byte_tx += len;
@@ -148,21 +238,19 @@ static inline ssize_t vhci_put_user(struct vhci_data *data,
case HCI_COMMAND_PKT:
data->hdev->stat.cmd_tx++;
break;
-
case HCI_ACLDATA_PKT:
data->hdev->stat.acl_tx++;
break;
-
case HCI_SCODATA_PKT:
data->hdev->stat.sco_tx++;
break;
}
- return total;
+ return len;
}
static ssize_t vhci_read(struct file *file,
- char __user *buf, size_t count, loff_t *pos)
+ char __user *buf, size_t count, loff_t *pos)
{
struct vhci_data *data = file->private_data;
struct sk_buff *skb;
@@ -185,7 +273,7 @@ static ssize_t vhci_read(struct file *file,
}
ret = wait_event_interruptible(data->read_wait,
- !skb_queue_empty(&data->readq));
+ !skb_queue_empty(&data->readq));
if (ret < 0)
break;
}
@@ -194,7 +282,7 @@ static ssize_t vhci_read(struct file *file,
}
static ssize_t vhci_write(struct file *file,
- const char __user *buf, size_t count, loff_t *pos)
+ const char __user *buf, size_t count, loff_t *pos)
{
struct vhci_data *data = file->private_data;
@@ -213,10 +301,17 @@ static unsigned int vhci_poll(struct file *file, poll_table *wait)
return POLLOUT | POLLWRNORM;
}
+static void vhci_open_timeout(struct work_struct *work)
+{
+ struct vhci_data *data = container_of(work, struct vhci_data,
+ open_timeout.work);
+
+ vhci_create_device(data, amp ? HCI_AMP : HCI_BREDR);
+}
+
static int vhci_open(struct inode *inode, struct file *file)
{
struct vhci_data *data;
- struct hci_dev *hdev;
data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL);
if (!data)
@@ -225,35 +320,13 @@ static int vhci_open(struct inode *inode, struct file *file)
skb_queue_head_init(&data->readq);
init_waitqueue_head(&data->read_wait);
- hdev = hci_alloc_dev();
- if (!hdev) {
- kfree(data);
- return -ENOMEM;
- }
-
- data->hdev = hdev;
-
- hdev->bus = HCI_VIRTUAL;
- hci_set_drvdata(hdev, data);
-
- if (amp)
- hdev->dev_type = HCI_AMP;
-
- hdev->open = vhci_open_dev;
- hdev->close = vhci_close_dev;
- hdev->flush = vhci_flush;
- hdev->send = vhci_send_frame;
-
- if (hci_register_dev(hdev) < 0) {
- BT_ERR("Can't register HCI device");
- kfree(data);
- hci_free_dev(hdev);
- return -EBUSY;
- }
+ INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout);
file->private_data = data;
nonseekable_open(inode, file);
+ schedule_delayed_work(&data->open_timeout, msecs_to_jiffies(1000));
+
return 0;
}
@@ -262,8 +335,12 @@ static int vhci_release(struct inode *inode, struct file *file)
struct vhci_data *data = file->private_data;
struct hci_dev *hdev = data->hdev;
- hci_unregister_dev(hdev);
- hci_free_dev(hdev);
+ cancel_delayed_work_sync(&data->open_timeout);
+
+ if (hdev) {
+ hci_unregister_dev(hdev);
+ hci_free_dev(hdev);
+ }
file->private_data = NULL;
kfree(data);
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH 1/3] sco-tester: Update ECONNABORTED to EOPNOTSUPP
From: Frédéric DALLEAU @ 2013-09-02 15:53 UTC (permalink / raw)
To: Frédéric Dalleau; +Cc: linux-bluetooth
In-Reply-To: <1376062977-1497-1-git-send-email-frederic.dalleau@linux.intel.com>
Le 09/08/2013 17:42, Frédéric Dalleau a écrit :
> Kernel interface has evolved in between.
> ---
> tools/sco-tester.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/sco-tester.c b/tools/sco-tester.c
> index 70b8a5d..1e8351f 100644
> --- a/tools/sco-tester.c
> +++ b/tools/sco-tester.c
> @@ -237,7 +237,7 @@ static const struct sco_client_data connect_success = {
> };
>
> static const struct sco_client_data connect_failure = {
> - .expect_err = ECONNABORTED
> + .expect_err = EOPNOTSUPP
> };
>
> static void client_connectable_complete(uint16_t opcode, uint8_t status,
>
Hello,
SCO sockets are now using EOPNOTSUPP.
What about these patches?
Thanks,
Frédéric
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add support for BCM20702A0 [0b05, 17cb]
From: Marcel Holtmann @ 2013-09-02 15:53 UTC (permalink / raw)
To: Raphael Kubo da Costa; +Cc: linux-bluetooth, stable
In-Reply-To: <1378123071-16732-1-git-send-email-rakuco@FreeBSD.org>
Hi Raphael,
> Yet another vendor specific ID for this chipset; this one for the ASUS
> USB-BT400 Bluetooth 4.0 adapter.
>
> T: Bus=03 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 6 Spd=12 MxCh= 0
> D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
> P: Vendor=0b05 ProdID=17cb Rev=01.12
> S: Manufacturer=Broadcom Corp
> S: Product=BCM20702A0
> S: SerialNumber=000272C64400
> C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
> I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
> I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Raphael Kubo da Costa <rakuco@FreeBSD.org>
> ---
> drivers/bluetooth/btusb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index d3313e6..c0a9df4 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -99,6 +99,7 @@ static struct usb_device_id btusb_table[] = {
>
> /* Broadcom BCM20702A0 */
> { USB_DEVICE(0x0b05, 0x17b5) },
> + { USB_DEVICE(0x0b05, 0x17cb) },
> { USB_DEVICE(0x04ca, 0x2003) },
> { USB_DEVICE(0x0489, 0xe042) },
> { USB_DEVICE(0x413c, 0x8197) },
I wonder if we should stop this crazy and just this one line
USB_VENDOR_AND_INTERFACE_INFO(0x0b05, 0xff, 0x01, 0x01)
for all Broadcom originated devices.
Same as we do for all Apple Bluetooth devices that are based on Broadcom chips. It seems that Broadcom decided to use ff:01:01 for their chips instead of the official e0:01:01.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add support for BCM20702A0 [0b05, 17cb]
From: Tim Aerts @ 2013-09-02 15:02 UTC (permalink / raw)
To: Raphael Kubo da Costa; +Cc: Gustavo Padovan, linux-bluetooth, stable
In-Reply-To: <837gezbaax.fsf@FreeBSD.org>
Raphael,
I wish I had time to do so. But since we couldn't get bluez to work
and my e-mail to this list remained unanswered (probably even unread),
my employer has already moved on.
I provide these id's in hope to avoid other victims. I may get some
time to come back to this in a some weeks/months from now. But I
didn't want to withhold this information from you guys.
Cheers,
Tim
On Mon, Sep 2, 2013 at 3:52 PM, Raphael Kubo da Costa
<rakuco@freebsd.org> wrote:
> Tim Aerts <tim.koder@gmail.com> writes:
>
>> The Trust Bluetooth 4.0 USB module is also BCM20702A0. The id's are
>> 0x21e8 and 0x0a5c.
>>
>> Would you please add this one as well?
>
> Hi,
>
> I don't have access to this device, so I can't test the patch or provide
> the usb-devices output that's generally needed for this kind of commit.
>
> If you do, it would probably be easier for you to send the patch
> yourself.
>
> Cheers.
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add support for BCM20702A0 [0b05, 17cb]
From: Raphael Kubo da Costa @ 2013-09-02 13:52 UTC (permalink / raw)
To: Tim Aerts; +Cc: Gustavo Padovan, linux-bluetooth, stable
In-Reply-To: <CAPs60XyE6FsdKFdvsui6JbEPWLhGGpSTHKUpPDMM3hp-vbhrRw@mail.gmail.com>
Tim Aerts <tim.koder@gmail.com> writes:
> The Trust Bluetooth 4.0 USB module is also BCM20702A0. The id's are
> 0x21e8 and 0x0a5c.
>
> Would you please add this one as well?
Hi,
I don't have access to this device, so I can't test the patch or provide
the usb-devices output that's generally needed for this kind of commit.
If you do, it would probably be easier for you to send the patch
yourself.
Cheers.
^ permalink raw reply
* Re: [PATCH] Bluetooth: Add support for BCM20702A0 [0b05, 17cb]
From: Tim Aerts @ 2013-09-02 13:26 UTC (permalink / raw)
To: Gustavo Padovan, Raphael Kubo da Costa, linux-bluetooth, stable
In-Reply-To: <20130902124133.GP7440@joana>
The Trust Bluetooth 4.0 USB module is also BCM20702A0. The id's are
0x21e8 and 0x0a5c.
Would you please add this one as well?
On Mon, Sep 2, 2013 at 2:41 PM, Gustavo Padovan <gustavo@padovan.org> wrote:
> Hi Raphael,
>
> 2013-09-02 Raphael Kubo da Costa <rakuco@FreeBSD.org>:
>
>> Yet another vendor specific ID for this chipset; this one for the ASUS
>> USB-BT400 Bluetooth 4.0 adapter.
>>
>> T: Bus=03 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 6 Spd=12 MxCh= 0
>> D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
>> P: Vendor=0b05 ProdID=17cb Rev=01.12
>> S: Manufacturer=Broadcom Corp
>> S: Product=BCM20702A0
>> S: SerialNumber=000272C64400
>> C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
>> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
>> I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
>> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
>> I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Raphael Kubo da Costa <rakuco@FreeBSD.org>
>> ---
>> drivers/bluetooth/btusb.c | 1 +
>> 1 file changed, 1 insertion(+)
>
> Patch has been applied to bluetooth.git. Thanks.
>
> Gustavo
> --
> 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] Bluetooth: Add support for BCM20702A0 [0b05, 17cb]
From: Gustavo Padovan @ 2013-09-02 12:41 UTC (permalink / raw)
To: Raphael Kubo da Costa; +Cc: linux-bluetooth, stable
In-Reply-To: <1378123071-16732-1-git-send-email-rakuco@FreeBSD.org>
Hi Raphael,
2013-09-02 Raphael Kubo da Costa <rakuco@FreeBSD.org>:
> Yet another vendor specific ID for this chipset; this one for the ASUS
> USB-BT400 Bluetooth 4.0 adapter.
>
> T: Bus=03 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 6 Spd=12 MxCh= 0
> D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
> P: Vendor=0b05 ProdID=17cb Rev=01.12
> S: Manufacturer=Broadcom Corp
> S: Product=BCM20702A0
> S: SerialNumber=000272C64400
> C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
> I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
> I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Raphael Kubo da Costa <rakuco@FreeBSD.org>
> ---
> drivers/bluetooth/btusb.c | 1 +
> 1 file changed, 1 insertion(+)
Patch has been applied to bluetooth.git. Thanks.
Gustavo
^ permalink raw reply
* [PATCH] hog: ignore UHID-setup events and document why
From: David Herrmann @ 2013-09-02 11:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Johan Hedberg, Marcel Holtmann, David Herrmann
The UHID_{START,STOP,OPEN,CLOSE} events should be ignored by us to avoid
triggering the warn(). It is safe to do that. Add few comments that
explain why we don't have to handle these.
---
profiles/input/hog.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 91c2802..0130f94 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -621,12 +621,42 @@ static gboolean uhid_event_cb(GIOChannel *io, GIOCondition cond,
DBG("uHID event type %d received", ev.type);
switch (ev.type) {
+ case UHID_START:
+ case UHID_STOP:
+ /* These are called to start and stop the underlying hardware.
+ * For HoG we open the channels before creating the device so
+ * the hardware is always ready. No need to handle these.
+ * Note that these are also called when the kernel switches
+ * between device-drivers loaded on the HID device. But we can
+ * simply keep the hardware alive during transitions and it
+ * works just fine.
+ * The kernel never destroys a device itself! Only an explicit
+ * UHID_DESTROY request can remove a device. */
+ break;
+ case UHID_OPEN:
+ case UHID_CLOSE:
+ /* OPEN/CLOSE are sent whenever user-space opens any interface
+ * provided by the kernel HID device. Whenever the open-count
+ * is non-zero we must be ready for I/O. As long as it is zero,
+ * we can decide to drop all I/O and put the device asleep. This
+ * is optional, though. Moreover, some special device drivers
+ * are buggy in that regard, so maybe we just keep I/O always
+ * awake like HIDP in the kernel does. */
+ break;
case UHID_OUTPUT:
case UHID_FEATURE:
forward_report(hogdev, &ev);
break;
case UHID_OUTPUT_EV:
- DBG("uHID output event: type %d code %d value %d",
+ /* This is only sent by kernels prior to linux-3.11. It requires
+ * us to parse HID-descriptors in user-space to properly handle
+ * it. This is redundant as the kernel does it already. That's
+ * why newer kernels assemble the output-reports and send it to
+ * us via UHID_OUTPUT.
+ * We never implemented this, so we rely on users to use
+ * recent-enough kernels if they want this feature. No reason to
+ * implement this for older kernels. */
+ DBG("Unsupported uHID output event: type %d code %d value %d",
ev.u.output_ev.type, ev.u.output_ev.code,
ev.u.output_ev.value);
break;
--
1.8.4
^ permalink raw reply related
* [PATCH] Bluetooth: Add support for BCM20702A0 [0b05, 17cb]
From: Raphael Kubo da Costa @ 2013-09-02 11:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: stable
Yet another vendor specific ID for this chipset; this one for the ASUS
USB-BT400 Bluetooth 4.0 adapter.
T: Bus=03 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 6 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0b05 ProdID=17cb Rev=01.12
S: Manufacturer=Broadcom Corp
S: Product=BCM20702A0
S: SerialNumber=000272C64400
C: #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
Cc: stable@vger.kernel.org
Signed-off-by: Raphael Kubo da Costa <rakuco@FreeBSD.org>
---
drivers/bluetooth/btusb.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index d3313e6..c0a9df4 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -99,6 +99,7 @@ static struct usb_device_id btusb_table[] = {
/* Broadcom BCM20702A0 */
{ USB_DEVICE(0x0b05, 0x17b5) },
+ { USB_DEVICE(0x0b05, 0x17cb) },
{ USB_DEVICE(0x04ca, 0x2003) },
{ USB_DEVICE(0x0489, 0xe042) },
{ USB_DEVICE(0x413c, 0x8197) },
--
1.8.4
^ permalink raw reply related
* Re: [PATCH 2/2] obexd: Add property changed signals for 'org.bluez.obex.Message1'
From: Luiz Augusto von Dentz @ 2013-09-02 10:43 UTC (permalink / raw)
To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <521C50AA.3090802@oss.bmw-carit.de>
Hi Christian,
On Tue, Aug 27, 2013 at 10:09 AM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> Hi Luiz,
>
> On 08/26/2013 02:08 PM, Luiz Augusto von Dentz wrote:
>> Hi Christian,
>>
>> On Thu, Aug 22, 2013 at 7:08 PM, Christian Fetzer
>> <christian.fetzer@oss.bmw-carit.de> wrote:
>>> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>>>
>>> This patch adds property changed signal emissions in case message properties
>>> change on the server.
>>> ---
>>> obexd/client/map.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
>>> 1 file changed, 92 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/obexd/client/map.c b/obexd/client/map.c
>>> index 8864a54..a9a9bcd 100644
>>> --- a/obexd/client/map.c
>>> +++ b/obexd/client/map.c
>>> @@ -792,121 +792,211 @@ static struct map_msg *map_msg_create(struct map_data *data, const char *handle)
>>>
>>> static void parse_subject(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->subject, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->subject);
>>> msg->subject = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Subject");
>>> }
>>>
>>> static void parse_datetime(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->timestamp, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->timestamp);
>>> msg->timestamp = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Timestamp");
>>> }
>>>
>>> static void parse_sender(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->sender, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->sender);
>>> msg->sender = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Sender");
>>> }
>>>
>>> static void parse_sender_address(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->sender_address, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->sender_address);
>>> msg->sender_address = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "SenderAddress");
>>> }
>>>
>>> static void parse_replyto(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->replyto, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->replyto);
>>> msg->replyto = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "ReplyTo");
>>> }
>>>
>>> static void parse_recipient(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->recipient, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->recipient);
>>> msg->recipient = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Recipient");
>>> }
>>>
>>> static void parse_recipient_address(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->recipient_address, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->recipient_address);
>>> msg->recipient_address = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "RecipientAddress");
>>> }
>>>
>>> static void parse_type(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->type, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->type);
>>> msg->type = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Type");
>>> }
>>>
>>> static void parse_size(struct map_msg *msg, const char *value)
>>> {
>>> - msg->size = g_ascii_strtoll(value, NULL, 10);
>>> + uint64_t size = g_ascii_strtoll(value, NULL, 10);
>>> +
>>> + if (msg->size == size)
>>> + return;
>>> +
>>> + msg->size = size;
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Size");
>>> }
>>>
>>> static void parse_text(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_TEXT;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_TEXT;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Text");
>>> }
>>>
>>> static void parse_status(struct map_msg *msg, const char *value)
>>> {
>>> + if (g_strcmp0(msg->status, value) == 0)
>>> + return;
>>> +
>>> g_free(msg->status);
>>> msg->status = g_strdup(value);
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Status");
>>> }
>>>
>>> static void parse_attachment_size(struct map_msg *msg, const char *value)
>>> {
>>> - msg->attachment_size = g_ascii_strtoll(value, NULL, 10);
>>> + uint64_t attachment_size = g_ascii_strtoll(value, NULL, 10);
>>> +
>>> + if (msg->attachment_size == attachment_size)
>>> + return;
>>> +
>>> + msg->attachment_size = attachment_size;
>>> +
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "AttachmentSize");
>>> }
>>>
>>> static void parse_priority(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_PRIORITY;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_PRIORITY;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Priority");
>>> }
>>>
>>> static void parse_read(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_READ;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_READ;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Read");
>>> }
>>>
>>> static void parse_sent(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_SENT;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_SENT;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Sent");
>>> }
>>>
>>> static void parse_protected(struct map_msg *msg, const char *value)
>>> {
>>> gboolean flag = strcasecmp(value, "no") != 0;
>>>
>>> + uint8_t oldflags = msg->flags;
>>> if (flag)
>>> msg->flags |= MAP_MSG_FLAG_PROTECTED;
>>> else
>>> msg->flags &= ~MAP_MSG_FLAG_PROTECTED;
>>>
>>> + if (msg->flags != oldflags)
>>> + g_dbus_emit_property_changed(conn, msg->path,
>>> + MAP_MSG_INTERFACE, "Protected");
>>> }
>>>
>>> static struct map_msg_parser {
>>> --
>>> 1.8.3.4
>>
>> Does this make us emit signals when creating the objects? That should
>> probably not be necessary, only emit signals once the value really
>> changes.
>>
>>
>
> The property changed signals are not sent for newly created objects.
> This is already ensured in g_dbus_emit_property_changed (gdbus/object.c:1709).
> Do you prefer an additional check?
Fair enough, I applied it after fixing the new line before defining
oldflags, it looks like it was a copy/paste error please make sure
this does not happen again.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH v2 1/2] obexd: Add obc_session_get_folder function
From: Luiz Augusto von Dentz @ 2013-09-02 10:39 UTC (permalink / raw)
To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1377866712-5253-1-git-send-email-christian.fetzer@oss.bmw-carit.de>
Hi Christian,
On Fri, Aug 30, 2013 at 3:45 PM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>
> This patch extends client session by the tracking of the current folder.
> The current folder can be accessed by obc_session_get_current_folder.
>
> This allows drivers to add a folder property to browsed objects so that
> the application doesn't have to keep track of the folder an object
> belongs to.
> ---
> obexd/client/session.c | 38 ++++++++++++++++++++++++++++++++++++++
> obexd/client/session.h | 2 ++
> 2 files changed, 40 insertions(+)
>
> diff --git a/obexd/client/session.c b/obexd/client/session.c
> index 44e2bf8..632e114 100644
> --- a/obexd/client/session.c
> +++ b/obexd/client/session.c
> @@ -110,6 +110,7 @@ struct obc_session {
> guint watch;
> GQueue *queue;
> guint process_id;
> + char *folder;
> };
>
> static GSList *sessions = NULL;
> @@ -242,6 +243,7 @@ static void session_free(struct obc_session *session)
> g_free(session->owner);
> g_free(session->source);
> g_free(session->destination);
> + g_free(session->folder);
> g_free(session);
> }
>
> @@ -500,6 +502,7 @@ struct obc_session *obc_session_create(const char *source,
> session->destination = g_strdup(destination);
> session->channel = channel;
> session->queue = g_queue_new();
> + session->folder = g_strdup("/");
>
> if (owner)
> obc_session_set_owner(session, owner, owner_disconnected);
> @@ -930,6 +933,11 @@ const char *obc_session_get_target(struct obc_session *session)
> return session->driver->target;
> }
>
> +const char *obc_session_get_folder(struct obc_session *session)
> +{
> + return session->folder;
> +}
> +
> static void setpath_complete(struct obc_session *session,
> struct obc_transfer *transfer,
> GError *err, void *user_data)
> @@ -957,12 +965,39 @@ static void setpath_op_complete(struct obc_session *session,
> data->func(session, NULL, err, data->user_data);
> }
>
> +static void setpath_set_folder(struct obc_session *session, const char *cur)
> +{
> + char *folder = NULL;
> + const char *delim;
> +
> + delim = strrchr(session->folder, '/');
> + if (strlen(cur) == 0 || delim == NULL ||
> + (strcmp(cur, "..") == 0 && delim == session->folder)) {
> + folder = g_strdup("/");
> + } else {
> + if (strcmp(cur, "..") == 0) {
> + folder = g_strndup(session->folder,
> + delim - session->folder);
> + } else {
> + if (g_str_has_suffix(session->folder, "/"))
> + folder = g_strconcat(session->folder,
> + cur, NULL);
> + else
> + folder = g_strconcat(session->folder, "/",
> + cur, NULL);
> + }
> + }
> + g_free(session->folder);
> + session->folder = folder;
> +}
> +
> static void setpath_cb(GObex *obex, GError *err, GObexPacket *rsp,
> gpointer user_data)
> {
> struct pending_request *p = user_data;
> struct setpath_data *data = p->data;
> char *next;
> + char *current;
> guint8 code;
>
> p->req_id = 0;
> @@ -982,6 +1017,9 @@ static void setpath_cb(GObex *obex, GError *err, GObexPacket *rsp,
> return;
> }
>
> + current = data->remaining[data->index - 1];
> + setpath_set_folder(p->session, current);
> +
> /* Ignore empty folder names to avoid resetting the current path */
> while ((next = data->remaining[data->index]) && strlen(next) == 0)
> data->index++;
> diff --git a/obexd/client/session.h b/obexd/client/session.h
> index 319d529..35899bc 100644
> --- a/obexd/client/session.h
> +++ b/obexd/client/session.h
> @@ -58,6 +58,8 @@ const char *obc_session_register(struct obc_session *session,
> const void *obc_session_get_attribute(struct obc_session *session,
> int attribute_id);
>
> +const char *obc_session_get_folder(struct obc_session *session);
> +
> guint obc_session_queue(struct obc_session *session,
> struct obc_transfer *transfer,
> session_callback_t func, void *user_data,
> --
> 1.8.3.4
Both patches applied, thanks.
--
Luiz Augusto von Dentz
^ 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