From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/3] emulator/hciemu: Add hciemu_new_debug/hciemu_new_num_debug
Date: Wed, 6 May 2026 15:41:49 -0400 [thread overview]
Message-ID: <20260506194150.1701855-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260506194150.1701855-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add new constructors that accept debug callback and user_data parameters,
setting them up immediately after allocation so errors during early
initialization (create_vhci, hciemu_client_new) are captured by the debug
output.
---
emulator/hciemu.c | 20 +++++++++++++++++++-
emulator/hciemu.h | 11 +++++++++--
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/emulator/hciemu.c b/emulator/hciemu.c
index 9534d82bac39..15d806a62aa6 100644
--- a/emulator/hciemu.c
+++ b/emulator/hciemu.c
@@ -396,7 +396,9 @@ static struct hciemu_client *hciemu_client_new(struct hciemu *hciemu,
return client;
}
-struct hciemu *hciemu_new_num(enum hciemu_type type, uint8_t num)
+struct hciemu *hciemu_new_num_debug(enum hciemu_type type, uint8_t num,
+ hciemu_debug_func_t callback, void *user_data,
+ hciemu_destroy_func_t destroy)
{
struct hciemu *hciemu;
@@ -409,6 +411,10 @@ struct hciemu *hciemu_new_num(enum hciemu_type type, uint8_t num)
if (!hciemu)
return NULL;
+ hciemu->debug_callback = callback;
+ hciemu->debug_destroy = destroy;
+ hciemu->debug_data = user_data;
+
switch (type) {
case HCIEMU_TYPE_BREDRLE:
hciemu->btdev_type = BTDEV_TYPE_BREDRLE;
@@ -465,11 +471,23 @@ struct hciemu *hciemu_new_num(enum hciemu_type type, uint8_t num)
return hciemu_ref(hciemu);
}
+struct hciemu *hciemu_new_num(enum hciemu_type type, uint8_t num)
+{
+ return hciemu_new_num_debug(type, num, NULL, NULL, NULL);
+}
+
struct hciemu *hciemu_new(enum hciemu_type type)
{
return hciemu_new_num(type, 1);
}
+struct hciemu *hciemu_new_debug(enum hciemu_type type,
+ hciemu_debug_func_t callback, void *user_data,
+ hciemu_destroy_func_t destroy)
+{
+ return hciemu_new_num_debug(type, 1, callback, user_data, destroy);
+}
+
struct hciemu *hciemu_ref(struct hciemu *hciemu)
{
if (!hciemu)
diff --git a/emulator/hciemu.h b/emulator/hciemu.h
index 1164be6510a3..e832d6350bb3 100644
--- a/emulator/hciemu.h
+++ b/emulator/hciemu.h
@@ -31,8 +31,17 @@ enum hciemu_hook_type {
HCIEMU_HOOK_POST_EVT,
};
+typedef void (*hciemu_debug_func_t)(const char *str, void *user_data);
+typedef void (*hciemu_destroy_func_t)(void *user_data);
+
struct hciemu *hciemu_new(enum hciemu_type type);
struct hciemu *hciemu_new_num(enum hciemu_type type, uint8_t num);
+struct hciemu *hciemu_new_debug(enum hciemu_type type,
+ hciemu_debug_func_t callback, void *user_data,
+ hciemu_destroy_func_t destroy);
+struct hciemu *hciemu_new_num_debug(enum hciemu_type type, uint8_t num,
+ hciemu_debug_func_t callback, void *user_data,
+ hciemu_destroy_func_t destroy);
struct hciemu *hciemu_ref(struct hciemu *hciemu);
void hciemu_unref(struct hciemu *hciemu);
@@ -43,8 +52,6 @@ const uint8_t *hciemu_client_bdaddr(struct hciemu_client *client);
bool hciemu_set_client_bdaddr(struct hciemu_client *client,
const uint8_t *bdaddr);
-typedef void (*hciemu_debug_func_t)(const char *str, void *user_data);
-typedef void (*hciemu_destroy_func_t)(void *user_data);
bool hciemu_set_debug(struct hciemu *hciemu, hciemu_debug_func_t callback,
void *user_data, hciemu_destroy_func_t destroy);
--
2.53.0
next prev parent reply other threads:[~2026-05-06 19:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 19:41 [PATCH BlueZ v1 1/3] tools/tester: Fix crash when hciemu_new fails Luiz Augusto von Dentz
2026-05-06 19:41 ` Luiz Augusto von Dentz [this message]
2026-05-06 19:41 ` [PATCH BlueZ v1 3/3] tools/tester: Retry with debug on hciemu_new failure Luiz Augusto von Dentz
2026-05-06 21:12 ` [BlueZ,v1,1/3] tools/tester: Fix crash when hciemu_new fails bluez.test.bot
2026-05-07 16:10 ` [PATCH BlueZ v1 1/3] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260506194150.1701855-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox