public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [BlueZ 0/4] API fixes to make better bindings
@ 2026-01-19 13:27 Bastien Nocera
  2026-01-19 13:27 ` [BlueZ 1/4] src: Turn available priority macros into an enum Bastien Nocera
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Bastien Nocera @ 2026-01-19 13:27 UTC (permalink / raw)
  To: linux-bluetooth

Those changes will make using the internal bluez API easier to access
from Rust.

Bastien Nocera (4):
  src: Turn available priority macros into an enum
  src: Prefix plugin-accessible adapter_set_name() function
  adapter: Fix const'ness of struct btd_adapter_driver
  src: Prefix plugin-accessible adapter_foreach() function

 plugins/hostname.c  | 12 ++++++------
 src/adapter.c       | 16 ++++++++--------
 src/adapter.h       |  9 +++++----
 src/agent.c         |  4 ++--
 src/gatt-database.c |  2 +-
 src/plugin.h        |  9 ++++++---
 src/profile.c       |  4 ++--
 7 files changed, 30 insertions(+), 26 deletions(-)

-- 
2.52.0


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

* [BlueZ 1/4] src: Turn available priority macros into an enum
  2026-01-19 13:27 [BlueZ 0/4] API fixes to make better bindings Bastien Nocera
@ 2026-01-19 13:27 ` Bastien Nocera
  2026-01-19 15:16   ` API fixes to make better bindings bluez.test.bot
  2026-01-19 13:27 ` [BlueZ 2/4] src: Prefix plugin-accessible adapter_set_name() function Bastien Nocera
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Bastien Nocera @ 2026-01-19 13:27 UTC (permalink / raw)
  To: linux-bluetooth

This will allow generated bindings to know to use the same type
independent of individual values.
---
 src/plugin.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/plugin.h b/src/plugin.h
index b484ed37874e..e03b587faed6 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -7,9 +7,12 @@
  *
  *
  */
-#define BLUETOOTH_PLUGIN_PRIORITY_LOW      -100
-#define BLUETOOTH_PLUGIN_PRIORITY_DEFAULT     0
-#define BLUETOOTH_PLUGIN_PRIORITY_HIGH      100
+
+enum bluetooth_plugin_priority {
+	BLUETOOTH_PLUGIN_PRIORITY_LOW     = -100,
+	BLUETOOTH_PLUGIN_PRIORITY_DEFAULT = 0,
+	BLUETOOTH_PLUGIN_PRIORITY_HIGH    = 100
+};
 
 struct bluetooth_plugin_desc {
 	const char *name;
-- 
2.52.0


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

* [BlueZ 2/4] src: Prefix plugin-accessible adapter_set_name() function
  2026-01-19 13:27 [BlueZ 0/4] API fixes to make better bindings Bastien Nocera
  2026-01-19 13:27 ` [BlueZ 1/4] src: Turn available priority macros into an enum Bastien Nocera
@ 2026-01-19 13:27 ` Bastien Nocera
  2026-01-19 13:27 ` [BlueZ 3/4] adapter: Fix const'ness of struct btd_adapter_driver Bastien Nocera
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Bastien Nocera @ 2026-01-19 13:27 UTC (permalink / raw)
  To: linux-bluetooth

Plugin-accessible functions are usually prefixed with btd_ to avoid
confusing them with internal private functions. Rename
adapter_set_name() to match the existing btd_adapter_set_class().
---
 plugins/hostname.c | 4 ++--
 src/adapter.c      | 2 +-
 src/adapter.h      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/plugins/hostname.c b/plugins/hostname.c
index 35420e5d587b..c827506275aa 100644
--- a/plugins/hostname.c
+++ b/plugins/hostname.c
@@ -82,7 +82,7 @@ static void update_name(struct btd_adapter *adapter, gpointer user_data)
 	if (btd_adapter_is_default(adapter)) {
 		DBG("name: %s", hostname);
 
-		adapter_set_name(adapter, hostname);
+		btd_adapter_set_name(adapter, hostname);
 	} else {
 		uint16_t index = btd_adapter_get_index(adapter);
 		char *str;
@@ -92,7 +92,7 @@ static void update_name(struct btd_adapter *adapter, gpointer user_data)
 
 		DBG("name: %s", str);
 
-		adapter_set_name(adapter, str);
+		btd_adapter_set_name(adapter, str);
 
 		g_free(str);
 	}
diff --git a/src/adapter.c b/src/adapter.c
index a5de7cee1552..3bbee2e36810 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -998,7 +998,7 @@ static int set_name(struct btd_adapter *adapter, const char *name)
 	return -EIO;
 }
 
-int adapter_set_name(struct btd_adapter *adapter, const char *name)
+int btd_adapter_set_name(struct btd_adapter *adapter, const char *name)
 {
 	if (g_strcmp0(adapter->system_name, name) == 0)
 		return 0;
diff --git a/src/adapter.h b/src/adapter.h
index dd0c90d9cb3a..e562b1bcd4da 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -100,7 +100,6 @@ const char *adapter_get_path(struct btd_adapter *adapter);
 const bdaddr_t *btd_adapter_get_address(struct btd_adapter *adapter);
 uint8_t btd_adapter_get_address_type(struct btd_adapter *adapter);
 const char *btd_adapter_get_storage_dir(struct btd_adapter *adapter);
-int adapter_set_name(struct btd_adapter *adapter, const char *name);
 
 int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec);
 void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle);
@@ -114,6 +113,7 @@ void btd_adapter_unref(struct btd_adapter *adapter);
 
 void btd_adapter_set_class(struct btd_adapter *adapter, uint8_t major,
 							uint8_t minor);
+int btd_adapter_set_name(struct btd_adapter *adapter, const char *name);
 
 struct btd_adapter_driver {
 	const char *name;
-- 
2.52.0


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

* [BlueZ 3/4] adapter: Fix const'ness of struct btd_adapter_driver
  2026-01-19 13:27 [BlueZ 0/4] API fixes to make better bindings Bastien Nocera
  2026-01-19 13:27 ` [BlueZ 1/4] src: Turn available priority macros into an enum Bastien Nocera
  2026-01-19 13:27 ` [BlueZ 2/4] src: Prefix plugin-accessible adapter_set_name() function Bastien Nocera
@ 2026-01-19 13:27 ` Bastien Nocera
  2026-01-19 13:27 ` [BlueZ 4/4] src: Prefix plugin-accessible adapter_foreach() function Bastien Nocera
  2026-01-20 16:30 ` [BlueZ 0/4] API fixes to make better bindings patchwork-bot+bluetooth
  4 siblings, 0 replies; 7+ messages in thread
From: Bastien Nocera @ 2026-01-19 13:27 UTC (permalink / raw)
  To: linux-bluetooth

When registering or deregistering an adapter driver, the struct that
holds the function pointers to the various callbacks doesn't need to be
modified, so make it const.
---
 src/adapter.c | 12 ++++++------
 src/adapter.h |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 3bbee2e36810..1eaadc4f89bb 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7696,7 +7696,7 @@ static void adapter_stop(struct btd_adapter *adapter)
 	DBG("adapter %s has been disabled", adapter->path);
 }
 
-int btd_register_adapter_driver(struct btd_adapter_driver *driver)
+int btd_register_adapter_driver(const struct btd_adapter_driver *driver)
 {
 	if (driver->experimental && !(g_dbus_get_flags() &
 					G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) {
@@ -7704,12 +7704,12 @@ int btd_register_adapter_driver(struct btd_adapter_driver *driver)
 		return -ENOTSUP;
 	}
 
-	adapter_drivers = g_slist_append(adapter_drivers, driver);
+	adapter_drivers = g_slist_append(adapter_drivers, (void *) driver);
 
 	if (driver->probe == NULL)
 		return 0;
 
-	adapter_foreach(probe_driver, driver);
+	adapter_foreach(probe_driver, (void *) driver);
 
 	return 0;
 }
@@ -7724,11 +7724,11 @@ static void unload_driver(struct btd_adapter *adapter, gpointer data)
 	adapter->drivers = g_slist_remove(adapter->drivers, data);
 }
 
-void btd_unregister_adapter_driver(struct btd_adapter_driver *driver)
+void btd_unregister_adapter_driver(const struct btd_adapter_driver *driver)
 {
-	adapter_drivers = g_slist_remove(adapter_drivers, driver);
+	adapter_drivers = g_slist_remove(adapter_drivers, (void *) driver);
 
-	adapter_foreach(unload_driver, driver);
+	adapter_foreach(unload_driver, (void *) driver);
 }
 
 static void agent_auth_cb(struct agent *agent, DBusError *derr,
diff --git a/src/adapter.h b/src/adapter.h
index e562b1bcd4da..09d08f9d5b6f 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -139,8 +139,8 @@ typedef void (*service_auth_cb) (DBusError *derr, void *user_data);
 
 void adapter_add_profile(struct btd_adapter *adapter, gpointer p);
 void adapter_remove_profile(struct btd_adapter *adapter, gpointer p);
-int btd_register_adapter_driver(struct btd_adapter_driver *driver);
-void btd_unregister_adapter_driver(struct btd_adapter_driver *driver);
+int btd_register_adapter_driver(const struct btd_adapter_driver *driver);
+void btd_unregister_adapter_driver(const struct btd_adapter_driver *driver);
 guint btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
 		const char *uuid, service_auth_cb cb, void *user_data);
 guint btd_request_authorization_cable_configured(const bdaddr_t *src, const bdaddr_t *dst,
-- 
2.52.0


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

* [BlueZ 4/4] src: Prefix plugin-accessible adapter_foreach() function
  2026-01-19 13:27 [BlueZ 0/4] API fixes to make better bindings Bastien Nocera
                   ` (2 preceding siblings ...)
  2026-01-19 13:27 ` [BlueZ 3/4] adapter: Fix const'ness of struct btd_adapter_driver Bastien Nocera
@ 2026-01-19 13:27 ` Bastien Nocera
  2026-01-20 16:30 ` [BlueZ 0/4] API fixes to make better bindings patchwork-bot+bluetooth
  4 siblings, 0 replies; 7+ messages in thread
From: Bastien Nocera @ 2026-01-19 13:27 UTC (permalink / raw)
  To: linux-bluetooth

---
 plugins/hostname.c  | 8 ++++----
 src/adapter.c       | 6 +++---
 src/adapter.h       | 3 ++-
 src/agent.c         | 4 ++--
 src/gatt-database.c | 2 +-
 src/profile.c       | 4 ++--
 6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/plugins/hostname.c b/plugins/hostname.c
index c827506275aa..5a04df80560f 100644
--- a/plugins/hostname.c
+++ b/plugins/hostname.c
@@ -140,7 +140,7 @@ static void property_changed(GDBusProxy *proxy, const char *name,
 			g_free(pretty_hostname);
 			pretty_hostname = g_strdup(str);
 
-			adapter_foreach(update_name, NULL);
+			btd_adapter_foreach(update_name, NULL);
 		}
 	} else if (g_str_equal(name, "StaticHostname") == TRUE) {
 		if (iter == NULL) {
@@ -158,7 +158,7 @@ static void property_changed(GDBusProxy *proxy, const char *name,
 			g_free(static_hostname);
 			static_hostname = g_strdup(str);
 
-			adapter_foreach(update_name, NULL);
+			btd_adapter_foreach(update_name, NULL);
 		}
 	} else if (g_str_equal(name, "Chassis") == TRUE) {
 		if (iter == NULL) {
@@ -181,7 +181,7 @@ static void property_changed(GDBusProxy *proxy, const char *name,
 				major_class = chassis_table[i].major_class;
 				minor_class = chassis_table[i].minor_class;
 
-				adapter_foreach(update_class, NULL);
+				btd_adapter_foreach(update_class, NULL);
 				break;
 			}
 		}
@@ -210,7 +210,7 @@ static gboolean hostname_cb(GIOChannel *io, GIOCondition cond,
 {
 	DBG("transient hostname changed");
 	read_transient_hostname();
-	adapter_foreach(update_class, NULL);
+	btd_adapter_foreach(update_class, NULL);
 	return TRUE;
 }
 
diff --git a/src/adapter.c b/src/adapter.c
index 1eaadc4f89bb..31d4ae917688 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7709,7 +7709,7 @@ int btd_register_adapter_driver(const struct btd_adapter_driver *driver)
 	if (driver->probe == NULL)
 		return 0;
 
-	adapter_foreach(probe_driver, (void *) driver);
+	btd_adapter_foreach(probe_driver, (void *) driver);
 
 	return 0;
 }
@@ -7728,7 +7728,7 @@ void btd_unregister_adapter_driver(const struct btd_adapter_driver *driver)
 {
 	adapter_drivers = g_slist_remove(adapter_drivers, (void *) driver);
 
-	adapter_foreach(unload_driver, (void *) driver);
+	btd_adapter_foreach(unload_driver, (void *) driver);
 }
 
 static void agent_auth_cb(struct agent *agent, DBusError *derr,
@@ -9332,7 +9332,7 @@ struct btd_adapter *adapter_find_by_id(int id)
 	return match->data;
 }
 
-void adapter_foreach(adapter_cb func, gpointer user_data)
+void btd_adapter_foreach(adapter_cb func, gpointer user_data)
 {
 	g_slist_foreach(adapters, (GFunc) func, user_data);
 }
diff --git a/src/adapter.h b/src/adapter.h
index 09d08f9d5b6f..cdcee69385cb 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -53,6 +53,8 @@ int adapter_init(void);
 void adapter_cleanup(void);
 void adapter_shutdown(void);
 
+void btd_adapter_foreach(adapter_cb func, gpointer user_data);
+
 typedef void (*btd_disconnect_cb) (struct btd_device *device, uint8_t reason);
 void btd_add_disconnect_cb(btd_disconnect_cb func);
 void btd_remove_disconnect_cb(btd_disconnect_cb func);
@@ -63,7 +65,6 @@ void btd_remove_conn_fail_cb(btd_conn_fail_cb func);
 
 struct btd_adapter *adapter_find(const bdaddr_t *sba);
 struct btd_adapter *adapter_find_by_id(int id);
-void adapter_foreach(adapter_cb func, gpointer user_data);
 
 bool btd_adapter_get_pairable(struct btd_adapter *adapter);
 bool btd_adapter_get_powered(struct btd_adapter *adapter);
diff --git a/src/agent.c b/src/agent.c
index c990dc368439..3696575b83e6 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -148,7 +148,7 @@ static bool add_default_agent(struct agent *agent)
 
 	DBG("Default agent set to %s %s", agent->owner, agent->path);
 
-	adapter_foreach(set_io_cap, agent);
+	btd_adapter_foreach(set_io_cap, agent);
 
 	return true;
 }
@@ -168,7 +168,7 @@ static void remove_default_agent(struct agent *agent)
 	else
 		DBG("Default agent cleared");
 
-	adapter_foreach(set_io_cap, agent);
+	btd_adapter_foreach(set_io_cap, agent);
 }
 
 static void agent_disconnect(DBusConnection *conn, void *user_data)
diff --git a/src/gatt-database.c b/src/gatt-database.c
index ff5fa3bcc8b2..5819c252900c 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -548,7 +548,7 @@ static void profile_remove(void *data)
 
 	DBG("Removed \"%s\"", p->name);
 
-	adapter_foreach(adapter_remove_profile, p);
+	btd_adapter_foreach(adapter_remove_profile, p);
 	btd_profile_unregister(p);
 
 	g_free((void *) p->name);
diff --git a/src/profile.c b/src/profile.c
index 46a3d3b45718..dfc5f7161db9 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -2452,14 +2452,14 @@ static struct ext_profile *create_ext(const char *owner, const char *path,
 
 	ext_profiles = g_slist_append(ext_profiles, ext);
 
-	adapter_foreach(adapter_add_profile, &ext->p);
+	btd_adapter_foreach(adapter_add_profile, &ext->p);
 
 	return ext;
 }
 
 static void remove_ext(struct ext_profile *ext)
 {
-	adapter_foreach(adapter_remove_profile, &ext->p);
+	btd_adapter_foreach(adapter_remove_profile, &ext->p);
 
 	ext_profiles = g_slist_remove(ext_profiles, ext);
 
-- 
2.52.0


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

* RE: API fixes to make better bindings
  2026-01-19 13:27 ` [BlueZ 1/4] src: Turn available priority macros into an enum Bastien Nocera
@ 2026-01-19 15:16   ` bluez.test.bot
  0 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2026-01-19 15:16 UTC (permalink / raw)
  To: linux-bluetooth, hadess

[-- Attachment #1: Type: text/plain, Size: 1262 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=1044175

---Test result---

Test Summary:
CheckPatch                    PENDING   0.41 seconds
GitLint                       PENDING   0.34 seconds
BuildEll                      PASS      20.41 seconds
BluezMake                     PASS      663.07 seconds
MakeCheck                     PASS      18.31 seconds
MakeDistcheck                 PASS      244.12 seconds
CheckValgrind                 PASS      299.64 seconds
CheckSmatch                   PASS      361.08 seconds
bluezmakeextell               PASS      187.26 seconds
IncrementalBuild              PENDING   0.41 seconds
ScanBuild                     PASS      1035.64 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [BlueZ 0/4] API fixes to make better bindings
  2026-01-19 13:27 [BlueZ 0/4] API fixes to make better bindings Bastien Nocera
                   ` (3 preceding siblings ...)
  2026-01-19 13:27 ` [BlueZ 4/4] src: Prefix plugin-accessible adapter_foreach() function Bastien Nocera
@ 2026-01-20 16:30 ` patchwork-bot+bluetooth
  4 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2026-01-20 16:30 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 19 Jan 2026 14:27:08 +0100 you wrote:
> Those changes will make using the internal bluez API easier to access
> from Rust.
> 
> Bastien Nocera (4):
>   src: Turn available priority macros into an enum
>   src: Prefix plugin-accessible adapter_set_name() function
>   adapter: Fix const'ness of struct btd_adapter_driver
>   src: Prefix plugin-accessible adapter_foreach() function
> 
> [...]

Here is the summary with links:
  - [BlueZ,1/4] src: Turn available priority macros into an enum
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a1f2e53de4e9
  - [BlueZ,2/4] src: Prefix plugin-accessible adapter_set_name() function
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=69fd644df0a2
  - [BlueZ,3/4] adapter: Fix const'ness of struct btd_adapter_driver
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=80828d5ff016
  - [BlueZ,4/4] src: Prefix plugin-accessible adapter_foreach() function
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c24f0b487ca3

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-01-20 16:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 13:27 [BlueZ 0/4] API fixes to make better bindings Bastien Nocera
2026-01-19 13:27 ` [BlueZ 1/4] src: Turn available priority macros into an enum Bastien Nocera
2026-01-19 15:16   ` API fixes to make better bindings bluez.test.bot
2026-01-19 13:27 ` [BlueZ 2/4] src: Prefix plugin-accessible adapter_set_name() function Bastien Nocera
2026-01-19 13:27 ` [BlueZ 3/4] adapter: Fix const'ness of struct btd_adapter_driver Bastien Nocera
2026-01-19 13:27 ` [BlueZ 4/4] src: Prefix plugin-accessible adapter_foreach() function Bastien Nocera
2026-01-20 16:30 ` [BlueZ 0/4] API fixes to make better bindings 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