* [RFC v1 obexd 04/11] fuse: Add request helpers and setpath operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 856e1d5..1b8082f 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -273,3 +273,111 @@ void gobexhlp_disconnect(struct gobexhlp_session* session)
g_free(session);
}
+
+void request_new(struct gobexhlp_session *session,
+ gchar *name)
+{
+ g_print("REQUEST %s\n", name);
+
+ if (session->request != NULL)
+ g_error("Another request (%s) active!\n",
+ session->request->name);
+
+ session->status = 0;
+ session->request = g_malloc0(sizeof(struct gobexhlp_request));
+ session->request->name = name;
+
+ /*
+ * suspend/resume operations recreates g_io_add_watch(),
+ * it fixes obex->io freeze during transfer
+ */
+ g_obex_suspend(session->obex);
+ g_obex_resume(session->obex);
+}
+
+void request_wait_free(struct gobexhlp_session *session)
+{
+ g_print("WAIT for %s\n", session->request->name);
+
+ g_obex_suspend(session->obex);
+ g_obex_resume(session->obex);
+
+ if (session->err != NULL) {
+ g_print("ERROR: %s (%d)\n", session->err->message,
+ session->err->code);
+ g_error_free(session->err);
+ raise(SIGTERM);
+ return;
+ }
+
+ g_mutex_lock(gobexhlp_mutex);
+
+ while (session->request->complete != TRUE)
+ g_cond_wait(gobexhlp_cond, gobexhlp_mutex);
+
+ g_mutex_unlock(gobexhlp_mutex);
+
+ g_free(session->request->name);
+ g_free(session->request);
+ session->request = NULL;
+}
+
+static void complete_func(GObex *obex, GError *err,
+ gpointer user_data)
+{
+ struct gobexhlp_session *session = user_data;
+
+ if (err != NULL) {
+ g_print("ERROR: %s\n", err->message);
+ session->status = -ECANCELED;
+ g_error_free(err);
+ } else {
+ g_print("COMPLETE %s\n", session->request->name);
+ }
+
+ g_mutex_lock(gobexhlp_mutex);
+ session->request->complete = TRUE;
+ g_cond_signal(gobexhlp_cond);
+ g_mutex_unlock(gobexhlp_mutex);
+}
+
+static void response_func(GObex *obex, GError *err, GObexPacket *rsp,
+ gpointer user_data)
+{
+ complete_func(obex, err, user_data);
+}
+
+void gobexhlp_setpath(struct gobexhlp_session *session, const char *path)
+{
+ guint i = 0, split = 0;
+ gchar **path_v;
+ gsize len;
+
+ g_print("gobexhlp_setpath(%s)\n", path);
+
+ if (g_str_has_prefix(path, session->setpath)) {
+ split = strlen(session->setpath);
+ } else {
+ request_new(session, g_strdup_printf("setpath root"));
+ g_obex_setpath(session->obex, "", response_func,
+ session, &session->err);
+ request_wait_free(session);
+ }
+
+ path_v = g_strsplit(path+split, "/", -1);
+ len = g_strv_length(path_v);
+
+ for (i = 0; i < len; i++)
+ if (path_v[i][0] != '\0') {
+ request_new(session,
+ g_strdup_printf("setpath %s", path_v[i]));
+ g_obex_setpath(session->obex, path_v[i],
+ response_func, session, &session->err);
+ request_wait_free(session);
+ }
+
+ g_free(session->setpath);
+ session->setpath = g_strdup(path);
+
+ g_strfreev(path_v);
+}
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 05/11] fuse: Add readdir operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
fuse/helpers.h | 2 +
fuse/obexfuse.c | 23 ++++++++++
3 files changed, 154 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 1b8082f..1d3faa5 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -381,3 +381,132 @@ void gobexhlp_setpath(struct gobexhlp_session *session, const char *path)
g_strfreev(path_v);
}
+
+static void listfolder_xml_element(GMarkupParseContext *ctxt,
+ const gchar *element, const gchar **names,
+ const gchar **values, gpointer user_data,
+ GError **gerr)
+{
+ gchar *key, *pathname, *name = NULL;
+ struct gobexhlp_session *session = user_data;
+ struct stat *stbuf;
+ gint i = 0;
+
+ stbuf = g_malloc0(sizeof(struct stat));
+
+ if ((strcasecmp("file", element) == 0)) {
+ stbuf->st_mode = S_IFREG;
+ } else if ((strcasecmp("folder", element)) == 0) {
+ stbuf->st_mode = S_IFDIR;
+ stbuf->st_mtime = time(NULL);
+ } else {
+ g_free(stbuf);
+ return;
+ }
+
+ for (key = (gchar *) names[i]; key; key = (gchar *) names[++i]) {
+ if (g_str_equal("name", key) == TRUE) {
+ session->lsfiles = g_list_append(session->lsfiles,
+ g_strdup(values[i]));
+ name = g_strdup(values[i]);
+
+ } else if (g_str_equal("size", key) == TRUE) {
+ guint64 size;
+ size = g_ascii_strtoll(values[i], NULL, 10);
+ stbuf->st_size = size;
+
+ } else if (g_str_equal("created", key) == TRUE) {
+ GTimeVal time;
+ GDateTime *datetime;
+ g_time_val_from_iso8601(values[i], &time);
+ datetime = g_date_time_new_from_timeval_utc(&time);
+ stbuf->st_mtime = g_date_time_to_unix(datetime);
+ }
+ }
+
+ if (g_str_equal("/", session->setpath) == TRUE)
+ pathname = g_strdup_printf("/%s", name);
+ else
+ pathname = g_strdup_printf("%s/%s", session->setpath, name);
+
+ g_hash_table_replace(session->file_stat, pathname, stbuf);
+ g_free(name);
+}
+
+static const GMarkupParser parser = {
+ listfolder_xml_element,
+ NULL, NULL, NULL, NULL
+};
+
+static void complete_listfolder_func(GObex *obex, GError *err,
+ gpointer user_data)
+{
+ GMarkupParseContext *ctxt;
+ struct gobexhlp_session *session = user_data;
+ struct gobexhlp_buffer *buffer = session->buffer;
+
+ if (err == NULL) {
+ ctxt = g_markup_parse_context_new(&parser, 0, session, NULL);
+ g_markup_parse_context_parse(ctxt, buffer->data, buffer->size,
+ NULL);
+ g_markup_parse_context_free(ctxt);
+ }
+
+ complete_func(obex, err, user_data);
+}
+
+static gboolean async_get_consumer(const void *buf, gsize len,
+ gpointer user_data)
+{
+ struct gobexhlp_session *session = user_data;
+ struct gobexhlp_buffer *buffer = session->buffer;
+
+ if (buffer->size == 0)
+ buffer->data = g_malloc0(sizeof(char) * len);
+ else
+ buffer->data = g_realloc(buffer->data, buffer->size + len);
+
+ memcpy(buffer->data + buffer->size, buf, len);
+ buffer->size += len;
+
+ g_obex_suspend(session->obex);
+ g_obex_resume(session->obex);
+
+ return TRUE;
+}
+
+GList *gobexhlp_listfolder(struct gobexhlp_session* session,
+ const char *path)
+{
+ struct gobexhlp_buffer *buffer;
+ GObexPacket *req;
+ guint reqpkt;
+
+ gobexhlp_setpath(session, path);
+
+ g_print("gobexhlp_listfolder(%s)\n", path);
+
+ if (session->lsfiles != NULL) {
+ g_list_free_full(session->lsfiles, g_free);
+ session->lsfiles = NULL;
+ }
+
+ session->lsfiles = g_list_alloc();
+ buffer = g_malloc0(sizeof(struct gobexhlp_buffer));
+ session->buffer = buffer;
+
+ request_new(session, g_strdup_printf("listfolder %s", path));
+ req = g_obex_packet_new(G_OBEX_OP_GET, TRUE, G_OBEX_HDR_INVALID);
+ g_obex_packet_add_bytes(req, G_OBEX_HDR_TYPE, OBEX_FTP_LS,
+ strlen(OBEX_FTP_LS) + 1);
+ reqpkt = g_obex_get_req_pkt(session->obex, req,
+ async_get_consumer,
+ complete_listfolder_func,
+ session, &session->err);
+ request_wait_free(session);
+ g_free(buffer->data);
+ g_free(buffer);
+
+ return session->lsfiles;
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index f1d787b..84238c9 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -51,4 +51,6 @@ struct gobexhlp_session* gobexhlp_connect(const char *srcstr,
const char *dstsrc);
void gobexhlp_disconnect(struct gobexhlp_session* session);
+GList *gobexhlp_listfolder(struct gobexhlp_session* session, const char *path);
+
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index 79eb990..5de82ec 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -89,7 +89,30 @@ void obexfuse_destroy()
g_thread_join(main_gthread);
}
+static int obexfuse_readdir(const char *path, void *buf,
+ fuse_fill_dir_t filler, off_t offset,
+ struct fuse_file_info *fi)
+{
+ int len, i;
+ gchar *string;
+ GList *files;
+
+ filler(buf, ".", NULL, 0);
+ filler(buf, "..", NULL, 0);
+
+ files = gobexhlp_listfolder(session, path);
+ len = g_list_length(files);
+
+ for (i = 1; i < len; i++) { /* element for i==0 is NULL */
+ string = g_list_nth_data(files, i);
+ filler(buf, string, NULL, 0);
+ }
+
+ return session->status;
+}
+
static struct fuse_operations obexfuse_oper = {
+ .readdir = obexfuse_readdir,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 06/11] fuse: Add getattr operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 6 ++++++
fuse/helpers.h | 2 ++
fuse/obexfuse.c | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 1d3faa5..249d0c9 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -510,3 +510,9 @@ GList *gobexhlp_listfolder(struct gobexhlp_session* session,
return session->lsfiles;
}
+struct stat *gobexhlp_getattr(struct gobexhlp_session* session,
+ const char *path)
+{
+ return g_hash_table_lookup(session->file_stat, path);
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index 84238c9..0a0f366 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -52,5 +52,7 @@ struct gobexhlp_session* gobexhlp_connect(const char *srcstr,
void gobexhlp_disconnect(struct gobexhlp_session* session);
GList *gobexhlp_listfolder(struct gobexhlp_session* session, const char *path);
+struct stat *gobexhlp_getattr(struct gobexhlp_session* session,
+ const char *path);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index 5de82ec..f4e85fa 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -111,8 +111,42 @@ static int obexfuse_readdir(const char *path, void *buf,
return session->status;
}
+static int obexfuse_getattr(const char *path, struct stat *stbuf)
+{
+ int res = 0;
+ struct stat *stfile;
+
+ memset(stbuf, 0, sizeof(struct stat));
+
+ if (strcmp(path, "/") == 0) {
+ stbuf->st_mode = S_IFDIR | 0755;
+ stbuf->st_nlink = 2;
+ } else {
+ stfile = gobexhlp_getattr(session, path);
+
+ if (stfile == NULL)
+ return -ENOENT;
+
+ if (stfile->st_mode == S_IFREG)
+ stbuf->st_mode = stfile->st_mode | 0666;
+ else /* S_IFDIR */
+ stbuf->st_mode = stfile->st_mode | 0755;
+
+ stbuf->st_nlink = 1;
+ stbuf->st_size = stfile->st_size;
+ stbuf->st_mtime = stbuf->st_atime = stbuf->st_ctime =
+ stfile->st_mtime;
+ stbuf->st_blksize = 512;
+ stbuf->st_blocks = (stbuf->st_size + stbuf->st_blksize)
+ / stbuf->st_blksize;
+ }
+
+ return res;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
+ .getattr = obexfuse_getattr,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 07/11] fuse: Add open and read operations plus location helpers
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
fuse/helpers.h | 3 +-
fuse/obexfuse.c | 32 ++++++++++++++++++++++++++++
3 files changed, 95 insertions(+), 1 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 249d0c9..9b453e0 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -516,3 +516,64 @@ struct stat *gobexhlp_getattr(struct gobexhlp_session* session,
return g_hash_table_lookup(session->file_stat, path);
}
+static struct gobexhlp_location *get_location(const char *path)
+{
+ struct gobexhlp_location *location;
+ gchar **directories;
+ guint i, len, fid = 0;
+
+ location = g_malloc0(sizeof(*location));
+ directories = g_strsplit(path, "/", -1);
+ len = g_strv_length(directories);
+
+ for (i = 0; i < len; i++)
+ if (directories[i][0] != '\0') /* protect multi slashes */
+ fid = i; /* last nonempty is a file */
+
+ location->file = g_strdup(directories[fid]);
+ directories[fid][0] = '\0'; /* remove file */
+ location->dir = g_strjoinv("/", directories);
+
+ g_strfreev(directories);
+
+ return location;
+}
+
+void free_location(struct gobexhlp_location *location)
+{
+ g_free(location->file);
+ g_free(location->dir);
+ g_free(location);
+}
+
+struct gobexhlp_buffer *gobexhlp_get(struct gobexhlp_session* session,
+ const char *path)
+{
+ struct gobexhlp_location *l;
+ struct gobexhlp_buffer *buffer;
+ struct stat *stfile;
+ l = get_location(path);
+
+ g_print("gobexhlp_get(%s%s)\n", l->dir, l->file);
+
+ stfile = gobexhlp_getattr(session, path);
+ if (stfile == NULL)
+ return NULL;
+
+ buffer = g_malloc0(sizeof(*buffer));
+
+ if (stfile->st_size == 0)
+ return buffer;
+
+ gobexhlp_setpath(session, l->dir);
+ request_new(session, g_strdup_printf("get %s", path));
+ session->buffer = buffer;
+ g_obex_get_req(session->obex, async_get_consumer,
+ complete_func, session, &session->err,
+ G_OBEX_HDR_NAME, l->file,
+ G_OBEX_HDR_INVALID);
+ free_location(l);
+ request_wait_free(session);
+
+ return buffer;
+}
diff --git a/fuse/helpers.h b/fuse/helpers.h
index 0a0f366..50c750d 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -54,5 +54,6 @@ void gobexhlp_disconnect(struct gobexhlp_session* session);
GList *gobexhlp_listfolder(struct gobexhlp_session* session, const char *path);
struct stat *gobexhlp_getattr(struct gobexhlp_session* session,
const char *path);
-
+struct gobexhlp_buffer *gobexhlp_get(struct gobexhlp_session* session,
+ const char *path);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index f4e85fa..9fe2dea 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -144,9 +144,41 @@ static int obexfuse_getattr(const char *path, struct stat *stbuf)
return res;
}
+static int obexfuse_open(const char *path, struct fuse_file_info *fi)
+{
+ struct gobexhlp_buffer *file_buffer;
+
+ file_buffer = gobexhlp_get(session, path);
+
+ if (file_buffer == NULL)
+ return -ENOENT;
+
+ fi->fh = (uint64_t)file_buffer;
+
+ return session->status;
+}
+
+static int obexfuse_read(const char *path, char *buf, size_t size,
+ off_t offset, struct fuse_file_info *fi)
+{
+ gsize asize;
+ struct gobexhlp_buffer *file_buffer = (struct gobexhlp_buffer*)fi->fh;
+
+ asize = file_buffer->size - offset;
+
+ if (asize > size)
+ asize = size;
+
+ memcpy(buf, file_buffer->data + offset, asize);
+
+ return asize;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
.getattr = obexfuse_getattr,
+ .open = obexfuse_open,
+ .read = obexfuse_read,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 08/11] fuse: Add write operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
fuse/helpers.h | 3 +++
fuse/obexfuse.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 9b453e0..b807f15 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -577,3 +577,48 @@ struct gobexhlp_buffer *gobexhlp_get(struct gobexhlp_session* session,
return buffer;
}
+
+static gssize async_put_producer(void *buf, gsize len, gpointer user_data)
+{
+ gssize size;
+ struct gobexhlp_session *session = user_data;
+ struct gobexhlp_buffer *buffer = session->buffer;
+
+ size = buffer->size - buffer->tmpsize;
+
+ if (size > len)
+ size = len;
+
+ g_obex_suspend(session->obex);
+ g_obex_resume(session->obex);
+
+ if (size == 0)
+ return 0;
+
+ memcpy(buf, buffer->data + buffer->tmpsize, size);
+ buffer->tmpsize += size;
+
+ return size;
+}
+
+void gobexhlp_put(struct gobexhlp_session* session,
+ struct gobexhlp_buffer *buffer,
+ const char *path)
+{
+ struct gobexhlp_location *l;
+ l = get_location(path);
+
+ g_print("gobexhlp_put(%s%s)\n", l->dir, l->file);
+
+ gobexhlp_setpath(session, l->dir);
+ buffer->tmpsize = 0;
+ session->buffer = buffer;
+ request_new(session, g_strdup_printf("put %s", path));
+ g_obex_put_req(session->obex, async_put_producer,
+ complete_func, session, &session->err,
+ G_OBEX_HDR_NAME, l->file,
+ G_OBEX_HDR_INVALID);
+ free_location(l);
+ request_wait_free(session);
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index 50c750d..95987c4 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -56,4 +56,7 @@ struct stat *gobexhlp_getattr(struct gobexhlp_session* session,
const char *path);
struct gobexhlp_buffer *gobexhlp_get(struct gobexhlp_session* session,
const char *path);
+void gobexhlp_put(struct gobexhlp_session* session,
+ struct gobexhlp_buffer *buffer,
+ const char *path);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index 9fe2dea..900e6d7 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -174,11 +174,55 @@ static int obexfuse_read(const char *path, char *buf, size_t size,
return asize;
}
+static int obexfuse_write(const char *path, const char *buf, size_t size,
+ off_t offset, struct fuse_file_info *fi)
+{
+ gsize nsize;
+ struct gobexhlp_buffer *file_buffer = (struct gobexhlp_buffer*)fi->fh;
+
+ if (file_buffer->size < offset + size) {
+ nsize = offset + size;
+ file_buffer->data = g_realloc(file_buffer->data, nsize);
+ file_buffer->size = nsize;
+ } else {
+ nsize = file_buffer->size;
+ }
+
+ file_buffer->edited = TRUE;
+ memcpy(file_buffer->data + offset, buf, size);
+
+ return size;
+}
+
+static int obexfuse_truncate(const char *path, off_t offset)
+{
+ /*
+ * Allow to change the size of a file.
+ */
+ return 0;
+}
+
+static int obexfuse_release(const char *path, struct fuse_file_info *fi)
+{
+ struct gobexhlp_buffer *file_buffer = (struct gobexhlp_buffer*)fi->fh;
+
+ if (file_buffer->edited == TRUE)
+ gobexhlp_put(session, file_buffer, path); /* send to device */
+
+ g_free(file_buffer->data);
+ g_free(file_buffer);
+
+ return session->status;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
.getattr = obexfuse_getattr,
.open = obexfuse_open,
.read = obexfuse_read,
+ .write = obexfuse_write,
+ .truncate = obexfuse_truncate,
+ .release = obexfuse_release,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 09/11] fuse: Add touch operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 40 ++++++++++++++++++++++++++++++++++++++++
fuse/helpers.h | 1 +
fuse/obexfuse.c | 17 +++++++++++++++++
3 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index b807f15..05948be 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -56,6 +56,8 @@ struct gobexhlp_location {
gchar *file;
};
+void gobexhlp_touch_real(struct gobexhlp_session* session, gchar *path);
+
static uint16_t find_rfcomm_uuid(void *user_data)
{
sdp_list_t *pds = (sdp_list_t*) user_data;
@@ -279,6 +281,12 @@ void request_new(struct gobexhlp_session *session,
{
g_print("REQUEST %s\n", name);
+ if (session->vtouch == TRUE) {
+ session->vtouch = FALSE;
+ gobexhlp_touch_real(session, session->vtouch_path);
+ g_free(session->vtouch_path);
+ }
+
if (session->request != NULL)
g_error("Another request (%s) active!\n",
session->request->name);
@@ -622,3 +630,35 @@ void gobexhlp_put(struct gobexhlp_session* session,
request_wait_free(session);
}
+/* virtual file creation */
+void gobexhlp_touch(struct gobexhlp_session* session, const char *path)
+{
+ struct stat *stbuf;
+
+ g_print("gobexhlp_touch(%s)\n", path);
+
+ stbuf = g_malloc0(sizeof(struct stat));
+ stbuf->st_mode = S_IFREG;
+ g_hash_table_replace(session->file_stat, g_strdup(path), stbuf);
+
+ session->vtouch = TRUE;
+ session->vtouch_path = g_strdup(path);
+}
+
+void gobexhlp_touch_real(struct gobexhlp_session* session, gchar *path)
+{
+ struct gobexhlp_buffer *buffer, *tmpbuf;
+
+ g_print("gobexhlp_touch_real(%s)\n", path);
+
+ tmpbuf = session->buffer; /* save buffer state */
+
+ buffer = g_malloc0(sizeof(struct gobexhlp_buffer));
+ session->rtouch = TRUE;
+ gobexhlp_put(session, buffer, path);
+ session->rtouch = FALSE;
+ g_free(buffer);
+
+ session->buffer = tmpbuf;
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index 95987c4..da5f96c 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -59,4 +59,5 @@ struct gobexhlp_buffer *gobexhlp_get(struct gobexhlp_session* session,
void gobexhlp_put(struct gobexhlp_session* session,
struct gobexhlp_buffer *buffer,
const char *path);
+void gobexhlp_touch(struct gobexhlp_session* session, const char *path);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index 900e6d7..b4599d8 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -215,6 +215,21 @@ static int obexfuse_release(const char *path, struct fuse_file_info *fi)
return session->status;
}
+static int obexfuse_utimens(const char *path, const struct timespec tv[2])
+{
+ /*
+ * Important for mknod (touch) operation
+ */
+ return 0;
+}
+
+static int obexfuse_mknod(const char *path, mode_t mode, dev_t dev)
+{
+ gobexhlp_touch(session, path);
+
+ return 0;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
.getattr = obexfuse_getattr,
@@ -223,6 +238,8 @@ static struct fuse_operations obexfuse_oper = {
.write = obexfuse_write,
.truncate = obexfuse_truncate,
.release = obexfuse_release,
+ .utimens = obexfuse_utimens,
+ .mknod = obexfuse_mknod,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 10/11] fuse: Add unlink/rmdir operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 28 ++++++++++++++++++++++++++++
fuse/helpers.h | 1 +
fuse/obexfuse.c | 9 +++++++++
3 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 05948be..0ad8cbb 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -618,6 +618,16 @@ void gobexhlp_put(struct gobexhlp_session* session,
g_print("gobexhlp_put(%s%s)\n", l->dir, l->file);
+ if (g_strcmp0(path, session->vtouch_path) == 0 &&
+ session->vtouch == TRUE) {
+ session->vtouch = FALSE;
+ g_free(session->vtouch_path);
+ } else {
+ /* delete existing file */
+ if (session->rtouch == FALSE)
+ gobexhlp_delete(session, path);
+ }
+
gobexhlp_setpath(session, l->dir);
buffer->tmpsize = 0;
session->buffer = buffer;
@@ -662,3 +672,21 @@ void gobexhlp_touch_real(struct gobexhlp_session* session, gchar *path)
session->buffer = tmpbuf;
}
+void gobexhlp_delete(struct gobexhlp_session* session, const char *path)
+{
+ struct gobexhlp_location *l;
+ l = get_location(path);
+
+ g_print("gobexhlp_delete(%s)\n", l->file);
+
+ gobexhlp_setpath(session, l->dir);
+ request_new(session, g_strdup_printf("delete %s", path));
+ g_obex_delete(session->obex, l->file, response_func, session,
+ &session->err);
+
+ g_hash_table_remove(session->file_stat, path);
+
+ free_location(l);
+ request_wait_free(session);
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index da5f96c..baa6bf1 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -60,4 +60,5 @@ void gobexhlp_put(struct gobexhlp_session* session,
struct gobexhlp_buffer *buffer,
const char *path);
void gobexhlp_touch(struct gobexhlp_session* session, const char *path);
+void gobexhlp_delete(struct gobexhlp_session* session, const char *path);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index b4599d8..2a6ee11 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -230,6 +230,13 @@ static int obexfuse_mknod(const char *path, mode_t mode, dev_t dev)
return 0;
}
+static int obexfuse_unlink(const char *path)
+{
+ gobexhlp_delete(session, path);
+
+ return session->status;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
.getattr = obexfuse_getattr,
@@ -240,6 +247,8 @@ static struct fuse_operations obexfuse_oper = {
.release = obexfuse_release,
.utimens = obexfuse_utimens,
.mknod = obexfuse_mknod,
+ .unlink = obexfuse_unlink,
+ .rmdir = obexfuse_unlink,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* [RFC v1 obexd 11/11] fuse: Add rename operation
From: Michał Poczwardowski @ 2012-10-21 17:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michał Poczwardowski
In-Reply-To: <1350839131-12042-1-git-send-email-dmp0x7c5@gmail.com>
---
fuse/helpers.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
fuse/helpers.h | 3 +++
fuse/obexfuse.c | 16 ++++++++++++++++
3 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/fuse/helpers.c b/fuse/helpers.c
index 0ad8cbb..698781a 100644
--- a/fuse/helpers.c
+++ b/fuse/helpers.c
@@ -690,3 +690,49 @@ void gobexhlp_delete(struct gobexhlp_session* session, const char *path)
request_wait_free(session);
}
+void gobexhlp_mkdir(struct gobexhlp_session* session, const char *path)
+{
+ struct gobexhlp_location *l;
+ struct stat *stbuf;
+
+ g_print("gobexhlp_mkdir(%s)\n", path);
+
+ l = get_location(path);
+ gobexhlp_setpath(session, l->dir);
+
+ request_new(session, g_strdup_printf("mkdir %s", path));
+ /* g_obex_mkdir also sets path, to new folder */
+ g_obex_mkdir(session->obex, l->file, response_func, session,
+ &session->err);
+ g_free(session->setpath);
+ session->setpath = g_strdup(path);
+
+ stbuf = g_malloc0(sizeof(struct stat));
+ stbuf->st_mode = S_IFDIR;
+ stbuf->st_mtime = time(NULL);
+ g_hash_table_replace(session->file_stat, g_strdup(path), stbuf);
+
+ free_location(l);
+ request_wait_free(session);
+}
+
+void gobexhlp_move(struct gobexhlp_session* session, const char *oldpath,
+ const char* newpath)
+{
+ struct gobexhlp_location *l_from, *l_to;
+
+ l_to = get_location(newpath);
+ l_from = get_location(oldpath);
+ gobexhlp_setpath(session, l_from->dir);
+
+ g_print("gobexhlp_move(%s to %s)\n", l_from->file, l_to->file);
+
+ request_new(session, g_strdup_printf("move %s:%s",
+ oldpath, newpath));
+ g_obex_move(session->obex, l_from->file, l_to->file, response_func,
+ session, &session->err);
+ free_location(l_to);
+ free_location(l_from);
+ request_wait_free(session);
+}
+
diff --git a/fuse/helpers.h b/fuse/helpers.h
index baa6bf1..cc2d9a8 100644
--- a/fuse/helpers.h
+++ b/fuse/helpers.h
@@ -61,4 +61,7 @@ void gobexhlp_put(struct gobexhlp_session* session,
const char *path);
void gobexhlp_touch(struct gobexhlp_session* session, const char *path);
void gobexhlp_delete(struct gobexhlp_session* session, const char *path);
+void gobexhlp_mkdir(struct gobexhlp_session* session, const char *path);
+void gobexhlp_move(struct gobexhlp_session* session, const char *oldpath,
+ const char* newpath);
diff --git a/fuse/obexfuse.c b/fuse/obexfuse.c
index 2a6ee11..f9f9d0e 100644
--- a/fuse/obexfuse.c
+++ b/fuse/obexfuse.c
@@ -237,6 +237,20 @@ static int obexfuse_unlink(const char *path)
return session->status;
}
+static int obexfuse_mkdir(const char *path, mode_t mode)
+{
+ gobexhlp_mkdir(session, path);
+
+ return session->status;
+}
+
+static int obexfuse_rename(const char *from, const char *to)
+{
+ gobexhlp_move(session, from, to);
+
+ return session->status;
+}
+
static struct fuse_operations obexfuse_oper = {
.readdir = obexfuse_readdir,
.getattr = obexfuse_getattr,
@@ -249,6 +263,8 @@ static struct fuse_operations obexfuse_oper = {
.mknod = obexfuse_mknod,
.unlink = obexfuse_unlink,
.rmdir = obexfuse_unlink,
+ .mkdir = obexfuse_mkdir,
+ .rename = obexfuse_rename,
.init = obexfuse_init,
.destroy = obexfuse_destroy,
};
--
1.7.8.6
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Add support for Atheros [04ca:3004]
From: Julian Calaby @ 2012-10-22 5:26 UTC (permalink / raw)
To: Dwaine Garden VE3GIF
Cc: linville@redhat.com, linux-wireless@vger.kernel.org,
mcgrof@qca.qualcomm.com, linux-bluetooth, gustavo
In-Reply-To: <1350882145.55725.YahooMailNeo@web125403.mail.ne1.yahoo.com>
Hi Dwaine,
Firstly, you should really send this to the linux-bluetooth list and
Gustavo not to linux-wireless and John.
While linux-wireless is the catch-all place for everything relating to
wireless technology in Linux, bluetooth has it's own mailing list, and
bluetooth patches should be sent there first.
On Mon, Oct 22, 2012 at 4:02 PM, Dwaine Garden VE3GIF
<dwainegarden@rogers.com> wrote:
>
>
> Add another vendor specific ID for Atheros AR3012 device.
> This chip is wrapped by Lite-On Technology Corp.
>
> output of usb-devices:
> Bus 001 Device 008: ID 04ca:3004 Lite-On Technology Corp.
> Device Descriptor:
> bLength 18
>
> bDescriptorType 1
> bcdUSB 1.10
> bDeviceClass 224 Wireless
> bDeviceSubClass 1 Radio Frequency
> bDeviceProtocol 1 Bluetooth
> bMaxPacketSize0 64
> idVendor 0x04ca Lite-On Technology Corp.
> idProduct 0x3004
> bcdDevice 0.02
> iManufacturer 1 Atheros Communications
>
> iProduct 2 Bluetooth USB Host Controller
> iSerial 3 Alaska Day 2006
> bNumConfigurations 1
>
>
> Signed-off-by: Dwaine Garden <DwaineGarden@rogers.com> ---
Secondly, while your patch looks correct to me (I'm no expert on the
hardware or drivers involved) it seems to be severely whitespace
damaged. You should read the Email Clients document under the
Documentation directory in your kernel tree (or read it online here:
http://stuff.mit.edu/afs/sipb/contrib/linux/Documentation/email-clients.txt
) and ensure that your email client is set up correctly to send
patches without damaging them.
> diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
> index fc2de55..1486f15 100644
> --- a/drivers/bluetooth/ath3k.c
> +++ b/drivers/bluetooth/ath3k.c
> @@ -75,6 +75,7 @@ static struct usb_device_id ath3k_table[] = {
> { USB_DEVICE(0x0CF3, 0x3004) },
> { USB_DEVICE(0x0CF3, 0x311D) },
> { USB_DEVICE(0x13d3, 0x3375) },
> + { USB_DEVICE(0x04CA, 0x3004) },
> { USB_DEVICE(0x04CA, 0x3005) },
> { USB_DEVICE(0x13d3, 0x3362) },
> { USB_DEVICE(0x0CF3, 0xE004) },
> @@ -102,6 +103,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
> { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
> + { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
> {
> USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index debda27..0529cee 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -132,6 +132,7 @@ static struct usb_device_id blacklist_table[] = {
> { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
> + { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
> { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
.Plan: http://sites.google.com/site/juliancalaby/
^ permalink raw reply
* [PATCH bluez] wiimote: add Wii-Remote-Plus ID and name detection
From: David Herrmann @ 2012-10-22 8:31 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Johan Hedberg, Peter Olson, David Herrmann
The Nintendo Wii Remote Plus uses a new product ID and name. To detect
them properly, we need to add them to the wiimote-module.
To avoid an overlong "if" statement, this converts the match-function to
walk over an array and check all VID/PID pairs and device-names. This
makes adding new devices much easier.
---
Hi Johan
I am actually not sure why Nintendo changed the VID/PID for the new revisions of
the WiimotePlus. I have a WiimotePlus which still uses the old numbers and works
here quite well. However, I have now got multiple requests from people with the
new device name and IDs. Unfortunately, I cannot test these so I'd like to have
a "Tested-by" by Peter (CC'ed) before this is applied.
Thanks
David
plugins/wiimote.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/plugins/wiimote.c b/plugins/wiimote.c
index 5708bf8..f506ed6 100644
--- a/plugins/wiimote.c
+++ b/plugins/wiimote.c
@@ -2,7 +2,7 @@
*
* BlueZ - Bluetooth protocol stack for Linux
*
- * Copyright (C) 2011 David Herrmann <dh.herrmann@googlemail.com>
+ * Copyright (C) 2011-2012 David Herrmann <dh.herrmann@googlemail.com>
*
*
* This program is free software; you can redistribute it and/or modify
@@ -58,11 +58,23 @@
* is pressed.
*/
+static uint16_t wii_ids[][2] = {
+ { 0x057e, 0x0306 },
+ { 0x057e, 0x0330 },
+};
+
+static const char *wii_names[] = {
+ "Nintendo RVL-CNT-01",
+ "Nintendo RVL-CNT-01-TR",
+ "Nintendo RVL-WBC-01",
+};
+
static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
char *pinbuf, gboolean *display)
{
uint16_t vendor, product;
char addr[18], name[25];
+ unsigned int i, len;
ba2str(device_get_address(device), addr);
@@ -72,15 +84,24 @@ static ssize_t wii_pincb(struct btd_adapter *adapter, struct btd_device *device,
device_get_name(device, name, sizeof(name));
name[sizeof(name) - 1] = 0;
- if (g_str_equal(name, "Nintendo RVL-CNT-01") ||
- g_str_equal(name, "Nintendo RVL-WBC-01") ||
- (vendor == 0x057e && product == 0x0306)) {
- DBG("Forcing fixed pin on detected wiimote %s", addr);
- memcpy(pinbuf, adapter_get_address(adapter), 6);
- return 6;
+ len = sizeof(wii_ids) / sizeof(wii_ids[0]);
+ for (i = 0; i < len; ++i) {
+ if (vendor == wii_ids[i][0] && product == wii_ids[i][1])
+ goto found;
+ }
+
+ len = sizeof(wii_names) / sizeof(wii_names[0]);
+ for (i = 0; i < len; ++i) {
+ if (g_str_equal(name, wii_names[i]))
+ goto found;
}
return 0;
+
+found:
+ DBG("Forcing fixed pin on detected wiimote %s", addr);
+ memcpy(pinbuf, adapter_get_address(adapter), 6);
+ return 6;
}
static int wii_probe(struct btd_adapter *adapter)
--
1.7.12.4
^ permalink raw reply related
* Re: [PATCH 1/5 v2] Bluetooth: Add initial support for LE-only controllers
From: Andrei Emeltchenko @ 2012-10-22 10:08 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1350669469-7719-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
On Fri, Oct 19, 2012 at 08:57:45PM +0300, Johan Hedberg wrote:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> This patch splits off most the HCI init sequence commands from a fixed
> set into a conditional one that is sent once the HCI_Read_Local_Features
> and HCI_Read_Local_Version_Information commands complete. This is
> necessary since many of the current fixed commands are not allowed for
> LE-only controllers.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/hci_core.c | 47 ------------------------------------
> net/bluetooth/hci_event.c | 58 +++++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 53 insertions(+), 52 deletions(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 0ec776a..dd05ed0 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -178,48 +178,13 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
>
> static void bredr_init(struct hci_dev *hdev)
> {
> - struct hci_cp_delete_stored_link_key cp;
> - __le16 param;
> - __u8 flt_type;
> -
...
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 0383635..f4f0b8b 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
...
> +static void bredr_init(struct hci_dev *hdev)
> +{
Is this a good idea to have two functions with the same names? Even static
ones.
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCH 1/5 v2] Bluetooth: Add initial support for LE-only controllers
From: Johan Hedberg @ 2012-10-22 10:13 UTC (permalink / raw)
To: Andrei Emeltchenko, linux-bluetooth
In-Reply-To: <20121022100845.GA14263@aemeltch-MOBL1>
Hi Andrei,
On Mon, Oct 22, 2012, Andrei Emeltchenko wrote:
> > --- a/net/bluetooth/hci_core.c
> > +++ b/net/bluetooth/hci_core.c
> > @@ -178,48 +178,13 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
> >
> > static void bredr_init(struct hci_dev *hdev)
> > {
> > - struct hci_cp_delete_stored_link_key cp;
> > - __le16 param;
> > - __u8 flt_type;
> > -
>
> ...
>
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 0383635..f4f0b8b 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
>
> ...
>
> > +static void bredr_init(struct hci_dev *hdev)
> > +{
>
> Is this a good idea to have two functions with the same names? Even static
> ones.
Another option would have been to call this bredr_setup since it's the
hci_setup function that calls it. Anyway, I'll wait for feedback from
Gustavo to see if he cares.
Johan
^ permalink raw reply
* [PATCH RESEND net-next] bluetooth: hci_core: Replace list_for_each with list_for_each_entry() helper
From: Denis Kirjanov @ 2012-10-22 13:22 UTC (permalink / raw)
To: davem; +Cc: linux-bluetooth, netdev, linux-kernel, Denis Kirjanov
Replace list_for_each with list_for_each_entry() helper
Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
---
include/net/bluetooth/hci_core.h | 20 ++++++++------------
1 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 475b8c0..fcf839f 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -852,7 +852,7 @@ struct hci_cb {
static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
{
- struct list_head *p;
+ struct hci_cb *cb;
__u8 encrypt;
hci_proto_auth_cfm(conn, status);
@@ -863,8 +863,7 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00;
read_lock(&hci_cb_list_lock);
- list_for_each(p, &hci_cb_list) {
- struct hci_cb *cb = list_entry(p, struct hci_cb, list);
+ list_for_each_entry(cb, &hci_cb_list, list) {
if (cb->security_cfm)
cb->security_cfm(conn, status, encrypt);
}
@@ -874,7 +873,7 @@ static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status)
static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
__u8 encrypt)
{
- struct list_head *p;
+ struct hci_cb *cb;
if (conn->sec_level == BT_SECURITY_SDP)
conn->sec_level = BT_SECURITY_LOW;
@@ -885,8 +884,7 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
hci_proto_encrypt_cfm(conn, status, encrypt);
read_lock(&hci_cb_list_lock);
- list_for_each(p, &hci_cb_list) {
- struct hci_cb *cb = list_entry(p, struct hci_cb, list);
+ list_for_each_entry(cb, &hci_cb_list, list) {
if (cb->security_cfm)
cb->security_cfm(conn, status, encrypt);
}
@@ -895,11 +893,10 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status,
static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status)
{
- struct list_head *p;
+ struct hci_cb *cb;
read_lock(&hci_cb_list_lock);
- list_for_each(p, &hci_cb_list) {
- struct hci_cb *cb = list_entry(p, struct hci_cb, list);
+ list_for_each_entry(cb, &hci_cb_list, list) {
if (cb->key_change_cfm)
cb->key_change_cfm(conn, status);
}
@@ -909,11 +906,10 @@ static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status)
static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status,
__u8 role)
{
- struct list_head *p;
+ struct hci_cb *cb;
read_lock(&hci_cb_list_lock);
- list_for_each(p, &hci_cb_list) {
- struct hci_cb *cb = list_entry(p, struct hci_cb, list);
+ list_for_each_entry(cb, &hci_cb_list, list) {
if (cb->role_switch_cfm)
cb->role_switch_cfm(conn, status, role);
}
--
1.7.1
^ permalink raw reply related
* Re: [PATCH RESEND net-next] bluetooth: hci_core: Replace list_for_each with list_for_each_entry() helper
From: Marcel Holtmann @ 2012-10-22 17:00 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: davem, linux-bluetooth, netdev, linux-kernel
In-Reply-To: <1350912121-24171-1-git-send-email-kirjanov@gmail.com>
Hi Denis,
> Replace list_for_each with list_for_each_entry() helper
>
> Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
> ---
> include/net/bluetooth/hci_core.h | 20 ++++++++------------
> 1 files changed, 8 insertions(+), 12 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* [PATCH] doc: media API doco proofraeding.
From: Michael Knudsen @ 2012-10-23 12:02 UTC (permalink / raw)
To: linux-bluetooth
---
doc/media-api.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/doc/media-api.txt b/doc/media-api.txt
index b9802d9..d15d22a 100644
--- a/doc/media-api.txt
+++ b/doc/media-api.txt
@@ -48,7 +48,7 @@ Methods void RegisterEndpoint(object endpoint, dict properties)
dict metadata)
Register a media player object to sender, the sender
- can register as many objets as it likes.
+ can register as many objects as it likes.
Note: If the sender disconnects its objects are
automatically unregistered.
--
1.7.0.4
^ permalink raw reply related
* [PATCH] Bluetooth: Add support for Atheros [04ca:3004]
From: Dwaine Garden VE3GIF @ 2012-10-23 12:31 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Add another vendor specific ID for Atheros AR3012 device.
This chip is wrapped by Lite-On Technology Corp.
output of usb-devices:
Bus 001 Device 008: ID 04ca:3004 Lite-On Technology Corp.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 224 Wireless
bDeviceSubClass 1 Radio Frequency
bDeviceProtocol 1 Bluetooth
bMaxPacketSize0 64
idVendor 0x04ca Lite-On Technology Corp.
idProduct 0x3004
bcdDevice 0.02
iManufacturer 1 Atheros Communications
iProduct 2 Bluetooth USB Host Controller
iSerial 3 Alaska Day 2006
bNumConfigurations 1
Signed-off-by: Dwaine Garden <DwaineGarden@rogers.com> ---
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index fc2de55..1486f15 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -75,6 +75,7 @@ static struct usb_device_id ath3k_table[] = {
{ USB_DEVICE(0x0CF3, 0x3004) },
{ USB_DEVICE(0x0CF3, 0x311D) },
{ USB_DEVICE(0x13d3, 0x3375) },
+ { USB_DEVICE(0x04CA, 0x3004) },
{ USB_DEVICE(0x04CA, 0x3005) },
{ USB_DEVICE(0x13d3, 0x3362) },
{ USB_DEVICE(0x0CF3, 0xE004) },
@@ -102,6 +103,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
+ { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x3005), .driver_info =
BTUSB_ATH3012 },
{
USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index debda27..0529cee 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -132,6 +132,7 @@ static struct usb_device_id blacklist_table[] = {
{ USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 },
+ { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
{ USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
^ permalink raw reply related
* Re: [PATCH] doc: media API doco proofraeding.
From: Johan Hedberg @ 2012-10-23 12:36 UTC (permalink / raw)
To: Michael Knudsen; +Cc: linux-bluetooth
In-Reply-To: <50868762.4010501@samsung.com>
Hi Michael,
On Tue, Oct 23, 2012, Michael Knudsen wrote:
> ---
> doc/media-api.txt | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH BlueZ v2] AVDTP: Do not keep a internal reference
From: Ludek Finstrle @ 2012-10-23 13:16 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1350640763-24186-1-git-send-email-luiz.dentz@gmail.com>
Hello Luiz,
finally I find some time and find the reason (change).
I also see one strange thing in the patch.
Fri, Oct 19, 2012 at 12:59:23PM +0300, Luiz Augusto von Dentz napsal(a):
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Don't initialize reference with 1, instead always start disconnect timer
> when reference drops to 0, so in case nobody reclaims the session it
> automatically disconnect after 1 second and frees the memory.
> ---
> v2: Fix with stream_setup flag being ignored in disconnect_timeout
>
> audio/avdtp.c | 217 +++++++++++++++++++++++++---------------------------------
> 1 file changed, 94 insertions(+), 123 deletions(-)
>
> diff --git a/audio/avdtp.c b/audio/avdtp.c
> index bd91cb6..bca4809 100644
> --- a/audio/avdtp.c
> +++ b/audio/avdtp.c
> @@ -387,8 +387,7 @@ struct avdtp_stream {
> /* Structure describing an AVDTP connection between two devices */
>
> struct avdtp {
> - int ref;
> - int free_lock;
> + unsigned int ref;
>
> uint16_t version;
>
> @@ -657,50 +656,6 @@ static gboolean stream_open_timeout(gpointer user_data)
> return FALSE;
> }
>
> -static gboolean disconnect_timeout(gpointer user_data)
> -{
> - struct avdtp *session = user_data;
> - struct audio_device *dev;
> - gboolean stream_setup;
> -
> - session->dc_timer = 0;
> - stream_setup = session->stream_setup;
> - session->stream_setup = FALSE;
> -
> - dev = manager_get_device(&session->server->src, &session->dst, FALSE);
> -
> - if (dev && dev->sink && stream_setup)
> - sink_setup_stream(dev->sink, session);
> - else if (dev && dev->source && stream_setup)
> - source_setup_stream(dev->source, session);
> - else
> - connection_lost(session, ETIMEDOUT);
> -
> - return FALSE;
> -}
> -
> -static void remove_disconnect_timer(struct avdtp *session)
> -{
> - g_source_remove(session->dc_timer);
> - session->dc_timer = 0;
> - session->stream_setup = FALSE;
> -}
> -
> -static void set_disconnect_timer(struct avdtp *session)
> -{
> - if (session->dc_timer)
> - remove_disconnect_timer(session);
> -
> - if (session->device_disconnect) {
> - session->dc_timer = g_idle_add(disconnect_timeout, session);
> - return;
> - }
> -
> - session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
> - disconnect_timeout,
> - session);
> -}
> -
> void avdtp_error_init(struct avdtp_error *err, uint8_t category, int id)
> {
> err->category = category;
> @@ -780,8 +735,9 @@ static void avdtp_set_state(struct avdtp *session,
> }
> }
>
> -static void stream_free(struct avdtp_stream *stream)
> +static void stream_free(void *data)
> {
> + struct avdtp_stream *stream = data;
> struct avdtp_remote_sep *rsep;
>
> stream->lsep->info.inuse = 0;
> @@ -1144,37 +1100,42 @@ static int avdtp_cancel_authorization(struct avdtp *session)
> return err;
>
> session->auth_id = 0;
> + avdtp_unref(session);
>
> return 0;
> }
>
> -static void connection_lost(struct avdtp *session, int err)
> +static void sep_free(gpointer data)
> {
> - char address[18];
> + struct avdtp_remote_sep *sep = data;
>
> - ba2str(&session->dst, address);
> - DBG("Disconnected from %s", address);
> + g_slist_free_full(sep->caps, g_free);
> + g_free(sep);
> +}
>
> - if (err != EACCES)
> - avdtp_cancel_authorization(session);
> +static void remove_disconnect_timer(struct avdtp *session)
> +{
> + g_source_remove(session->dc_timer);
> + session->dc_timer = 0;
> + session->stream_setup = FALSE;
> +}
>
> - session->free_lock = 1;
> +static void avdtp_free(void *data)
> +{
> + struct avdtp *session = data;
>
> - finalize_discovery(session, err);
> + DBG("%p", session);
>
> - g_slist_foreach(session->streams, (GFunc) release_stream, session);
> - session->streams = NULL;
> + g_slist_free_full(session->streams, stream_free);
>
> - session->free_lock = 0;
> + if (session->state != AVDTP_SESSION_STATE_DISCONNECTED)
> + avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
>
> if (session->io) {
> g_io_channel_shutdown(session->io, FALSE, NULL);
> g_io_channel_unref(session->io);
> - session->io = NULL;
> }
>
> - avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
> -
> if (session->io_id) {
> g_source_remove(session->io_id);
> session->io_id = 0;
> @@ -1183,69 +1144,92 @@ static void connection_lost(struct avdtp *session, int err)
> if (session->dc_timer)
> remove_disconnect_timer(session);
>
> - if (session->ref != 1)
> - error("connection_lost: ref count not 1 after all callbacks");
> - else
> - avdtp_unref(session);
> + avdtp_cancel_authorization(session);
Why do you call avdtp_cancel_authorization here? It's useless as above you have
in the same function:
if (session->state != AVDTP_SESSION_STATE_DISCONNECTED)
avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
and the first if statement inf avdtp_cancel_authorization is to check if the
state is AVDTP_SESSION_STATE_CONNECTING (otherwise return).
> +
> + if (session->req)
> + pending_req_free(session->req);
> +
> + g_slist_free_full(session->seps, sep_free);
> +
> + g_free(session->buf);
> +
> + g_free(session);
> }
>
> -static void sep_free(gpointer data)
> +static gboolean disconnect_timeout(gpointer user_data)
> {
> - struct avdtp_remote_sep *sep = data;
> + struct avdtp *session = user_data;
> + struct audio_device *dev;
> + gboolean stream_setup;
>
> - g_slist_free_full(sep->caps, g_free);
> - g_free(sep);
> + session->dc_timer = 0;
> +
> + stream_setup = session->stream_setup;
> + session->stream_setup = FALSE;
> + dev = manager_get_device(&session->server->src, &session->dst, FALSE);
> +
> + if (dev && dev->sink && stream_setup)
> + sink_setup_stream(dev->sink, session);
> + else if (dev && dev->source && stream_setup)
> + source_setup_stream(dev->source, session);
See below. Why you deinitialize the session different way for ref=0?
> + else if (session->ref > 0)
> + connection_lost(session, ETIMEDOUT);
> + else {
> + struct avdtp_server *server = session->server;
> +
> + server->sessions = g_slist_remove(server->sessions, session);
> + avdtp_free(session);
> + }
If I change whole block above (starting else if ((session->ref > 0)) this
way it works with N900 as expected:
else {
connection_lost(session, ETIMEDOUT);
if (session->ref <= 0) {
struct avdtp_server *server = session->server;
server->sessions = g_slist_remove(server->sessions, session);
avdtp_free(session);
}
}
> +
> + return FALSE;
> }
>
> -void avdtp_unref(struct avdtp *session)
> +static void set_disconnect_timer(struct avdtp *session)
> {
> - struct avdtp_server *server;
> + if (session->dc_timer)
> + remove_disconnect_timer(session);
>
> - if (!session)
> + if (session->device_disconnect) {
> + session->dc_timer = g_idle_add(disconnect_timeout, session);
> return;
> + }
>
> - session->ref--;
> -
> - DBG("%p: ref=%d", session, session->ref);
> + session->dc_timer = g_timeout_add_seconds(DISCONNECT_TIMEOUT,
> + disconnect_timeout,
> + session);
> +}
>
> - if (session->ref == 1) {
> - if (session->state == AVDTP_SESSION_STATE_CONNECTING &&
> - session->io) {
> - avdtp_cancel_authorization(session);
> - g_io_channel_shutdown(session->io, TRUE, NULL);
> - g_io_channel_unref(session->io);
> - session->io = NULL;
> - avdtp_set_state(session,
> - AVDTP_SESSION_STATE_DISCONNECTED);
> - }
> +static void connection_lost(struct avdtp *session, int err)
> +{
> + char address[18];
>
> - if (session->io)
> - set_disconnect_timer(session);
> - else if (!session->free_lock) /* Drop the local ref if we
> - aren't connected */
> - session->ref--;
> - }
> + ba2str(&session->dst, address);
> + DBG("Disconnected from %s", address);
>
> - if (session->ref > 0)
> - return;
> + if (err != EACCES)
> + avdtp_cancel_authorization(session);
>
> - server = session->server;
> + g_slist_foreach(session->streams, (GFunc) release_stream, session);
> + session->streams = NULL;
>
> - DBG("%p: freeing session and removing from list", session);
> + finalize_discovery(session, err);
>
> - if (session->dc_timer)
> - remove_disconnect_timer(session);
> + avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
> +}
>
> - server->sessions = g_slist_remove(server->sessions, session);
> +void avdtp_unref(struct avdtp *session)
> +{
> + if (!session)
> + return;
>
> - if (session->req)
> - pending_req_free(session->req);
> + session->ref--;
>
> - g_slist_free_full(session->seps, sep_free);
> + DBG("%p: ref=%d", session, session->ref);
>
> - g_free(session->buf);
> + if (session->ref > 0)
> + return;
>
> - g_free(session);
> + set_disconnect_timer(session);
> }
>
> struct avdtp *avdtp_ref(struct avdtp *session)
> @@ -2231,12 +2215,6 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond,
> goto failed;
> }
>
> - if (session->ref == 1 && !session->streams && !session->req)
> - set_disconnect_timer(session);
> -
> - if (session->streams && session->dc_timer)
> - remove_disconnect_timer(session);
> -
> if (session->req && session->req->collided) {
> DBG("Collision detected");
> goto next;
> @@ -2383,7 +2361,7 @@ static struct avdtp *avdtp_get_internal(const bdaddr_t *src, const bdaddr_t *dst
>
> session->server = server;
> bacpy(&session->dst, dst);
> - session->ref = 1;
> + set_disconnect_timer(session);
> /* We don't use avdtp_set_state() here since this isn't a state change
> * but just setting of the initial state */
> session->state = AVDTP_SESSION_STATE_DISCONNECTED;
> @@ -2490,6 +2468,8 @@ static void auth_cb(DBusError *derr, void *user_data)
> struct avdtp *session = user_data;
> GError *err = NULL;
>
> + avdtp_unref(session);
> +
> if (derr && dbus_error_is_set(derr)) {
> error("Access denied: %s", derr->message);
> connection_lost(session, EACCES);
> @@ -2578,10 +2558,12 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
> auth_cb, session);
> if (session->auth_id == 0) {
> avdtp_set_state(session, AVDTP_SESSION_STATE_DISCONNECTED);
> - avdtp_unref(session);
> goto drop;
> }
>
> + /* Disable disconnect timer while authorizing */
> + avdtp_ref(session);
> +
> dev->auto_connect = auto_connect;
>
> return;
> @@ -3949,23 +3931,12 @@ proceed:
> void avdtp_exit(const bdaddr_t *src)
> {
> struct avdtp_server *server;
> - GSList *l;
>
> server = find_server(servers, src);
> if (!server)
> return;
>
> - l = server->sessions;
> - while (l) {
> - struct avdtp *session = l->data;
> -
> - l = l->next;
> - /* value of l pointer should be updated before invoking
> - * connection_lost since it internally uses avdtp_unref
> - * which operates on server->session list as well
> - */
> - connection_lost(session, -ECONNABORTED);
> - }
> + g_slist_free_full(server->sessions, avdtp_free);
>
> servers = g_slist_remove(servers, server);
>
> --
> 1.7.11.4
My fix should be wrong as I don't fully understand why it fixed my problem
but I think it's not ok to deinitialize it different way based on some counter.
I know you don't support N900 with bluez 4.99 with a lot of fixes from upstream
and pulseaudio 0.9.15 hacked by Nokia but I think this should be general problem.
Best regards,
Luf
^ permalink raw reply
* [PATCH 1/5] Bluetooth: trivial: Remove newline before EOF
From: Syam Sidhardhan @ 2012-10-23 13:32 UTC (permalink / raw)
To: linux-bluetooth
Trivial fix.
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
net/bluetooth/Kconfig | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig
index 1c11d0d..d3f3f7b 100644
--- a/net/bluetooth/Kconfig
+++ b/net/bluetooth/Kconfig
@@ -48,4 +48,3 @@ source "net/bluetooth/cmtp/Kconfig"
source "net/bluetooth/hidp/Kconfig"
source "drivers/bluetooth/Kconfig"
-
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/5] Bluetooth: Remove unnecessary include export.h
From: Syam Sidhardhan @ 2012-10-23 13:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1350999140-7481-1-git-send-email-s.syam@samsung.com>
For files only using THIS_MODULE and/or EXPORT_SYMBOL, map
them onto including export.h -- or if the file isn't even
using those, then just delete the include.
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
net/bluetooth/bnep/netdev.c | 1 -
net/bluetooth/hci_event.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index 98f86f9..e58c8b3 100644
--- a/net/bluetooth/bnep/netdev.c
+++ b/net/bluetooth/bnep/netdev.c
@@ -25,7 +25,6 @@
SOFTWARE IS DISCLAIMED.
*/
-#include <linux/export.h>
#include <linux/etherdevice.h>
#include <net/bluetooth/bluetooth.h>
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 82e478a..110006a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -24,7 +24,6 @@
/* Bluetooth HCI event handling. */
-#include <linux/export.h>
#include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h>
--
1.7.9.5
^ permalink raw reply related
* [PATCH 3/5] Bluetooth: Replace include linux/module.h with linux/export.h
From: Syam Sidhardhan @ 2012-10-23 13:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1350999140-7481-1-git-send-email-s.syam@samsung.com>
include <linux/export.h> is the right to go here.
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
net/bluetooth/cmtp/capi.c | 2 +-
net/bluetooth/cmtp/sock.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 50f0d13..a4a9d4b 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -20,7 +20,7 @@
SOFTWARE IS DISCLAIMED.
*/
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/types.h>
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index d5cacef..ea0e813 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -20,7 +20,7 @@
SOFTWARE IS DISCLAIMED.
*/
-#include <linux/module.h>
+#include <linux/export.h>
#include <linux/types.h>
#include <linux/capability.h>
--
1.7.9.5
^ permalink raw reply related
* [PATCH 4/5] Bluetooth: mgmt: Use __constant when dealing with constants
From: Syam Sidhardhan @ 2012-10-23 13:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1350999140-7481-1-git-send-email-s.syam@samsung.com>
__constant_cpu_to_le*() is the right go here.
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
net/bluetooth/mgmt.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b127b88..e3bb2a7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -222,7 +222,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status)
hdr = (void *) skb_put(skb, sizeof(*hdr));
- hdr->opcode = cpu_to_le16(MGMT_EV_CMD_STATUS);
+ hdr->opcode = __constant_cpu_to_le16(MGMT_EV_CMD_STATUS);
hdr->index = cpu_to_le16(index);
hdr->len = cpu_to_le16(sizeof(*ev));
@@ -253,7 +253,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status,
hdr = (void *) skb_put(skb, sizeof(*hdr));
- hdr->opcode = cpu_to_le16(MGMT_EV_CMD_COMPLETE);
+ hdr->opcode = __constant_cpu_to_le16(MGMT_EV_CMD_COMPLETE);
hdr->index = cpu_to_le16(index);
hdr->len = cpu_to_le16(sizeof(*ev) + rp_len);
@@ -832,7 +832,7 @@ static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, u16 data_len,
if (hdev)
hdr->index = cpu_to_le16(hdev->id);
else
- hdr->index = cpu_to_le16(MGMT_INDEX_NONE);
+ hdr->index = __constant_cpu_to_le16(MGMT_INDEX_NONE);
hdr->len = cpu_to_le16(data_len);
if (data)
@@ -3570,9 +3570,11 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
ev->addr.type = link_to_bdaddr(link_type, addr_type);
ev->rssi = rssi;
if (cfm_name)
- ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_CONFIRM_NAME);
+ ev->flags |=
+ __constant_cpu_to_le32(MGMT_DEV_FOUND_CONFIRM_NAME);
if (!ssp)
- ev->flags |= cpu_to_le32(MGMT_DEV_FOUND_LEGACY_PAIRING);
+ ev->flags |=
+ __constant_cpu_to_le32(MGMT_DEV_FOUND_LEGACY_PAIRING);
if (eir_len > 0)
memcpy(ev->eir, eir, eir_len);
--
1.7.9.5
^ permalink raw reply related
* [PATCH v1 5/5] Bluetooth: Fix L2CAP dynamic PSM bind issue
From: Syam Sidhardhan @ 2012-10-23 13:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1350999140-7481-1-git-send-email-s.syam@samsung.com>
Dynamic PSM choosen by the kernel should bound to either BDADDR_ANY
or the same adapter address(not both) for a particular adapter.
The problem here is by giving PSM 0, the kernel should return the first
available PSM in the non-reserverd space, but since we reuse the same
code to do the matching it end up given both Obexd and HDP the same
PSM.
Provid a helper function to handle the dymanic PSM auto selection.
Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
---
net/bluetooth/l2cap_core.c | 55 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 46 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d42cdb1..33b5d34 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -119,6 +119,43 @@ static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src)
return NULL;
}
+/* Returns free dynamic PSM */
+static u16 __l2cap_global_get_dyna_chan_by_addr(bdaddr_t *src)
+{
+ struct l2cap_chan *c;
+ u16 p;
+ bool found;
+
+ for (p = 0x1001; p < 0x1100; p += 2) {
+ found = false;
+
+ list_for_each_entry(c, &chan_list, global_l) {
+ if (c->sport != p)
+ continue;
+
+ /* PSM match found */
+ found = true;
+
+ /* Exact match */
+ if (!bacmp(&bt_sk(c->sk)->src, src))
+ break;
+
+ /* BDADDR_ANY match */
+ if (!bacmp(&bt_sk(c->sk)->src, BDADDR_ANY) ||
+ !bacmp(src, BDADDR_ANY))
+ break;
+
+ /* Match found only for other adapter address */
+ return p;
+ }
+
+ if (!found)
+ return p;
+ }
+
+ return 0;
+}
+
int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
{
int err;
@@ -135,16 +172,16 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
chan->sport = psm;
err = 0;
} else {
- u16 p;
-
+ /* No PSM given by user space */
+ u16 dpsm;
err = -EINVAL;
- for (p = 0x1001; p < 0x1100; p += 2)
- if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) {
- chan->psm = cpu_to_le16(p);
- chan->sport = cpu_to_le16(p);
- err = 0;
- break;
- }
+
+ dpsm = __l2cap_global_get_dyna_chan_by_addr(src);
+ if (dpsm) {
+ chan->psm = dpsm;
+ chan->sport = dpsm;
+ err = 0;
+ }
}
done:
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 1/2] audio: Fix headset NULL pointer dereference during AT+BLDN response
From: Syam Sidhardhan @ 2012-10-23 13:57 UTC (permalink / raw)
To: linux-bluetooth
While waiting for the AT+BLDN asynchronous response, if RFCOMM got
disconnected, then respose will cause NULL pointer dereference.
During headset disconnection, the headset state changes from
HEADSET_STATE_CONNECTED to HEADSET_STATE_DISCONNECTED along with
freeing the dev->headset. During the response, in telephony_generic_rsp
its dereferencing.
Log:
bluetoothd[5573]: audio/headset.c:handle_event() Received AT+BLDN
bluetoothd[5573]: audio/telephony.c:telephony_last_dialed_number_req()
telephony-tizen: last dialed number request
bluetoothd[5573]: audio/telephony.c:dbus_method_call_send() +
bluetoothd[5573]: audio/telephony.c:dbus_method_call_send() -
bluetoothd[5573]: Endpoint replied with an error: org.freedesktop.DBus\
.Error.NoReply
bluetoothd[5573]: audio/telephony.c:telephony_device_disconnected()
telephony-tizen: device 0x40439b60 disconnected
bluetoothd[5573]: audio/headset.c:headset_set_state() State changed
/org/bluez/5573/hci0/dev_BC_47_60_F5_88_89:
HEADSET_STATE_CONNECTED -> HEADSET_STATE_DISCONNECTED
bluetoothd[5573]: audio/media.c:headset_state_changed()
bluetoothd[5573]: audio/media.c:headset_state_changed() Clear endpoint
0x40430620
bluetoothd[5573]: audio/telephony.c:telephony_dial_number_reply()
redial_reply
bluetoothd[5573]: audio/telephony.c:telephony_dial_number_reply()
dial_reply reply: No Call log
---
audio/headset.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/audio/headset.c b/audio/headset.c
index bd83a65..30d24cf 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -689,6 +689,9 @@ static int telephony_generic_rsp(struct audio_device *device, cme_error_t err)
struct headset *hs = device->headset;
struct headset_slc *slc = hs->slc;
+ if (!slc)
+ return -EIO;
+
if ((err != CME_ERROR_NONE) && slc->cme_enabled)
return headset_send(hs, "\r\n+CME ERROR: %d\r\n", err);
--
1.7.4.1
^ permalink raw reply related
* [PATCH BlueZ 2/2] gdbus: Replace leading spaces with tabs
From: Syam Sidhardhan @ 2012-10-23 13:57 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1351000626-22632-1-git-send-email-s.syam@samsung.com>
Trivial formatting fix.
---
gdbus/object.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gdbus/object.c b/gdbus/object.c
index 9689006..d58a1a8 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -226,7 +226,7 @@ void g_dbus_pending_success(DBusConnection *connection,
{
GSList *list;
- for (list = pending_security; list; list = list->next) {
+ for (list = pending_security; list; list = list->next) {
struct security_data *secdata = list->data;
if (secdata->pending != pending)
@@ -240,7 +240,7 @@ void g_dbus_pending_success(DBusConnection *connection,
dbus_message_unref(secdata->message);
g_free(secdata);
return;
- }
+ }
}
void g_dbus_pending_error_valist(DBusConnection *connection,
@@ -249,7 +249,7 @@ void g_dbus_pending_error_valist(DBusConnection *connection,
{
GSList *list;
- for (list = pending_security; list; list = list->next) {
+ for (list = pending_security; list; list = list->next) {
struct security_data *secdata = list->data;
DBusMessage *reply;
@@ -268,7 +268,7 @@ void g_dbus_pending_error_valist(DBusConnection *connection,
dbus_message_unref(secdata->message);
g_free(secdata);
return;
- }
+ }
}
void g_dbus_pending_error(DBusConnection *connection,
--
1.7.4.1
^ permalink raw reply related
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