All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] mesh: Allow mesh-io to use dbus when initializing
@ 2022-02-03 14:12 Michał Lowas-Rzechonek
  2022-02-03 15:13 ` [BlueZ] " bluez.test.bot
  2022-02-04 22:40 ` [PATCH BlueZ] " Stotland, Inga
  0 siblings, 2 replies; 3+ messages in thread
From: Michał Lowas-Rzechonek @ 2022-02-03 14:12 UTC (permalink / raw)
  To: linux-bluetooth

Some io implementations might want to either make calls to other D-Bus
services, or provide additional objects/interfaces that allow
applications to fine-tune their operation.
---
 mesh/main.c            |  9 ++++-----
 mesh/mesh-io-api.h     |  3 ++-
 mesh/mesh-io-generic.c |  4 +++-
 mesh/mesh-io-unit.c    |  2 +-
 mesh/mesh-io.c         |  5 +++--
 mesh/mesh-io.h         |  3 ++-
 mesh/mesh.c            | 12 +++++++-----
 mesh/mesh.h            |  9 +++++----
 8 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/mesh/main.c b/mesh/main.c
index dd99c3085..74b0f884e 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -76,10 +76,9 @@ static void do_debug(const char *str, void *user_data)
 	l_info("%s%s", prefix, str);
 }
 
-static void mesh_ready_callback(void *user_data, bool success)
+static void mesh_ready_callback(bool success, struct l_dbus *dbus,
+								void *user_data)
 {
-	struct l_dbus *dbus = user_data;
-
 	l_info("mesh_ready_callback");
 	if (!success) {
 		l_error("Failed to start mesh");
@@ -102,8 +101,8 @@ static void request_name_callback(struct l_dbus *dbus, bool success,
 		return;
 	}
 
-	if (!mesh_init(storage_dir, mesh_conf_fname, io_type, io_opts,
-					mesh_ready_callback, dbus)) {
+	if (!mesh_init(dbus, storage_dir, mesh_conf_fname, io_type, io_opts,
+					mesh_ready_callback, NULL)) {
 		l_error("Failed to initialize mesh");
 		l_main_quit();
 	}
diff --git a/mesh/mesh-io-api.h b/mesh/mesh-io-api.h
index 61f79f224..7a50937da 100644
--- a/mesh/mesh-io-api.h
+++ b/mesh/mesh-io-api.h
@@ -11,7 +11,8 @@
 struct mesh_io_private;
 
 typedef bool (*mesh_io_init_t)(struct mesh_io *io, void *opts,
-				mesh_io_ready_func_t cb, void *user_data);
+				struct l_dbus *dbus, mesh_io_ready_func_t cb,
+				void *user_data);
 typedef bool (*mesh_io_destroy_t)(struct mesh_io *io);
 typedef bool (*mesh_io_caps_t)(struct mesh_io *io, struct mesh_io_caps *caps);
 typedef bool (*mesh_io_send_t)(struct mesh_io *io,
diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c
index 6c0b8f0fd..27cb4cf5f 100644
--- a/mesh/mesh-io-generic.c
+++ b/mesh/mesh-io-generic.c
@@ -27,6 +27,7 @@
 #include "mesh/mesh-io.h"
 #include "mesh/mesh-io-api.h"
 #include "mesh/mesh-io-generic.h"
+#include "mesh/dbus.h"
 
 struct mesh_io_private {
 	struct bt_hci *hci;
@@ -40,6 +41,7 @@ struct mesh_io_private {
 	uint16_t interval;
 	bool sending;
 	bool active;
+	struct l_dbus *dbus;
 };
 
 struct pvt_rx_reg {
@@ -429,7 +431,7 @@ static void read_info(int index, void *user_data)
 	hci_init(io);
 }
 
-static bool dev_init(struct mesh_io *io, void *opts,
+static bool dev_init(struct mesh_io *io, void *opts, struct l_dbus *dbus,
 				mesh_io_ready_func_t cb, void *user_data)
 {
 	if (!io || io->pvt)
diff --git a/mesh/mesh-io-unit.c b/mesh/mesh-io-unit.c
index f4b615ac8..a3cba747e 100644
--- a/mesh/mesh-io-unit.c
+++ b/mesh/mesh-io-unit.c
@@ -209,7 +209,7 @@ static void unit_up(void *user_data)
 	l_timeout_create_ms(1, get_name, pvt, NULL);
 }
 
-static bool unit_init(struct mesh_io *io, void *opt,
+static bool unit_init(struct mesh_io *io, void *opt, struct l_dbus *dbus,
 				mesh_io_ready_func_t cb, void *user_data)
 {
 	struct mesh_io_private *pvt;
diff --git a/mesh/mesh-io.c b/mesh/mesh-io.c
index 96891313a..dfd9e43d9 100644
--- a/mesh/mesh-io.c
+++ b/mesh/mesh-io.c
@@ -46,7 +46,8 @@ static bool match_by_type(const void *a, const void *b)
 }
 
 struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
-				mesh_io_ready_func_t cb, void *user_data)
+				struct l_dbus *dbus, mesh_io_ready_func_t cb,
+				void *user_data)
 {
 	const struct mesh_io_api *api = NULL;
 	struct mesh_io *io;
@@ -69,7 +70,7 @@ struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
 	io->type = type;
 	io->api = api;
 
-	if (!api->init(io, opts, cb, user_data))
+	if (!api->init(io, opts, dbus, cb, user_data))
 		goto fail;
 
 	if (!io_list)
diff --git a/mesh/mesh-io.h b/mesh/mesh-io.h
index 80ef3fa3e..8a4b2e8ee 100644
--- a/mesh/mesh-io.h
+++ b/mesh/mesh-io.h
@@ -74,7 +74,8 @@ typedef void (*mesh_io_recv_ext_func_t)(void *user_data,
 typedef void (*mesh_io_ready_func_t)(void *user_data, bool result);
 
 struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
-				mesh_io_ready_func_t cb, void *user_data);
+				struct l_dbus *dbus, mesh_io_ready_func_t cb,
+				void *user_data);
 void mesh_io_destroy(struct mesh_io *io);
 
 bool mesh_io_get_caps(struct mesh_io *io, struct mesh_io_caps *caps);
diff --git a/mesh/mesh.c b/mesh/mesh.c
index 62d650328..1d3451cf4 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -71,6 +71,7 @@ struct join_data{
 
 struct mesh_init_request {
 	mesh_ready_func_t cb;
+	struct l_dbus *dbus;
 	void *user_data;
 };
 
@@ -173,7 +174,7 @@ static void io_ready_callback(void *user_data, bool result)
 	if (result)
 		node_attach_io_all(mesh.io);
 
-	req->cb(req->user_data, result);
+	req->cb(result, req->dbus, req->user_data);
 
 	l_free(req);
 }
@@ -249,9 +250,9 @@ done:
 	l_settings_free(settings);
 }
 
-bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
-					enum mesh_io_type type, void *opts,
-					mesh_ready_func_t cb, void *user_data)
+bool mesh_init(struct l_dbus *dbus, const char *config_dir,
+		const char *mesh_conf_fname, enum mesh_io_type type, void *opts,
+		mesh_ready_func_t cb, void *user_data)
 {
 	struct mesh_io_caps caps;
 	struct mesh_init_request *req;
@@ -280,9 +281,10 @@ bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
 
 	req = l_new(struct mesh_init_request, 1);
 	req->cb = cb;
+	req->dbus = dbus;
 	req->user_data = user_data;
 
-	mesh.io = mesh_io_new(type, opts, io_ready_callback, req);
+	mesh.io = mesh_io_new(type, opts, dbus, io_ready_callback, req);
 	if (!mesh.io) {
 		l_free(req);
 		return false;
diff --git a/mesh/mesh.h b/mesh/mesh.h
index 0f77ebc58..6050cfa06 100644
--- a/mesh/mesh.h
+++ b/mesh/mesh.h
@@ -21,13 +21,14 @@
 
 enum mesh_io_type;
 
-typedef void (*mesh_ready_func_t)(void *user_data, bool success);
+typedef void (*mesh_ready_func_t)(bool success, struct l_dbus *dbus,
+							void *user_data);
 typedef void (*prov_rx_cb_t)(void *user_data, const uint8_t *data,
 								uint16_t len);
 
-bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
-					enum mesh_io_type type, void *opts,
-					mesh_ready_func_t cb, void *user_data);
+bool mesh_init(struct l_dbus *dus, const char *config_dir,
+		const char *mesh_conf_fname, enum mesh_io_type type, void *opts,
+		mesh_ready_func_t cb, void *user_data);
 void mesh_cleanup(void);
 bool mesh_dbus_init(struct l_dbus *dbus);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ] mesh: Allow mesh-io to use dbus when initializing
  2022-02-03 14:12 [PATCH BlueZ] mesh: Allow mesh-io to use dbus when initializing Michał Lowas-Rzechonek
@ 2022-02-03 15:13 ` bluez.test.bot
  2022-02-04 22:40 ` [PATCH BlueZ] " Stotland, Inga
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2022-02-03 15:13 UTC (permalink / raw)
  To: linux-bluetooth, michal.lowas-rzechonek

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=611014

---Test result---

Test Summary:
CheckPatch                    PASS      0.57 seconds
GitLint                       PASS      0.37 seconds
Prep - Setup ELL              PASS      41.12 seconds
Build - Prep                  PASS      0.42 seconds
Build - Configure             PASS      8.06 seconds
Build - Make                  PASS      1205.09 seconds
Make Check                    PASS      11.08 seconds
Make Check w/Valgrind         PASS      405.96 seconds
Make Distcheck                PASS      212.16 seconds
Build w/ext ELL - Configure   PASS      7.76 seconds
Build w/ext ELL - Make        PASS      1143.43 seconds
Incremental Build with patchesPASS      0.00 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ] mesh: Allow mesh-io to use dbus when initializing
  2022-02-03 14:12 [PATCH BlueZ] mesh: Allow mesh-io to use dbus when initializing Michał Lowas-Rzechonek
  2022-02-03 15:13 ` [BlueZ] " bluez.test.bot
@ 2022-02-04 22:40 ` Stotland, Inga
  1 sibling, 0 replies; 3+ messages in thread
From: Stotland, Inga @ 2022-02-04 22:40 UTC (permalink / raw)
  To: michal.lowas-rzechonek; +Cc: linux-bluetooth

Hi Michal,

On Thu, 2022-02-03 at 15:12 +0100, Michał Lowas-Rzechonek wrote:
> Some io implementations might want to either make calls to other D-
> Bus
> services, or provide additional objects/interfaces that allow
> applications to fine-tune their operation.
> ---
>  mesh/main.c            |  9 ++++-----
>  mesh/mesh-io-api.h     |  3 ++-
>  mesh/mesh-io-generic.c |  4 +++-
>  mesh/mesh-io-unit.c    |  2 +-
>  mesh/mesh-io.c         |  5 +++--
>  mesh/mesh-io.h         |  3 ++-
>  mesh/mesh.c            | 12 +++++++-----
>  mesh/mesh.h            |  9 +++++----
>  8 files changed, 27 insertions(+), 20 deletions(-)
> 
> diff --git a/mesh/main.c b/mesh/main.c
> index dd99c3085..74b0f884e 100644
> --- a/mesh/main.c
> +++ b/mesh/main.c
> @@ -76,10 +76,9 @@ static void do_debug(const char *str, void
> *user_data)
>         l_info("%s%s", prefix, str);
>  }
>  
> -static void mesh_ready_callback(void *user_data, bool success)
> +static void mesh_ready_callback(bool success, struct l_dbus *dbus,
> +                                                               void
> *user_data)
>  {
> -       struct l_dbus *dbus = user_data;
> -
>         l_info("mesh_ready_callback");
>         if (!success) {
>                 l_error("Failed to start mesh");
> @@ -102,8 +101,8 @@ static void request_name_callback(struct l_dbus
> *dbus, bool success,
>                 return;
>         }
>  
> -       if (!mesh_init(storage_dir, mesh_conf_fname, io_type,
> io_opts,
> -                                       mesh_ready_callback, dbus)) {
> +       if (!mesh_init(dbus, storage_dir, mesh_conf_fname, io_type,
> io_opts,
> +                                       mesh_ready_callback, NULL)) {
>                 l_error("Failed to initialize mesh");
>                 l_main_quit();
>         }
> diff --git a/mesh/mesh-io-api.h b/mesh/mesh-io-api.h
> index 61f79f224..7a50937da 100644
> --- a/mesh/mesh-io-api.h
> +++ b/mesh/mesh-io-api.h
> @@ -11,7 +11,8 @@
>  struct mesh_io_private;
>  
>  typedef bool (*mesh_io_init_t)(struct mesh_io *io, void *opts,
> -                               mesh_io_ready_func_t cb, void
> *user_data);
> +                               struct l_dbus *dbus,
> mesh_io_ready_func_t cb,
> +                               void *user_data);
>  typedef bool (*mesh_io_destroy_t)(struct mesh_io *io);
>  typedef bool (*mesh_io_caps_t)(struct mesh_io *io, struct
> mesh_io_caps *caps);
>  typedef bool (*mesh_io_send_t)(struct mesh_io *io,
> diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c
> index 6c0b8f0fd..27cb4cf5f 100644
> --- a/mesh/mesh-io-generic.c
> +++ b/mesh/mesh-io-generic.c
> @@ -27,6 +27,7 @@
>  #include "mesh/mesh-io.h"
>  #include "mesh/mesh-io-api.h"
>  #include "mesh/mesh-io-generic.h"
> +#include "mesh/dbus.h"
>  
>  struct mesh_io_private {
>         struct bt_hci *hci;
> @@ -40,6 +41,7 @@ struct mesh_io_private {
>         uint16_t interval;
>         bool sending;
>         bool active;
> +       struct l_dbus *dbus;
>  };
>  
>  struct pvt_rx_reg {
> @@ -429,7 +431,7 @@ static void read_info(int index, void *user_data)
>         hci_init(io);
>  }
>  
> -static bool dev_init(struct mesh_io *io, void *opts,
> +static bool dev_init(struct mesh_io *io, void *opts, struct l_dbus
> *dbus,
>                                 mesh_io_ready_func_t cb, void
> *user_data)
>  {
>         if (!io || io->pvt)
> diff --git a/mesh/mesh-io-unit.c b/mesh/mesh-io-unit.c
> index f4b615ac8..a3cba747e 100644
> --- a/mesh/mesh-io-unit.c
> +++ b/mesh/mesh-io-unit.c
> @@ -209,7 +209,7 @@ static void unit_up(void *user_data)
>         l_timeout_create_ms(1, get_name, pvt, NULL);
>  }
>  
> -static bool unit_init(struct mesh_io *io, void *opt,
> +static bool unit_init(struct mesh_io *io, void *opt, struct l_dbus
> *dbus,
>                                 mesh_io_ready_func_t cb, void
> *user_data)
>  {
>         struct mesh_io_private *pvt;
> diff --git a/mesh/mesh-io.c b/mesh/mesh-io.c
> index 96891313a..dfd9e43d9 100644
> --- a/mesh/mesh-io.c
> +++ b/mesh/mesh-io.c
> @@ -46,7 +46,8 @@ static bool match_by_type(const void *a, const void
> *b)
>  }
>  
>  struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
> -                               mesh_io_ready_func_t cb, void
> *user_data)
> +                               struct l_dbus *dbus,
> mesh_io_ready_func_t cb,
> +                               void *user_data)
>  {
>         const struct mesh_io_api *api = NULL;
>         struct mesh_io *io;
> @@ -69,7 +70,7 @@ struct mesh_io *mesh_io_new(enum mesh_io_type type,
> void *opts,
>         io->type = type;
>         io->api = api;
>  
> -       if (!api->init(io, opts, cb, user_data))
> +       if (!api->init(io, opts, dbus, cb, user_data))
>                 goto fail;
>  
>         if (!io_list)
> diff --git a/mesh/mesh-io.h b/mesh/mesh-io.h
> index 80ef3fa3e..8a4b2e8ee 100644
> --- a/mesh/mesh-io.h
> +++ b/mesh/mesh-io.h
> @@ -74,7 +74,8 @@ typedef void (*mesh_io_recv_ext_func_t)(void
> *user_data,
>  typedef void (*mesh_io_ready_func_t)(void *user_data, bool result);
>  
>  struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
> -                               mesh_io_ready_func_t cb, void
> *user_data);
> +                               struct l_dbus *dbus,
> mesh_io_ready_func_t cb,
> +                               void *user_data);
>  void mesh_io_destroy(struct mesh_io *io);
>  
>  bool mesh_io_get_caps(struct mesh_io *io, struct mesh_io_caps
> *caps);
> diff --git a/mesh/mesh.c b/mesh/mesh.c
> index 62d650328..1d3451cf4 100644
> --- a/mesh/mesh.c
> +++ b/mesh/mesh.c
> @@ -71,6 +71,7 @@ struct join_data{
>  
>  struct mesh_init_request {
>         mesh_ready_func_t cb;
> +       struct l_dbus *dbus;
>         void *user_data;
>  };
>  
> @@ -173,7 +174,7 @@ static void io_ready_callback(void *user_data,
> bool result)
>         if (result)
>                 node_attach_io_all(mesh.io);
>  
> -       req->cb(req->user_data, result);
> +       req->cb(result, req->dbus, req->user_data);
>  
>         l_free(req);
>  }
> @@ -249,9 +250,9 @@ done:
>         l_settings_free(settings);
>  }
>  
> -bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
> -                                       enum mesh_io_type type, void
> *opts,
> -                                       mesh_ready_func_t cb, void
> *user_data)
> +bool mesh_init(struct l_dbus *dbus, const char *config_dir,
> +               const char *mesh_conf_fname, enum mesh_io_type type,
> void *opts,
> +               mesh_ready_func_t cb, void *user_data)
>  {
>         struct mesh_io_caps caps;
>         struct mesh_init_request *req;
> @@ -280,9 +281,10 @@ bool mesh_init(const char *config_dir, const
> char *mesh_conf_fname,
>  
>         req = l_new(struct mesh_init_request, 1);
>         req->cb = cb;
> +       req->dbus = dbus;
>         req->user_data = user_data;
>  
> -       mesh.io = mesh_io_new(type, opts, io_ready_callback, req);
> +       mesh.io = mesh_io_new(type, opts, dbus, io_ready_callback,
> req);
>         if (!mesh.io) {
>                 l_free(req);
>                 return false;
> diff --git a/mesh/mesh.h b/mesh/mesh.h
> index 0f77ebc58..6050cfa06 100644
> --- a/mesh/mesh.h
> +++ b/mesh/mesh.h
> @@ -21,13 +21,14 @@
>  
>  enum mesh_io_type;
>  
> -typedef void (*mesh_ready_func_t)(void *user_data, bool success);
> +typedef void (*mesh_ready_func_t)(bool success, struct l_dbus *dbus,
> +                                                       void
> *user_data);
>  typedef void (*prov_rx_cb_t)(void *user_data, const uint8_t *data,
>                                                                 uint1
> 6_t len);
>  
> -bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
> -                                       enum mesh_io_type type, void
> *opts,
> -                                       mesh_ready_func_t cb, void
> *user_data);
> +bool mesh_init(struct l_dbus *dus, const char *config_dir,
> +               const char *mesh_conf_fname, enum mesh_io_type type,
> void *opts,
> +               mesh_ready_func_t cb, void *user_data);
>  void mesh_cleanup(void);
>  bool mesh_dbus_init(struct l_dbus *dbus);
>  

I wonder if setting the global dbus value prior to initializing mesh
would be a bettter solution. That is, introducing a function like 

void dbus_set_bus(struct l_dbus *bus) (in dbus.c)

and call it right after l_dbus_new_default()in main.c

Would that provide the required functionality?

Best regards,
Inga

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-04 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 14:12 [PATCH BlueZ] mesh: Allow mesh-io to use dbus when initializing Michał Lowas-Rzechonek
2022-02-03 15:13 ` [BlueZ] " bluez.test.bot
2022-02-04 22:40 ` [PATCH BlueZ] " Stotland, Inga

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.