public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 0/2] fix build error with --enable-hid and --enable-hog options
@ 2025-05-01 16:35 Thomas Perale
  2025-05-01 16:35 ` [PATCH BlueZ v2 1/2] input: fix HID compilation w/o HoG Thomas Perale
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thomas Perale @ 2025-05-01 16:35 UTC (permalink / raw)
  To: linux-bluetooth

This patch series fixes build failures when --enable-hid and --enable-hog
are not enabled together. The issue is documented in the following ticket:

https://github.com/bluez/bluez/issues/1228.

Compiling with the --enable-hid --disable-hog option would give an
error because the HID plugin relied on functions defined in the HoG
plugin:

```
> ./configure --enable-hid --disable-hog
...
> make
...
  CCLD     src/bluetoothd
/usr/bin/ld: profiles/input/bluetoothd-manager.o: in function `input_init':
/home/../bluez/profiles/input/manager.c:122:(.text.input_init+0x1c8): undefined reference to `input_set_auto_sec'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:6376: src/bluetoothd] Error 1
```

Compiling with the --disable-hid --enable-hog option would give an
error because the HID plugin relied on functions defined in the HoG
plugin:

```
> ./configure --disable-hid --enable-hog
> make
...
/usr/bin/ld: profiles/input/bluetoothd-hog.o: in function `hog_disconnect':
/home/../bluez-5.79/profiles/input/hog.c:211:(.text.hog_disconnect+0x12): undefined reference to `input_get_userspace_hid'
collect2: error: ld returned 1 exit status
```

This patch series follows the indication gave by Vudentz to make both
plugins independents of each other.

[changes in v2]

Following the review of Luiz Augusto von Dentz, the reading of the
LEAutoSecurity config entry is moved to the HoG files and the reading of
UserspaceHID entry is duplicated in the HoG file.

Thomas Perale (2):
  input: fix HID compilation w/o HoG
  input: fix HoG compilation w/o HID

 configure.ac            |  3 +++
 profiles/input/device.c | 11 +++++++++++
 profiles/input/device.h |  1 +
 profiles/input/hog.c    | 19 +++++++++++--------
 4 files changed, 26 insertions(+), 8 deletions(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH BlueZ 1/2] input: fix HID compilation w/o HoG
@ 2025-04-30 14:36 Thomas Perale
  2025-04-30 16:04 ` fix build error with --enable-hid and --enable-hog options bluez.test.bot
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Perale @ 2025-04-30 14:36 UTC (permalink / raw)
  To: linux-bluetooth

Commit [1] introduced a dependency with the HID plugin in the HoG code
As a result, building with --enable-hid --disable-hog caused linker
errors due to undefined references to HoG-related functions:

```
> ./configure --enable-hid --disable-hog
...
> make
...
  CCLD     src/bluetoothd
/usr/bin/ld: profiles/input/bluetoothd-manager.o: in function `input_init':
/home/../bluez/profiles/input/manager.c:122:(.text.input_init+0x1c8): undefined reference to `input_set_auto_sec'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:6376: src/bluetoothd] Error 1
```

This patch moves the `input_set_auto_sec` function to
`profiles/input/device.c` file so it remains defined even when HoG is
disabled.

[1] f2778f587 input: Add LEAutoSecurity setting to input.conf
---
 profiles/input/device.c | 11 +++++++++++
 profiles/input/device.h |  1 +
 profiles/input/hog.c    |  8 +-------
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index a7bc4d44f..d27cfccee 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -92,6 +92,7 @@ struct input_device {
 static int idle_timeout = 0;
 static uhid_state_t uhid_state = UHID_ENABLED;
 static bool classic_bonded_only = true;
+static bool auto_sec = true;
 
 void input_set_idle_timeout(int timeout)
 {
@@ -127,6 +128,16 @@ bool input_get_classic_bonded_only(void)
 	return classic_bonded_only;
 }
 
+void input_set_auto_sec(bool state)
+{
+	auto_sec = state;
+}
+
+bool input_get_auto_sec(void)
+{
+	return auto_sec;
+}
+
 static void input_device_enter_reconnect_mode(struct input_device *idev);
 static int connection_disconnect(struct input_device *idev, uint32_t flags);
 
diff --git a/profiles/input/device.h b/profiles/input/device.h
index 7b87ce590..9d31fdc51 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
@@ -26,6 +26,7 @@ uint8_t input_get_userspace_hid(void);
 void input_set_classic_bonded_only(bool state);
 bool input_get_classic_bonded_only(void);
 void input_set_auto_sec(bool state);
+bool input_get_auto_sec(void);
 
 int input_device_register(struct btd_service *service);
 void input_device_unregister(struct btd_service *service);
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 017e320f0..97224f0d1 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -54,14 +54,8 @@ struct hog_device {
 };
 
 static gboolean suspend_supported = FALSE;
-static bool auto_sec = true;
 static struct queue *devices = NULL;
 
-void input_set_auto_sec(bool state)
-{
-	auto_sec = state;
-}
-
 static void hog_device_accept(struct hog_device *dev, struct gatt_db *db)
 {
 	char name[248];
@@ -187,7 +181,7 @@ static int hog_accept(struct btd_service *service)
 	if (!device_is_bonded(device, btd_device_get_bdaddr_type(device))) {
 		struct bt_gatt_client *client;
 
-		if (!auto_sec)
+		if (!input_get_auto_sec())
 			return -ECONNREFUSED;
 
 		client = btd_device_get_gatt_client(device);
-- 
2.49.0


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

end of thread, other threads:[~2025-05-01 19:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 16:35 [PATCH BlueZ v2 0/2] fix build error with --enable-hid and --enable-hog options Thomas Perale
2025-05-01 16:35 ` [PATCH BlueZ v2 1/2] input: fix HID compilation w/o HoG Thomas Perale
2025-05-01 17:56   ` fix build error with --enable-hid and --enable-hog options bluez.test.bot
2025-05-01 16:35 ` [PATCH BlueZ v2 2/2] input: fix HoG compilation w/o HID Thomas Perale
2025-05-01 19:10 ` [PATCH BlueZ v2 0/2] fix build error with --enable-hid and --enable-hog options patchwork-bot+bluetooth
  -- strict thread matches above, loose matches on Subject: below --
2025-04-30 14:36 [PATCH BlueZ 1/2] input: fix HID compilation w/o HoG Thomas Perale
2025-04-30 16:04 ` fix build error with --enable-hid and --enable-hog options bluez.test.bot

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