public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/4] shared/gatt-client: Use parent debug_callback if not set on clone
@ 2023-01-05 22:09 Luiz Augusto von Dentz
  2023-01-05 22:09 ` [PATCH BlueZ 2/4] shared/gatt-client: Allow registering with NULL callback Luiz Augusto von Dentz
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2023-01-05 22:09 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If clone don't have a dedicated callback set use its parent so users of
bt_gatt_client_clone don't have to keep setting the same callback for
all clone instances.
---
 src/shared/gatt-client.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index cb2e64b6cc6b..4aa5d7d92957 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -38,7 +38,8 @@
 #define GATT_SVC_UUID	0x1801
 #define SVC_CHNGD_UUID	0x2a05
 #define DBG(_client, _format, arg...) \
-	gatt_log(_client, "%s:%s() " _format, __FILE__, __func__, ## arg)
+	gatt_log(_client, "[%p] %s:%s() " _format, _client, __FILE__, \
+		__func__, ## arg)
 
 struct ready_cb {
 	bt_gatt_client_callback_t callback;
@@ -357,15 +358,28 @@ static void discovery_op_free(struct discovery_op *op)
 
 static bool read_db_hash(struct discovery_op *op);
 
+static void gatt_log_va(struct bt_gatt_client *client, const char *format,
+						va_list va)
+{
+	if (!client || !format)
+		return;
+
+	if (client->debug_callback)
+		util_debug_va(client->debug_callback, client->debug_data,
+							format, va);
+	else
+		gatt_log_va(client->parent, format, va);
+}
+
 static void gatt_log(struct bt_gatt_client *client, const char *format, ...)
 {
 	va_list ap;
 
-	if (!client || !format || !client->debug_callback)
+	if (!client || !format)
 		return;
 
 	va_start(ap, format);
-	util_debug_va(client->debug_callback, client->debug_data, format, ap);
+	gatt_log_va(client, format, ap);
 	va_end(ap);
 }
 
-- 
2.37.3


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

end of thread, other threads:[~2023-01-06 20:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-05 22:09 [PATCH BlueZ 1/4] shared/gatt-client: Use parent debug_callback if not set on clone Luiz Augusto von Dentz
2023-01-05 22:09 ` [PATCH BlueZ 2/4] shared/gatt-client: Allow registering with NULL callback Luiz Augusto von Dentz
2023-01-05 22:09 ` [PATCH BlueZ 3/4] attrib: Introduce g_attrib_attach_client Luiz Augusto von Dentz
2023-01-05 22:09 ` [PATCH BlueZ 4/4] hog-lib: Fix not handling BT_ATT_OP_HANDLE_NFY_MULT Luiz Augusto von Dentz
2023-01-06  0:03 ` [BlueZ,1/4] shared/gatt-client: Use parent debug_callback if not set on clone bluez.test.bot
2023-01-06  0:11   ` Luiz Augusto von Dentz
2023-01-06 20:00 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox