* [PATCH 1/3 v3] Unified ebook data structures
From: Dmitriy Paliy @ 2010-12-08 21:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1291842956-8610-1-git-send-email-dmitriy.paliy@nokia.com>
Query data structures are unified in phonebook-ebook.c to have a
unique identifier for ebook async operation. Purpose of this
modification is next commit where pending async operation can be
cancelled.
---
plugins/phonebook-ebook.c | 36 ++++++++++++++++--------------------
1 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/plugins/phonebook-ebook.c b/plugins/phonebook-ebook.c
index 073ff33..b9d297a 100644
--- a/plugins/phonebook-ebook.c
+++ b/plugins/phonebook-ebook.c
@@ -45,13 +45,9 @@
#define QUERY_NAME "(contains \"given_name\" \"%s\")"
#define QUERY_PHONE "(contains \"phone\" \"%s\")"
-struct contacts_query {
+struct context_query {
const struct apparam_field *params;
- phonebook_cb cb;
- void *user_data;
-};
-
-struct cache_query {
+ phonebook_cb contacts_cb;
phonebook_entry_cb entry_cb;
phonebook_cache_ready_cb ready_cb;
void *user_data;
@@ -141,7 +137,7 @@ static char *evcard_to_string(EVCard *evcard, unsigned int format,
static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts,
void *user_data)
{
- struct contacts_query *data = user_data;
+ struct context_query *data = user_data;
GString *string = g_string_new("");
unsigned int count = 0, maxcount;
GList *l;
@@ -182,7 +178,7 @@ static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts,
done:
- data->cb(string->str, string->len, count, 0, data->user_data);
+ data->contacts_cb(string->str, string->len, count, 0, data->user_data);
g_string_free(string, TRUE);
g_free(data);
@@ -191,14 +187,14 @@ done:
static void ebook_entry_cb(EBook *book, EBookStatus estatus,
EContact *contact, void *user_data)
{
- struct contacts_query *data = user_data;
+ struct context_query *data = user_data;
EVCard *evcard;
char *vcard;
size_t len;
if (estatus != E_BOOK_ERROR_OK) {
error("E-Book query failed: status %d", estatus);
- data->cb(NULL, 0, 1, 0, data->user_data);
+ data->contacts_cb(NULL, 0, 1, 0, data->user_data);
g_free(data);
return;
}
@@ -210,7 +206,7 @@ static void ebook_entry_cb(EBook *book, EBookStatus estatus,
len = vcard ? strlen(vcard) : 0;
- data->cb(vcard, len, 1, 0, data->user_data);
+ data->contacts_cb(vcard, len, 1, 0, data->user_data);
g_free(vcard);
g_free(data);
@@ -249,7 +245,7 @@ static char *evcard_name_attribute_to_string(EVCard *evcard)
static void cache_cb(EBook *book, EBookStatus estatus, GList *contacts,
void *user_data)
{
- struct cache_query *data = user_data;
+ struct context_query *data = user_data;
GList *l;
if (estatus != E_BOOK_ERROR_OK) {
@@ -411,13 +407,13 @@ done:
int phonebook_pull(const char *name, const struct apparam_field *params,
phonebook_cb cb, void *user_data)
{
- struct contacts_query *data;
+ struct context_query *data;
EBookQuery *query;
query = e_book_query_any_field_contains("");
- data = g_new0(struct contacts_query, 1);
- data->cb = cb;
+ data = g_new0(struct context_query, 1);
+ data->contacts_cb = cb;
data->params = params;
data->user_data = user_data;
@@ -432,10 +428,10 @@ int phonebook_get_entry(const char *folder, const char *id,
const struct apparam_field *params,
phonebook_cb cb, void *user_data)
{
- struct contacts_query *data;
+ struct context_query *data;
- data = g_new0(struct contacts_query, 1);
- data->cb = cb;
+ data = g_new0(struct context_query, 1);
+ data->contacts_cb = cb;
data->params = params;
data->user_data = user_data;
@@ -450,7 +446,7 @@ int phonebook_get_entry(const char *folder, const char *id,
int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
phonebook_cache_ready_cb ready_cb, void *user_data)
{
- struct cache_query *data;
+ struct context_query *data;
EBookQuery *query;
gboolean ret;
@@ -459,7 +455,7 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
query = e_book_query_any_field_contains("");
- data = g_new0(struct cache_query, 1);
+ data = g_new0(struct context_query, 1);
data->entry_cb = entry_cb;
data->ready_cb = ready_cb;
data->user_data = user_data;
--
1.7.0.4
^ permalink raw reply related
* [PATCH 0/3 v3] Cancel pending phonebook request
From: Dmitriy Paliy @ 2010-12-08 21:15 UTC (permalink / raw)
To: linux-bluetooth
Hi,
This is updated version of patch to handle pending phonebook
request and to cancel it if OBEX session is terminated.
Additionally to previous submission, it containts updates for
phonebook-dummy.c and phonebook-ebook.c backend drivers. Therefore,
it is highly encouraged for those who exploit them to provide
feedback.
Also, code for tracker was significantly improved.
BR,
Dmitriy
^ permalink raw reply
* Re: [PATCH 1/7] Fix coding styling issues in src/error.c
From: Johan Hedberg @ 2010-12-08 20:58 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1291839961-14940-1-git-send-email-padovan@profusion.mobi>
Hi Gustavo,
On Wed, Dec 08, 2010, Gustavo F. Padovan wrote:
> ---
> src/error.c | 26 +++++++++-----------------
> 1 files changed, 9 insertions(+), 17 deletions(-)
Thanks! All seven patches have been pushed upstream.
Johan
^ permalink raw reply
* [PATCH 7/7] Add btd_error_already_connected()
From: Gustavo F. Padovan @ 2010-12-08 20:26 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-6-git-send-email-padovan@profusion.mobi>
---
audio/device.c | 4 +---
audio/headset.c | 8 ++------
audio/sink.c | 4 +---
audio/source.c | 4 +---
input/device.c | 8 +-------
network/connection.c | 2 +-
src/error.c | 6 ++++++
src/error.h | 1 +
8 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/audio/device.c b/audio/device.c
index 6e005a5..fe7aed4 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -521,9 +521,7 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
if (priv->state == AUDIO_STATE_CONNECTING)
return btd_error_in_progress(msg);
else if (priv->state == AUDIO_STATE_CONNECTED)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Already Connected");
+ return btd_error_already_connected(msg);
dev->auto_connect = TRUE;
diff --git a/audio/headset.c b/audio/headset.c
index 8402789..3d584e0 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1697,9 +1697,7 @@ static DBusMessage *hs_connect(DBusConnection *conn, DBusMessage *msg,
if (hs->state == HEADSET_STATE_CONNECTING)
return btd_error_in_progress(msg);
else if (hs->state > HEADSET_STATE_CONNECTING)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Already Connected");
+ return btd_error_already_connected(msg);
if (hs->hfp_handle && !ag.telephony_ready)
return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
@@ -1806,9 +1804,7 @@ static DBusMessage *hs_play(DBusConnection *conn, DBusMessage *msg,
}
return btd_error_busy(msg);
case HEADSET_STATE_PLAYING:
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
case HEADSET_STATE_CONNECTED:
default:
break;
diff --git a/audio/sink.c b/audio/sink.c
index 37ba8c0..176a4ed 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -442,9 +442,7 @@ static DBusMessage *sink_connect(DBusConnection *conn,
return btd_error_busy(msg);
if (sink->stream_state >= AVDTP_STATE_OPEN)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
if (!sink_setup_stream(sink, NULL))
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
diff --git a/audio/source.c b/audio/source.c
index 9b9dab7..c106eaa 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -393,9 +393,7 @@ static DBusMessage *source_connect(DBusConnection *conn,
return btd_error_busy(msg);
if (source->stream_state >= AVDTP_STATE_OPEN)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
if (!source_setup_stream(source, NULL))
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
diff --git a/input/device.c b/input/device.c
index 3c3f9fd..dee943b 100644
--- a/input/device.c
+++ b/input/device.c
@@ -315,12 +315,6 @@ failed:
return FALSE;
}
-static inline DBusMessage *already_connected(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
- "Already connected to a device");
-}
-
static inline DBusMessage *connection_attempt_failed(DBusMessage *msg,
const char *err)
{
@@ -937,7 +931,7 @@ static DBusMessage *input_device_connect(DBusConnection *conn,
return btd_error_in_progress(msg);
if (is_connected(iconn))
- return already_connected(msg);
+ return btd_error_already_connected(msg);
iconn->pending_connect = dbus_message_ref(msg);
fake = iconn->fake;
diff --git a/network/connection.c b/network/connection.c
index a652b98..89c38d8 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -396,7 +396,7 @@ static DBusMessage *connection_connect(DBusConnection *conn,
return btd_error_not_supported(msg);
if (nc->state != DISCONNECTED)
- return already_connected(msg);
+ return btd_error_already_connected(msg);
nc->io = bt_io_connect(BT_IO_L2CAP, connect_cb, nc,
NULL, &err,
diff --git a/src/error.c b/src/error.c
index 0d33fb5..e1f0598 100644
--- a/src/error.c
+++ b/src/error.c
@@ -79,6 +79,12 @@ DBusMessage *btd_error_not_connected(DBusMessage *msg)
"Not Connected");
}
+DBusMessage *btd_error_already_connected(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
+ "Already Connected");
+}
+
DBusMessage *btd_error_in_progress(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress",
diff --git a/src/error.h b/src/error.h
index a7028bd..9d80fa0 100644
--- a/src/error.h
+++ b/src/error.h
@@ -35,6 +35,7 @@ DBusMessage *btd_error_busy(DBusMessage *msg);
DBusMessage *btd_error_already_exists(DBusMessage *msg);
DBusMessage *btd_error_not_supported(DBusMessage *msg);
DBusMessage *btd_error_not_connected(DBusMessage *msg);
+DBusMessage *btd_error_already_connected(DBusMessage *msg);
DBusMessage *btd_error_not_available(DBusMessage *msg);
DBusMessage *btd_error_in_progress(DBusMessage *msg);
DBusMessage *btd_error_does_not_exist(DBusMessage *msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 6/7] convert error to btd_error_not_supported()
From: Gustavo F. Padovan @ 2010-12-08 20:26 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-5-git-send-email-padovan@profusion.mobi>
---
input/device.c | 8 +-------
network/connection.c | 2 +-
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/input/device.c b/input/device.c
index f7f96be..3c3f9fd 100644
--- a/input/device.c
+++ b/input/device.c
@@ -315,12 +315,6 @@ failed:
return FALSE;
}
-static inline DBusMessage *not_supported(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Not supported");
-}
-
static inline DBusMessage *already_connected(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
@@ -937,7 +931,7 @@ static DBusMessage *input_device_connect(DBusConnection *conn,
iconn = find_connection(idev->connections, "HID");
if (!iconn)
- return not_supported(msg);
+ return btd_error_not_supported(msg);
if (iconn->pending_connect)
return btd_error_in_progress(msg);
diff --git a/network/connection.c b/network/connection.c
index d24d96c..a652b98 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -393,7 +393,7 @@ static DBusMessage *connection_connect(DBusConnection *conn,
id = bnep_service_id(svc);
nc = find_connection(peer->connections, id);
if (!nc)
- return not_supported(msg);
+ return btd_error_not_supported(msg);
if (nc->state != DISCONNECTED)
return already_connected(msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 5/7] convert error to btd_error_not_connected()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-4-git-send-email-padovan@profusion.mobi>
---
network/connection.c | 8 +-------
serial/port.c | 2 +-
src/device.c | 4 +---
3 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/network/connection.c b/network/connection.c
index 37a7511..d24d96c 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -123,12 +123,6 @@ static inline DBusMessage *already_connected(DBusMessage *msg)
"Device already connected");
}
-static inline DBusMessage *not_connected(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Device not connected");
-}
-
static inline DBusMessage *not_permited(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
@@ -460,7 +454,7 @@ static DBusMessage *connection_disconnect(DBusConnection *conn,
return connection_cancel(conn, msg, nc);
}
- return not_connected(msg);
+ return btd_error_not_connected(msg);
}
static DBusMessage *connection_get_properties(DBusConnection *conn,
diff --git a/serial/port.c b/serial/port.c
index 1d0bfc1..0d1e600 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -533,7 +533,7 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
return btd_error_does_not_exist(msg);
if (!port->listener_id)
- return failed(msg, "Not connected");
+ return btd_error_not_connected(msg);
owner = dbus_message_get_sender(port->msg);
caller = dbus_message_get_sender(msg);
diff --git a/src/device.c b/src/device.c
index cc8131b..91b9d23 100644
--- a/src/device.c
+++ b/src/device.c
@@ -799,9 +799,7 @@ static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
struct btd_device *device = user_data;
if (!device->handle)
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".NotConnected",
- "Device is not connected");
+ return btd_error_not_connected(msg);
device_request_disconnect(device, msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 4/7] convert error to btd_error_busy()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-3-git-send-email-padovan@profusion.mobi>
---
audio/source.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/audio/source.c b/audio/source.c
index a6fd8e7..9b9dab7 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -425,8 +425,7 @@ static DBusMessage *source_disconnect(DBusConnection *conn,
return btd_error_not_connected(msg);
if (source->connect || source->disconnect)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "%s", strerror(EBUSY));
+ return btd_error_busy(msg);
if (source->stream_state < AVDTP_STATE_OPEN) {
DBusMessage *reply = dbus_message_new_method_return(msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 3/7] convert errors to btd_error_does_not_exist()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-2-git-send-email-padovan@profusion.mobi>
---
audio/gateway.c | 4 +---
audio/media.c | 3 +--
plugins/service.c | 2 +-
src/device.c | 4 +---
4 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 7aec623..05b9ff7 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -522,9 +522,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
return btd_error_invalid_args(msg);
if (strcmp(gw->agent->path, path) != 0)
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".Failed",
- "Unknown object path");
+ return btd_error_does_not_exist(msg);
g_dbus_remove_watch(device->conn, gw->agent->watch);
diff --git a/audio/media.c b/audio/media.c
index b893231..0e6ccc9 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -351,8 +351,7 @@ static DBusMessage *unregister_endpoint(DBusConnection *conn, DBusMessage *msg,
endpoint = media_adapter_find_endpoint(adapter, sender, path, NULL);
if (endpoint == NULL)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Endpoint not registered");
+ return btd_error_does_not_exist(msg);
media_endpoint_remove(endpoint);
diff --git a/plugins/service.c b/plugins/service.c
index 5267671..a442d53 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -600,7 +600,7 @@ static DBusMessage *request_authorization(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
if (find_pending_by_sender(serv_adapter, sender))
- return failed(msg);
+ return btd_error_does_not_exist(msg);
user_record = find_record(serv_adapter, handle, sender);
if (!user_record) {
diff --git a/src/device.c b/src/device.c
index 1b8d581..cc8131b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -723,9 +723,7 @@ static DBusMessage *cancel_discover(DBusConnection *conn,
const char *requestor;
if (!device->browse)
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".Failed",
- "No pending discovery");
+ return btd_error_does_not_exist(msg);
if (!dbus_message_is_method_call(device->browse->msg, DEVICE_INTERFACE,
"DiscoverServices"))
--
1.7.3.2
^ permalink raw reply related
* [PATCH 2/7] convert errors to btd_error_not_authorized()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-1-git-send-email-padovan@profusion.mobi>
---
audio/gateway.c | 3 +--
audio/transport.c | 8 ++++----
network/connection.c | 2 +-
serial/port.c | 2 +-
serial/proxy.c | 4 ++--
5 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 93c4301..7aec623 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -514,8 +514,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
goto done;
if (strcmp(gw->agent->name, dbus_message_get_sender(msg)) != 0)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Permission denied");
+ return btd_error_not_authorized(msg);
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_OBJECT_PATH, &path,
diff --git a/audio/transport.c b/audio/transport.c
index 48af0ea..e2ee400 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -443,10 +443,10 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
owner = media_transport_find_owner(transport, sender);
if (owner != NULL)
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
if (media_transport_acquire(transport, accesstype) == FALSE)
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
owner = media_owner_create(transport, msg, accesstype);
req = g_new0(struct acquire_request, 1);
@@ -476,7 +476,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
owner = media_transport_find_owner(transport, sender);
if (owner == NULL)
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
if (g_strcmp0(owner->accesstype, accesstype) == 0)
media_owner_remove(owner);
@@ -484,7 +484,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
media_transport_release(transport, accesstype);
g_strdelimit(owner->accesstype, accesstype, ' ');
} else
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
diff --git a/network/connection.c b/network/connection.c
index 7380cbe..37a7511 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -438,7 +438,7 @@ static DBusMessage *connection_cancel(DBusConnection *conn,
const char *caller = dbus_message_get_sender(msg);
if (!g_str_equal(owner, caller))
- return not_permited(msg);
+ return btd_error_not_authorized(msg);
connection_destroy(conn, nc);
diff --git a/serial/port.c b/serial/port.c
index add8ae0..1d0bfc1 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -538,7 +538,7 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
owner = dbus_message_get_sender(port->msg);
caller = dbus_message_get_sender(msg);
if (!g_str_equal(owner, caller))
- return failed(msg, "Operation not permited");
+ return btd_error_not_authorized(msg);
port_release(port);
diff --git a/serial/proxy.c b/serial/proxy.c
index 778deb0..c779c4e 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -728,7 +728,7 @@ static DBusMessage *proxy_set_serial_params(DBusConnection *conn,
/* Don't allow change TTY settings if it is open */
if (prx->local)
- return failed(msg, "Not allowed");
+ return btd_error_not_authorized(msg);
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &ratestr,
@@ -1112,7 +1112,7 @@ static DBusMessage *remove_proxy(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
if (g_strcmp0(prx->owner, sender) != 0)
- return failed(msg, "Permission denied");
+ return btd_error_not_authorized(msg);
unregister_proxy(prx);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 1/7] Fix coding styling issues in src/error.c
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
---
src/error.c | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/error.c b/src/error.c
index 3c09567..0d33fb5 100644
--- a/src/error.c
+++ b/src/error.c
@@ -51,8 +51,7 @@ DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
DBusMessage *btd_error_invalid_args(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".InvalidArguments",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments",
"Invalid arguments in method call");
}
@@ -64,49 +63,42 @@ DBusMessage *btd_error_busy(DBusMessage *msg)
DBusMessage *btd_error_already_exists(DBusMessage *msg)
{
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".AlreadyExists",
- "Already Exists");
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyExists",
+ "Already Exists");
}
DBusMessage *btd_error_not_supported(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotSupported",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotSupported",
"Operation is not supported");
}
DBusMessage *btd_error_not_connected(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotConnected",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotConnected",
"Not Connected");
}
DBusMessage *btd_error_in_progress(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".InProgress",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress",
"In Progress");
}
DBusMessage *btd_error_not_available(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotAvailable",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable",
"Operation currently not available");
}
DBusMessage *btd_error_does_not_exist(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".DoesNotExist",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist",
"Does Not Exist");
}
DBusMessage *btd_error_not_authorized(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotAuthorized",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAuthorized",
"Operation Not Authorized");
}
--
1.7.3.2
^ permalink raw reply related
* Re: [PATCH 1/1] bluetooth: add NULL pointer check in hci
From: Gustavo F. Padovan @ 2010-12-08 15:26 UTC (permalink / raw)
To: Jun Nie; +Cc: Vinicius Costa Gomes, Brian Gix, linux-bluetooth
In-Reply-To: <AANLkTinN3R4q-YA=4jweveB4LfE9S2SwhCK2xXYORw6W@mail.gmail.com>
Hi Jun,
* Jun Nie <niej0001@gmail.com> [2010-12-08 13:46:34 +0800]:
> From e729eda3b2cfae501c704e2eb39e07aa1b8607f0 Mon Sep 17 00:00:00 2001
> From: Jun Nie <njun@marvell.com>
> Date: Tue, 7 Dec 2010 14:03:38 +0800
> Subject: [PATCH] bluetooth: add NULL pointer check in hci
>
> If we fail to find a hci device pointer in hci_uart, don't try
> to deref the NULL one we do have.
>
> Signed-off-by: Jun Nie <njun@marvell.com>
> ---
> drivers/bluetooth/hci_ldisc.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
Patch is applied now, thanks.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [PATCH] Changed obex_service_driver put() signature.
From: Johan Hedberg @ 2010-12-08 15:18 UTC (permalink / raw)
To: Slawomir Bochenski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikzUraZ9ac5qf9ePG8YKo0Sx0B2YZoKz8HoRTmn@mail.gmail.com>
Hi,
On Wed, Dec 08, 2010, Slawomir Bochenski wrote:
> This API change is needed for implementing Message Access Profile, as
> MAP uses application parameters in puts also (for example
> SetMessageStatus function, see MAP specification, chapter 5.7) and in
> order to access application parameters headers access to obex object
> is required.
>
> ---
> plugins/ftp.c | 3 ++-
> plugins/opp.c | 3 ++-
> plugins/syncevolution.c | 3 ++-
> src/obex.c | 2 +-
> src/service.h | 3 ++-
> 5 files changed, 9 insertions(+), 5 deletions(-)
The patch looks good, but I can't apply it with git am. I get the
following:
fatal: corrupt patch at line 14
Patch failed at 0001 Changed obex_service_driver put() signature.
Could you try recreating it with git format-patch and resending with git
send-email? Thanks.
Btw, summary line should start with "Change ..." instead of "Changed
..." and it shouldn't end with a .
Johan
^ permalink raw reply
* Re: [PATCH 1/3] Add support for stat files bigger than 2GB on 32-bit systems
From: Johan Hedberg @ 2010-12-08 15:15 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1291821222-18990-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Wed, Dec 08, 2010, Luiz Augusto von Dentz wrote:
> From stat documentation:
>
> "(stat()) path refers to a file whose size cannot be represented in the
> type off_t. This can occur when an application compiled on a 32-bit
> platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size
> exceeds (2<<31)-1 bits."
>
> To fix this now size header is omitted when the file is over 32-bit, but
> it is able to transfer it by using 64-bit variables. In addition to that
> folder-listing now should report such big sizes properly.
> ---
> acinclude.m4 | 2 +-
> client/transfer.c | 5 +++--
> plugins/filesystem.c | 7 ++++---
> src/obex-priv.h | 6 +++---
> src/obex.c | 7 ++++---
> 5 files changed, 15 insertions(+), 12 deletions(-)
Thanks. The patch has been pushed upstream.
Johan
^ permalink raw reply
* [PATCH 1/3] Add support for stat files bigger than 2GB on 32-bit systems
From: Luiz Augusto von Dentz @ 2010-12-08 15:13 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>From stat documentation:
"(stat()) path refers to a file whose size cannot be represented in the
type off_t. This can occur when an application compiled on a 32-bit
platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size
exceeds (2<<31)-1 bits."
To fix this now size header is omitted when the file is over 32-bit, but
it is able to transfer it by using 64-bit variables. In addition to that
folder-listing now should report such big sizes properly.
---
acinclude.m4 | 2 +-
client/transfer.c | 5 +++--
plugins/filesystem.c | 7 ++++---
src/obex-priv.h | 6 +++---
src/obex.c | 7 ++++---
5 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index 4594073..3d1f511 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -12,7 +12,7 @@ AC_DEFUN([AC_PROG_CC_PIE], [
AC_DEFUN([COMPILER_FLAGS], [
if (test "${CFLAGS}" = ""); then
- CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
+ CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64"
fi
if (test "$USE_MAINTAINER_MODE" = "yes"); then
CFLAGS+=" -Werror -Wextra"
diff --git a/client/transfer.c b/client/transfer.c
index 6eec513..fdcaa46 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -470,7 +470,7 @@ int transfer_put(struct transfer_data *transfer, transfer_callback_t func,
struct session_data *session = transfer->session;
gw_obex_xfer_cb_t cb;
struct stat st;
- int fd;
+ int fd, size;
if (transfer->xfer != NULL)
return -EALREADY;
@@ -497,8 +497,9 @@ int transfer_put(struct transfer_data *transfer, transfer_callback_t func,
cb = put_xfer_progress;
done:
+ size = transfer->size < UINT32_MAX ? transfer->size : 0;
transfer->xfer = gw_obex_put_async(session->obex, transfer->name,
- transfer->type, transfer->size,
+ transfer->type, size,
-1, NULL);
if (transfer->xfer == NULL)
return -ENOTCONN;
diff --git a/plugins/filesystem.c b/plugins/filesystem.c
index bb758ab..b4ff556 100644
--- a/plugins/filesystem.c
+++ b/plugins/filesystem.c
@@ -66,7 +66,7 @@
#define FL_PARENT_FOLDER_ELEMENT "<parent-folder/>" EOL_CHARS
-#define FL_FILE_ELEMENT "<file name=\"%s\" size=\"%lu\"" \
+#define FL_FILE_ELEMENT "<file name=\"%s\" size=\"%" PRIu64 "\"" \
" %s accessed=\"%s\" " \
"modified=\"%s\" created=\"%s\"/>" EOL_CHARS
@@ -121,8 +121,9 @@ static char *file_stat_line(char *filename, struct stat *fstat,
ret = g_strdup_printf(FL_FOLDER_ELEMENT, escaped, perm,
atime, mtime, ctime);
} else if (S_ISREG(fstat->st_mode))
- ret = g_strdup_printf(FL_FILE_ELEMENT, escaped, fstat->st_size,
- perm, atime, mtime, ctime);
+ ret = g_strdup_printf(FL_FILE_ELEMENT, escaped,
+ (uint64_t) fstat->st_size,
+ perm, atime, mtime, ctime);
g_free(escaped);
diff --git a/src/obex-priv.h b/src/obex-priv.h
index c9be1c5..0806a56 100644
--- a/src/obex-priv.h
+++ b/src/obex-priv.h
@@ -33,9 +33,9 @@ struct obex_session {
char *path;
time_t time;
uint8_t *buf;
- int32_t pending;
- int32_t offset;
- int32_t size;
+ int64_t pending;
+ int64_t offset;
+ int64_t size;
void *object;
gboolean aborted;
struct obex_service_driver *service;
diff --git a/src/obex.c b/src/obex.c
index 6d4430d..effb81e 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -590,7 +590,8 @@ static int obex_read_stream(struct obex_session *os, obex_t *obex,
/* only write if both object and driver are valid */
if (os->object == NULL || os->driver == NULL) {
- DBG("Stored %u bytes into temporary buffer", os->pending);
+ DBG("Stored %" PRIu64 " bytes into temporary buffer",
+ os->pending);
return 0;
}
@@ -796,7 +797,7 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj)
if (err < 0)
goto done;
- if (os->size != OBJECT_SIZE_UNKNOWN) {
+ if (os->size != OBJECT_SIZE_UNKNOWN && os->size < UINT32_MAX) {
hd.bq4 = os->size;
OBEX_ObjectAddHeader(obex, obj,
OBEX_HDR_LENGTH, hd, 4, 0);
@@ -1005,7 +1006,7 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj)
case OBEX_HDR_LENGTH:
os->size = hd.bq4;
- DBG("OBEX_HDR_LENGTH: %d", os->size);
+ DBG("OBEX_HDR_LENGTH: %" PRIu64, os->size);
break;
case OBEX_HDR_TIME:
os->time = parse_iso8610((const char *) hd.bs, hlen);
--
1.7.1
^ permalink raw reply related
* [PATCH] Changed obex_service_driver put() signature.
From: Slawomir Bochenski @ 2010-12-08 14:50 UTC (permalink / raw)
To: linux-bluetooth
This API change is needed for implementing Message Access Profile, as
MAP uses application parameters in puts also (for example
SetMessageStatus function, see MAP specification, chapter 5.7) and in
order to access application parameters headers access to obex object
is required.
---
plugins/ftp.c | 3 ++-
plugins/opp.c | 3 ++-
plugins/syncevolution.c | 3 ++-
src/obex.c | 2 +-
src/service.h | 3 ++-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/plugins/ftp.c b/plugins/ftp.c
index 91c77a3..a952f64 100644
--- a/plugins/ftp.c
+++ b/plugins/ftp.c
@@ -258,7 +258,8 @@ static int ftp_chkput(struct obex_session *os,
void *user_data)
return ret;
}
-static int ftp_put(struct obex_session *os, void *user_data)
+static int ftp_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
struct ftp_session *ftp = user_data;
const char *name = obex_get_name(os);
diff --git a/plugins/opp.c b/plugins/opp.c
index 05f944f..17c4356 100644
--- a/plugins/opp.c
+++ b/plugins/opp.c
@@ -155,7 +155,8 @@ skip_auth:
return ret;
}
-static int opp_put(struct obex_session *os, void *user_data)
+static int opp_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
const char *name = obex_get_name(os);
const char *folder = obex_get_root_folder(os);
diff --git a/plugins/syncevolution.c b/plugins/syncevolution.c
index bf436a9..8041df6 100644
--- a/plugins/syncevolution.c
+++ b/plugins/syncevolution.c
@@ -243,7 +243,8 @@ failed:
return NULL;
}
-static int synce_put(struct obex_session *os, void *user_data)
+static int synce_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
return 0;
}
diff --git a/src/obex.c b/src/obex.c
index 6d4430d..1649cd0 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -1089,7 +1089,7 @@ static void cmd_put(struct obex_session *os,
obex_t *obex, obex_object_t *obj)
return;
}
- err = os->service->put(os, os->service_data);
+ err = os->service->put(os, obj, os->service_data);
if (err < 0)
os_set_response(obj, err);
}
diff --git a/src/service.h b/src/service.h
index 1726c43..a844885 100644
--- a/src/service.h
+++ b/src/service.h
@@ -34,7 +34,8 @@ struct obex_service_driver {
void (*progress) (struct obex_session *os, void *user_data);
int (*get) (struct obex_session *os, obex_object_t *obj,
gboolean *stream, void *user_data);
- int (*put) (struct obex_session *os, void *user_data);
+ int (*put) (struct obex_session *os, obex_object_t *obj,
+ void *user_data);
int (*chkput) (struct obex_session *os, void *user_data);
int (*setpath) (struct obex_session *os, obex_object_t *obj,
void *user_data);
--
Slawomir Bochenski
^ permalink raw reply related
* Re: [PATCH v2] Fix regression causing crash in 3-way calling
From: Johan Hedberg @ 2010-12-08 12:54 UTC (permalink / raw)
To: Dmitriy Paliy; +Cc: linux-bluetooth
In-Reply-To: <1291809471-806-2-git-send-email-dmitriy.paliy@nokia.com>
Hi Dmitriy,
On Wed, Dec 08, 2010, Dmitriy Paliy wrote:
> Fix obexd crash in 3-way calling scenario. Crash happens when there
> is redialed second incoming call. Cache for the PBAP session is
> already created at that moment, but PBAP object is destroyed. Crash
> happens when object is dereferenced in vobject_list_open.
>
> Therefore, PBAP object has to be created before any attempt to write
> cached data to buffer associated to this object.
>
> However, cache_ready_notify function, which is invoked in
> vobject_vcard_open for valid cache case, sends also PBAP object data
> via callback function to obex.c and written to OBEX stream as GET
> response in handle_async_io handler function.
>
> A new response is sent to OBEX stream after cache_ready_notify exists
> to vobject_list_open function, which is callback function for
> obex_mime_type_driver. Such leads to undefined befavior. Therefore,
> cache_ready_notify is splitted in two cache_ready_notify and
> generate_response functions.
>
> generate_response fills data to buffer and returns error, if any,
> while cache_ready_notify notifies OBEX core to write this data to
> stream.
>
> In order to avoid writing to stream twice, cache_ready_notify is
> replaced by generate_response in vobject_list_open. As a result,
> PBAP buffer data is generated from existing cache and sent to
> stream upon start of OBEX stream after vobject_list_open exits.
> ---
> plugins/pbap.c | 98 +++++++++++++++++++++++++++++++-------------------------
> 1 files changed, 54 insertions(+), 44 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 5/9] mfd: Add UART support for the ST-Ericsson CG2900.
From: Arnd Bergmann @ 2010-12-08 12:51 UTC (permalink / raw)
To: Par-Gunnar Hjalmdahl
Cc: Pavan Savoy, Vitaly Wool, Alan Cox, linus.walleij,
linux-bluetooth, linux-kernel, Marcel Holtmann
In-Reply-To: <AANLkTi=B4wT5SbN2qyyO5RZd7qMnkZXHpB6d=RTQeRtX@mail.gmail.com>
On Wednesday 08 December 2010, Par-Gunnar Hjalmdahl wrote:
> > Marcel did previously suggest a bus-driver sort of a structure, where
> > the transport are sort of adapter drivers, the data interpretation
> > logic like splitting HCI-events, FM CH-8 packets all fall into the
> > algos drivers and the actual Bluetooth driver or GPS or FM-V4L2
> > drivers falling into the client/protocol drivers....
>
> What the cg2900 driver has now turned into is almost like the
> cg2900_core acting as a bus, identifying which chip is connected and
> choosing correct chip driver from this. This cg2900_core module should
> not contain any vendor specific code. When identified, the chip driver
> then uses MFD to setup channels according to the functionality it
> supports (one MFD device per H4 channel). It's hard to explain
> everything of the new architecture here. I would like you to check the
> new patch set I'm trying hard to create at the moment. I will try to
> get it out on Friday, but it's hard to promise anything (there is a
> lot of work to do with it). There you could then see if it is
> something you could consider useful.
It sounds really good, I'm looking forward to your new patch set!
If it's generic enough to replace the ti-st code, that would be a
clear sign that you are on the right track ;-)
I'm not asking to fix their code yourself, but it might be good to
look at it and see if it would work.
Arnd
^ permalink raw reply
* Re: [PATCH 5/9] mfd: Add UART support for the ST-Ericsson CG2900.
From: Par-Gunnar Hjalmdahl @ 2010-12-08 12:21 UTC (permalink / raw)
To: Pavan Savoy
Cc: Arnd Bergmann, Vitaly Wool, Alan Cox, linus.walleij,
linux-bluetooth, linux-kernel, Marcel Holtmann
In-Reply-To: <AANLkTimCKK9NAiXD4wsCkJt8bsy_exYEBWdb1+M6+NOE@mail.gmail.com>
Hi Pavan et al,
2010/12/8 Pavan Savoy <pavan_savoy@sify.com>:
> On Tue, Dec 7, 2010 at 4:37 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Monday 06 December 2010 22:24:34 Vitaly Wool wrote:
>>> On Mon, Dec 6, 2010 at 5:54 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>>>
>>> >> But I was trying to make a different point here. On a basic level,
>>> >> there's this cg2000 chip from STE that does BT, FM and GPS. There's
>>> >> the chip from TI that does BT, FM and GPS, and there's the Broadcom
>>> >> chip that does BT+FM. They all use HCI to access the other functions
>>> >> of the combo chip and they do it in a really simiar way, with the
>>> >> differences mostly in power management techniques. So I think it's
>>> >> quite sensible to have some kind of framework that is suitable for
>>> >> such devices.
>>> >
>>> > Yes, I agree 100% in principle. I could not find the code that
>>> > Broadcom/TI FM and GPS stuff so far, can you point us to that?
>>>
>>> Sure, the TI "shared transport" code is mostly at drivers/misc/ti-st.
>>>
>>> Some Broadcom BCM43xx chips work in a similar way AFAIK but I'm not
>>> sure about the mainline support for those.
>>
>> Ah, it had not occured to me to look in drivers/misc. Looking at the
>> code over there, it becomes much clearer what your point is. Evidently
>> the ti-st driver implements a line discipline similar to, but conflictin=
g
>> with hci_ldisc, and it has its own copy of the hci_ll code.
>>
>> I guess this is exactly what we're trying to avoid having with the
>> cg2900 code ;-).
>>
>>> > The cg2900 solution for this was to use MFD (plus another layer
>>> > in the posted version, but that will go away I assume). Using
>>> > MFD is not the only possibility here, but I could not see anything
>>> > wrong with it either. Do you think we can move them all over to
>>> > use MFD infrastructure?
>>>
>>> I guess so but it's probably more of a detail than what I'm up to now :=
)
>>
>> Agreed.
>>
>>> >> But generally speaking, isn't a line discipline/driver attached to a
>>> >> tty? We can use dumb tty for e. g. SPI and still be able to use
>>> >> hci_ll, right?
>>> >
>>> > I suggested that as well, but the point was made that this would
>>> > add an unnecessary indirection for the SPI case, which is not
>>> > really much like a serial port. It's certainly possible to do it
>>> > like you say, but if we add a way to register the high-level
>>> > protocols with an HCI-like multi-function device, we could
>>> > also do it in a way that does not rely on tty-ldisc but keeps it
>>> > as one of the options.
>>>
>>> I actually don't think it's such a big indirection, I prefer to think
>>> of it more as of the abstraction layer. If not use this, are we going
>>> to have direct SPI device drivers? I'm afraid we might end up with a
>>> huge duplication of code in that case.
>>
>> The question is how it should be modeled in a better way than today.
>>
>> I believe we already agree it should be something like
>>
>> =A0 bt =A0 ti-radio =A0 =A0st-e-radio =A0 =A0ti-gps =A0 st-e-gps =A0broa=
dcom-radio ...
>> =A0 | =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0| =
=A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 |
>> =A0 +---------+----------+---------+--+----------+----------+---------+
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0common-hci-module
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+-----------+-----------+
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0| =A0 =A0 =
=A0 | =A0 =A0 =A0|
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0serial =A0 =A0spi =A0 =A0 i2c =A0=
=A0...
>
> Yes, this sort of architecture would certainly help...
> However, I suppose the most common question as one of you stated above
> was how can the channel -ID and other factors such as offset-header
> packet format be generalized?
>
> As in over here, will the common-hci-module work fine, If say ti-radio
> says he is expecting packets starting from id-8 which is of length 10?
> and also work for st-e-radio which would say expecting data from id-6
> with 15 max bytes?
> Answering this I suppose would solve a lot of our problems....
>
> Marcel did previously suggest a bus-driver sort of a structure, where
> the transport are sort of adapter drivers, the data interpretation
> logic like splitting HCI-events, FM CH-8 packets all fall into the
> algos drivers and the actual Bluetooth driver or GPS or FM-V4L2
> drivers falling into the client/protocol drivers....
>
What the cg2900 driver has now turned into is almost like the
cg2900_core acting as a bus, identifying which chip is connected and
choosing correct chip driver from this. This cg2900_core module should
not contain any vendor specific code. When identified, the chip driver
then uses MFD to setup channels according to the functionality it
supports (one MFD device per H4 channel). It's hard to explain
everything of the new architecture here. I would like you to check the
new patch set I'm trying hard to create at the moment. I will try to
get it out on Friday, but it's hard to promise anything (there is a
lot of work to do with it). There you could then see if it is
something you could consider useful.
/P-G
>
>
>> Any objections to this?
>>
>> If you agree, I think we should discuss the alternatives for the common
>> module. I think you are saying we should make the common module a single
>> ldisc doing the multiplexing and have all transports register as ttys in=
to
>> it, right?
>>
>> What we discussed before was to split it into multiple modules, one for
>> the tty ldisc and one for the common code, and then have the spi/i2c/...
>> drivers feed into the common multiplexer without going through tty.
>>
>> I don't currently see a significant advantage or disadvantage with eithe=
r
>> approach.
>>
>> =A0 =A0 =A0 =A0Arnd
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoot=
h" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
>>
>
^ permalink raw reply
* [PATCH v2] Fix regression causing crash in 3-way calling
From: Dmitriy Paliy @ 2010-12-08 11:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1291809471-806-1-git-send-email-dmitriy.paliy@nokia.com>
Fix obexd crash in 3-way calling scenario. Crash happens when there
is redialed second incoming call. Cache for the PBAP session is
already created at that moment, but PBAP object is destroyed. Crash
happens when object is dereferenced in vobject_list_open.
Therefore, PBAP object has to be created before any attempt to write
cached data to buffer associated to this object.
However, cache_ready_notify function, which is invoked in
vobject_vcard_open for valid cache case, sends also PBAP object data
via callback function to obex.c and written to OBEX stream as GET
response in handle_async_io handler function.
A new response is sent to OBEX stream after cache_ready_notify exists
to vobject_list_open function, which is callback function for
obex_mime_type_driver. Such leads to undefined befavior. Therefore,
cache_ready_notify is splitted in two cache_ready_notify and
generate_response functions.
generate_response fills data to buffer and returns error, if any,
while cache_ready_notify notifies OBEX core to write this data to
stream.
In order to avoid writing to stream twice, cache_ready_notify is
replaced by generate_response in vobject_list_open. As a result,
PBAP buffer data is generated from existing cache and sent to
stream upon start of OBEX stream after vobject_list_open exits.
---
plugins/pbap.c | 98 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 1a7d001..4086227 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -378,7 +378,7 @@ static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib,
return sorted;
}
-static void cache_ready_notify(void *user_data)
+static int generate_response(void *user_data)
{
struct pbap_session *pbap = user_data;
GSList *sorted;
@@ -398,7 +398,8 @@ static void cache_ready_notify(void *user_data)
memcpy(hdr->val, &size, sizeof(size));
pbap->obj->buffer = g_string_new_len(aparam, sizeof(aparam));
- goto done;
+
+ return 0;
}
/*
@@ -409,11 +410,8 @@ static void cache_ready_notify(void *user_data)
pbap->params->searchattrib,
(const char *) pbap->params->searchval);
- if (sorted == NULL) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT);
- return;
- }
+ if (sorted == NULL)
+ return -ENOENT;
/* Computing offset considering first entry of the phonebook */
l = g_slist_nth(sorted, pbap->params->liststartoffset);
@@ -430,11 +428,25 @@ static void cache_ready_notify(void *user_data)
g_slist_free(sorted);
-done:
- if (!pbap->cache.valid) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
+ return 0;
+}
+
+static void cache_ready_notify(void *user_data)
+{
+ struct pbap_session *pbap = user_data;
+ int err;
+
+ DBG("");
+
+ pbap->cache.valid = TRUE;
+
+ err = generate_response(pbap);
+ if (err < 0) {
+ obex_object_set_io_flags(pbap->obj, G_IO_ERR, err);
+ return;
}
+
+ obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
}
static void cache_entry_done(void *user_data)
@@ -746,10 +758,28 @@ fail:
return NULL;
}
+static int vobject_close(void *object)
+{
+ struct pbap_object *obj = object;
+
+ DBG("");
+
+ if (obj->session)
+ obj->session->obj = NULL;
+
+ if (obj->buffer)
+ g_string_free(obj->buffer, TRUE);
+
+ g_free(obj);
+
+ return 0;
+}
+
static void *vobject_list_open(const char *name, int oflag, mode_t mode,
void *context, size_t *size, int *err)
{
struct pbap_session *pbap = context;
+ struct pbap_object *obj = NULL;
int ret;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -766,30 +796,25 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
/* PullvCardListing always get the contacts from the cache */
- if (pbap->cache.valid) {
- /*
- * Valid cache and empty buffer mean that cache was already
- * created within a single session, but no data is available.
- */
- if (!pbap->obj->buffer) {
- ret = -ENOENT;
- goto fail;
- }
-
- cache_ready_notify(pbap);
- goto done;
- }
-
- ret = phonebook_create_cache(name,
- cache_entry_notify, cache_ready_notify, pbap);
+ obj = vobject_create(pbap);
+ if (pbap->cache.valid)
+ ret = generate_response(pbap);
+ else
+ ret = phonebook_create_cache(name, cache_entry_notify,
+ cache_ready_notify, pbap);
if (ret < 0)
goto fail;
-done:
- return vobject_create(pbap);
+ if (err)
+ *err = 0;
+
+ return obj;
fail:
+ if (obj)
+ vobject_close(obj);
+
if (err)
*err = ret;
@@ -902,21 +927,6 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count,
return string_read(obj->buffer, buf, count);
}
-static int vobject_close(void *object)
-{
- struct pbap_object *obj = object;
-
- if (obj->session)
- obj->session->obj = NULL;
-
- if (obj->buffer)
- g_string_free(obj->buffer, TRUE);
-
- g_free(obj);
-
- return 0;
-}
-
static struct obex_mime_type_driver mime_pull = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
--
1.7.0.4
^ permalink raw reply related
* [PATCH 0/1 v2] Fix regression causing crash in 3-way calling
From: Dmitriy Paliy @ 2010-12-08 11:57 UTC (permalink / raw)
To: linux-bluetooth
Hi,
More detailed commit message explaining the problem and
justification of changes, including refactoring of the code,
are written in this version of submitted earlier patch.
Also, label is removed in generate_response function.
Thanks,
Dmitriy
^ permalink raw reply
* [PATCH v2] Fix regression causing crash in 3-way calling
From: Dmitriy Paliy @ 2010-12-08 11:48 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1291808923-440-1-git-send-email-dmitriy.paliy@nokia.com>
Fix obexd crash in 3-way calling scenario. Crash happens when there
is redialed second incoming call. Cache for the PBAP session is
already created at that moment, but PBAP object is destroyed. Crash
happens when object is dereferenced in vobject_list_open.
Therefore, PBAP object has to be created before any attempt to write
cached data to buffer associated to this object.
However, cache_ready_notify function, which is invoked in
vobject_vcard_open for valid cache case, sends also PBAP object data
via callback function to obex.c and written to OBEX stream as GET
response in handle_async_io handler function.
A new response is sent to OBEX stream after cache_ready_notify exists
to vobject_list_open function, which is callback function for
obex_mime_type_driver. Such leads to undefined befavior. Therefore,
cache_ready_notify is splitted in two cache_ready_notify and
generate_response functions.
generate_response fills data to buffer and returns error, if any,
while cache_ready_notify notifies OBEX core to write this data to
stream.
In order to avoid writing to stream twice, cache_ready_notify is
replaced by generate_response in vobject_list_open. As a result,
PBAP buffer data is generated from existing cache and sent to
stream upon start of OBEX stream after vobject_list_open exits.
---
plugins/pbap.c | 98 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 1a7d001..4086227 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -378,7 +378,7 @@ static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib,
return sorted;
}
-static void cache_ready_notify(void *user_data)
+static int generate_response(void *user_data)
{
struct pbap_session *pbap = user_data;
GSList *sorted;
@@ -398,7 +398,8 @@ static void cache_ready_notify(void *user_data)
memcpy(hdr->val, &size, sizeof(size));
pbap->obj->buffer = g_string_new_len(aparam, sizeof(aparam));
- goto done;
+
+ return 0;
}
/*
@@ -409,11 +410,8 @@ static void cache_ready_notify(void *user_data)
pbap->params->searchattrib,
(const char *) pbap->params->searchval);
- if (sorted == NULL) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT);
- return;
- }
+ if (sorted == NULL)
+ return -ENOENT;
/* Computing offset considering first entry of the phonebook */
l = g_slist_nth(sorted, pbap->params->liststartoffset);
@@ -430,11 +428,25 @@ static void cache_ready_notify(void *user_data)
g_slist_free(sorted);
-done:
- if (!pbap->cache.valid) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
+ return 0;
+}
+
+static void cache_ready_notify(void *user_data)
+{
+ struct pbap_session *pbap = user_data;
+ int err;
+
+ DBG("");
+
+ pbap->cache.valid = TRUE;
+
+ err = generate_response(pbap);
+ if (err < 0) {
+ obex_object_set_io_flags(pbap->obj, G_IO_ERR, err);
+ return;
}
+
+ obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
}
static void cache_entry_done(void *user_data)
@@ -746,10 +758,28 @@ fail:
return NULL;
}
+static int vobject_close(void *object)
+{
+ struct pbap_object *obj = object;
+
+ DBG("");
+
+ if (obj->session)
+ obj->session->obj = NULL;
+
+ if (obj->buffer)
+ g_string_free(obj->buffer, TRUE);
+
+ g_free(obj);
+
+ return 0;
+}
+
static void *vobject_list_open(const char *name, int oflag, mode_t mode,
void *context, size_t *size, int *err)
{
struct pbap_session *pbap = context;
+ struct pbap_object *obj = NULL;
int ret;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -766,30 +796,25 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
/* PullvCardListing always get the contacts from the cache */
- if (pbap->cache.valid) {
- /*
- * Valid cache and empty buffer mean that cache was already
- * created within a single session, but no data is available.
- */
- if (!pbap->obj->buffer) {
- ret = -ENOENT;
- goto fail;
- }
-
- cache_ready_notify(pbap);
- goto done;
- }
-
- ret = phonebook_create_cache(name,
- cache_entry_notify, cache_ready_notify, pbap);
+ obj = vobject_create(pbap);
+ if (pbap->cache.valid)
+ ret = generate_response(pbap);
+ else
+ ret = phonebook_create_cache(name, cache_entry_notify,
+ cache_ready_notify, pbap);
if (ret < 0)
goto fail;
-done:
- return vobject_create(pbap);
+ if (err)
+ *err = 0;
+
+ return obj;
fail:
+ if (obj)
+ vobject_close(obj);
+
if (err)
*err = ret;
@@ -902,21 +927,6 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count,
return string_read(obj->buffer, buf, count);
}
-static int vobject_close(void *object)
-{
- struct pbap_object *obj = object;
-
- if (obj->session)
- obj->session->obj = NULL;
-
- if (obj->buffer)
- g_string_free(obj->buffer, TRUE);
-
- g_free(obj);
-
- return 0;
-}
-
static struct obex_mime_type_driver mime_pull = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
--
1.7.0.4
^ permalink raw reply related
* [PATCH 0/1 v2] Fix regression causing crash in 3-way calling
From: Dmitriy Paliy @ 2010-12-08 11:48 UTC (permalink / raw)
To: linux-bluetooth
Hi,
More detailed commit message explaining the problem and
justification of changes, including refactoring of the code,
are written in this version of submitted earlier patch.
Also, label is removed in generate_response function.
Thanks,
Dmitriy
^ permalink raw reply
* Re: [PATCH 1/1] bluetooth: Fix NULL pointer dereference issue
From: Yuri Ershov @ 2010-12-08 10:52 UTC (permalink / raw)
To: ext Gustavo F. Padovan
Cc: marcel, davem, jprvita, ville.tervo, andrei.emeltchenko,
linux-bluetooth@vger.kernel.org
In-Reply-To: <20101207155037.GA2944@vigoh>
[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]
Hi Gustavo,
ext Gustavo F. Padovan wrote:
> Hi Yuri,
>
> * Yuri Ershov <ext-yuri.ershov@nokia.com> [2010-12-07 16:12:00 +0300]:
>
>
>> Hello Gustavo,
>>
>> ext Gustavo F. Padovan wrote:
>>
>>> Hi Yuri,
>>>
>>> * Yuri Ershov <ext-yuri.ershov@nokia.com> [2010-11-25 12:55:33 +0300]:
>>>
>>>
>>>
>>>> This patch is an addition to my previous patch for this issue.
>>>> The problem is in resynchronization between two loops:
>>>> 1. Main controlling loop (l2cap_connect_req, l2cap_config_req,
>>>> l2cap_config_rsp, l2cap_disconnect_req, etc.)
>>>> 2. Loop waiting of BT_CONNECTED state of socket (l2cap_sock_accept,
>>>> bt_accept_dequeue, etc.).
>>>> In case of fast sequence of connect/disconnect operations the loop #1
>>>> makes several cycles, while the loop #2 only has time to make one
>>>> cycle and it results crash.
>>>> The aim of the patch is to skeep handling of sockets queued for
>>>> deletion.
>>>>
>>>> Signed-off-by: Yuri Ershov <ext-yuri.ershov@nokia.com>
>>>> ---
>>>> net/bluetooth/af_bluetooth.c | 2 ++
>>>> net/bluetooth/l2cap.c | 6 ++++--
>>>> 2 files changed, 6 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
>>>> index c4cf3f5..f9389da 100644
>>>> --- a/net/bluetooth/af_bluetooth.c
>>>> +++ b/net/bluetooth/af_bluetooth.c
>>>> @@ -200,6 +200,8 @@ struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
>>>> BT_DBG("parent %p", parent);
>>>>
>>>> list_for_each_safe(p, n, &bt_sk(parent)->accept_q) {
>>>> + if (n == p)
>>>> + break;
>>>>
>>>>
>>> So in which situations (n == p), or (p == p->next)? That should happen only
>>> when p is the only element in the list, then p == head, right?
>>>
>>>
>> The (n == p) is in situation, when sk is unlinked by task responsible
>> for handling connect/disconnect requests while the "bt_accept_dequeue".
>> This condition is indirect checking of sk validity.
>>
>
> Why not using a list lock here instead? Fits a way better.
>
>
Yes, it's better. I tried to use the locks in this function, but it
slows down the task handling connect/disconnect/etc. events and the task
skips some events from fast clients.
[-- Attachment #2: Type: text/html, Size: 2898 bytes --]
^ permalink raw reply
* [PATCH] Fix regression causing crash in 3-way calling
From: Dmitriy Paliy @ 2010-12-08 10:04 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
Fix possible obexd crash in 3-way calling scenario. Callback
function cache_ready_notify is splitted in two cache_ready_notify
and generate_response functions.
generate_response fills data to buffer and returns error, if any.
---
plugins/pbap.c | 94 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 1a7d001..83c8ff4 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -378,7 +378,7 @@ static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib,
return sorted;
}
-static void cache_ready_notify(void *user_data)
+static int generate_response(void *user_data)
{
struct pbap_session *pbap = user_data;
GSList *sorted;
@@ -409,11 +409,8 @@ static void cache_ready_notify(void *user_data)
pbap->params->searchattrib,
(const char *) pbap->params->searchval);
- if (sorted == NULL) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT);
- return;
- }
+ if (sorted == NULL)
+ return -ENOENT;
/* Computing offset considering first entry of the phonebook */
l = g_slist_nth(sorted, pbap->params->liststartoffset);
@@ -431,10 +428,25 @@ static void cache_ready_notify(void *user_data)
g_slist_free(sorted);
done:
- if (!pbap->cache.valid) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
+ return 0;
+}
+
+static void cache_ready_notify(void *user_data)
+{
+ struct pbap_session *pbap = user_data;
+ int err;
+
+ DBG("");
+
+ pbap->cache.valid = TRUE;
+
+ err = generate_response(pbap);
+ if (err < 0) {
+ obex_object_set_io_flags(pbap->obj, G_IO_ERR, err);
+ return;
}
+
+ obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
}
static void cache_entry_done(void *user_data)
@@ -746,10 +758,28 @@ fail:
return NULL;
}
+static int vobject_close(void *object)
+{
+ struct pbap_object *obj = object;
+
+ DBG("");
+
+ if (obj->session)
+ obj->session->obj = NULL;
+
+ if (obj->buffer)
+ g_string_free(obj->buffer, TRUE);
+
+ g_free(obj);
+
+ return 0;
+}
+
static void *vobject_list_open(const char *name, int oflag, mode_t mode,
void *context, size_t *size, int *err)
{
struct pbap_session *pbap = context;
+ struct pbap_object *obj = NULL;
int ret;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -766,30 +796,25 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
/* PullvCardListing always get the contacts from the cache */
- if (pbap->cache.valid) {
- /*
- * Valid cache and empty buffer mean that cache was already
- * created within a single session, but no data is available.
- */
- if (!pbap->obj->buffer) {
- ret = -ENOENT;
- goto fail;
- }
-
- cache_ready_notify(pbap);
- goto done;
- }
-
- ret = phonebook_create_cache(name,
- cache_entry_notify, cache_ready_notify, pbap);
+ obj = vobject_create(pbap);
+ if (pbap->cache.valid)
+ ret = generate_response(pbap);
+ else
+ ret = phonebook_create_cache(name, cache_entry_notify,
+ cache_ready_notify, pbap);
if (ret < 0)
goto fail;
-done:
- return vobject_create(pbap);
+ if (err)
+ *err = 0;
+
+ return obj;
fail:
+ if (obj)
+ vobject_close(obj);
+
if (err)
*err = ret;
@@ -902,21 +927,6 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count,
return string_read(obj->buffer, buf, count);
}
-static int vobject_close(void *object)
-{
- struct pbap_object *obj = object;
-
- if (obj->session)
- obj->session->obj = NULL;
-
- if (obj->buffer)
- g_string_free(obj->buffer, TRUE);
-
- g_free(obj);
-
- return 0;
-}
-
static struct obex_mime_type_driver mime_pull = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
--
1.7.0.4
^ permalink raw reply related
* LE Slave
From: Koustuv Ghosh @ 2010-12-08 8:19 UTC (permalink / raw)
To: linux-bluetooth
Hello ,
dose anybody know whether any commercial LE slave(core 4.0 compatible)
is available where slave side Security Manager Protocol is up and
running?
rgds
Koustuv
^ 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