public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* RE: fix build error with --enable-hid and --enable-hog options
  2025-04-30 14:36 [PATCH BlueZ 1/2] input: fix HID compilation w/o HoG Thomas Perale
@ 2025-04-30 16:04 ` bluez.test.bot
  0 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-04-30 16:04 UTC (permalink / raw)
  To: linux-bluetooth, thomas.perale

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

---Test result---

Test Summary:
CheckPatch                    PENDING   0.28 seconds
GitLint                       PENDING   0.31 seconds
BuildEll                      PASS      20.71 seconds
BluezMake                     PASS      2747.95 seconds
MakeCheck                     PASS      20.77 seconds
MakeDistcheck                 PASS      202.64 seconds
CheckValgrind                 PASS      281.15 seconds
CheckSmatch                   PASS      310.47 seconds
bluezmakeextell               PASS      130.71 seconds
IncrementalBuild              PENDING   0.24 seconds
ScanBuild                     PASS      927.24 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] 6+ messages in thread

* [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 v2 1/2] input: fix HID compilation w/o HoG
  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 ` 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
  2 siblings, 1 reply; 6+ messages in thread
From: Thomas Perale @ 2025-05-01 16:35 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 reading of the HOG specific configuration of the
'input.conf' file: LEAutoSecurity, to the HoG plugin file.

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

diff --git a/profiles/input/device.h b/profiles/input/device.h
index 7b87ce590..036a88980 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
@@ -25,7 +25,6 @@ void input_set_userspace_hid(char *state);
 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);
 
 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..f82648fec 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -57,11 +57,6 @@ 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];
@@ -228,10 +223,45 @@ static struct btd_profile hog_profile = {
 	.auto_connect	= true,
 };
 
+static void hog_read_config(void)
+{
+	const char filename[] = CONFIGDIR "/input.conf";
+	GKeyFile *config;
+	GError *err = NULL;
+	bool config_auto_sec;
+
+	config = g_key_file_new();
+	if (!config) {
+		error("Failed to allocate memory for config");
+		return;
+	}
+
+	if (!g_key_file_load_from_file(config, filename, 0, &err)) {
+		if (!g_error_matches(err, G_FILE_ERROR, G_FILE_ERROR_NOENT))
+			error("Parsing %s failed: %s", filename, err->message);
+		g_error_free(err);
+		g_key_file_free(config);
+		return;
+	}
+
+	config_auto_sec = g_key_file_get_boolean(config, "General",
+					"LEAutoSecurity", &err);
+	if (!err) {
+		DBG("input.conf: LEAutoSecurity=%s",
+				config_auto_sec ? "true" : "false");
+		auto_sec = config_auto_sec;
+	} else
+		g_clear_error(&err);
+
+	g_key_file_free(config);
+}
+
 static int hog_init(void)
 {
 	int err;
 
+	hog_read_config();
+
 	err = suspend_init(suspend_callback, resume_callback);
 	if (err < 0)
 		error("Loading suspend plugin failed: %s (%d)", strerror(-err),
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index 95ca0a7ee..1c0b6122a 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
@@ -85,7 +85,7 @@ static int input_init(void)
 	config = load_config_file(CONFIGDIR "/input.conf");
 	if (config) {
 		int idle_timeout;
-		gboolean classic_bonded_only, auto_sec;
+		gboolean classic_bonded_only;
 		char *uhid_enabled;
 
 		idle_timeout = g_key_file_get_integer(config, "General",
@@ -115,15 +115,6 @@ static int input_init(void)
 		} else
 			g_clear_error(&err);
 
-		auto_sec = g_key_file_get_boolean(config, "General",
-						"LEAutoSecurity", &err);
-		if (!err) {
-			DBG("input.conf: LEAutoSecurity=%s",
-					auto_sec ? "true" : "false");
-			input_set_auto_sec(auto_sec);
-		} else
-			g_clear_error(&err);
-
 	}
 
 	btd_profile_register(&input_profile);
-- 
2.49.0


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

* [PATCH BlueZ v2 2/2] input: fix HoG compilation w/o HID
  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 16:35 ` 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
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Perale @ 2025-05-01 16:35 UTC (permalink / raw)
  To: linux-bluetooth

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

```
> ./configure --disable-hid --enable-hog
> make
/usr/bin/ld: profiles/input/bluetoothd-hog.o: in function `hog_accept':
/home/../bluez/profiles/input/hog.c:184:(.text.hog_accept+0xbb): undefined reference to `input_get_auto_sec'
/usr/bin/ld: profiles/input/bluetoothd-hog.o: in function `hog_disconnect':
/home/../bluez/profiles/input/hog.c:205:(.text.hog_disconnect+0x12): undefined reference to `input_get_userspace_hid'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:6344: src/bluetoothd] Error 1
make: *** [Makefile:4695: all] Error 2
```

This patch duplicate the read of the 'UserspaceHID=persist' config entry
in the HoG plugin file to remove the dependency on the HID plugin files.

[1] 1782bfd79 input: Add support for UserspaceHID=persist

Fixes: https://github.com/bluez/bluez/issues/1228
---
 profiles/input/device.c |  5 -----
 profiles/input/device.h |  1 -
 profiles/input/hog.c    | 14 ++++++++++++--
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/profiles/input/device.c b/profiles/input/device.c
index a7bc4d44f..3642cc326 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -112,11 +112,6 @@ void input_set_userspace_hid(char *state)
 		error("Unknown value '%s'", state);
 }
 
-uint8_t input_get_userspace_hid(void)
-{
-	return uhid_state;
-}
-
 void input_set_classic_bonded_only(bool state)
 {
 	classic_bonded_only = state;
diff --git a/profiles/input/device.h b/profiles/input/device.h
index 036a88980..905669502 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
@@ -22,7 +22,6 @@ struct input_conn;
 
 void input_set_idle_timeout(int timeout);
 void input_set_userspace_hid(char *state);
-uint8_t input_get_userspace_hid(void);
 void input_set_classic_bonded_only(bool state);
 bool input_get_classic_bonded_only(void);
 
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index f82648fec..a3c876cf9 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -40,7 +40,6 @@
 #include "src/shared/gatt-client.h"
 #include "src/plugin.h"
 
-#include "device.h"
 #include "suspend.h"
 #include "attrib/att.h"
 #include "attrib/gattrib.h"
@@ -55,6 +54,7 @@ struct hog_device {
 
 static gboolean suspend_supported = FALSE;
 static bool auto_sec = true;
+static bool uhid_state_persist = false;
 static struct queue *devices = NULL;
 
 static void hog_device_accept(struct hog_device *dev, struct gatt_db *db)
@@ -203,7 +203,7 @@ static int hog_disconnect(struct btd_service *service)
 {
 	struct hog_device *dev = btd_service_get_user_data(service);
 
-	if (input_get_userspace_hid() == UHID_PERSIST)
+	if (uhid_state_persist)
 		bt_hog_detach(dev->hog, false);
 	else
 		bt_hog_detach(dev->hog, true);
@@ -229,6 +229,7 @@ static void hog_read_config(void)
 	GKeyFile *config;
 	GError *err = NULL;
 	bool config_auto_sec;
+	char *uhid_enabled;
 
 	config = g_key_file_new();
 	if (!config) {
@@ -253,6 +254,15 @@ static void hog_read_config(void)
 	} else
 		g_clear_error(&err);
 
+	uhid_enabled = g_key_file_get_string(config, "General",
+					"UserspaceHID", &err);
+	if (!err) {
+		DBG("input.conf: UserspaceHID=%s", uhid_enabled);
+		uhid_state_persist = strcasecmp(uhid_enabled, "persist") == 0;
+		free(uhid_enabled);
+	} else
+		g_clear_error(&err);
+
 	g_key_file_free(config);
 }
 
-- 
2.49.0


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

* RE: fix build error with --enable-hid and --enable-hog options
  2025-05-01 16:35 ` [PATCH BlueZ v2 1/2] input: fix HID compilation w/o HoG Thomas Perale
@ 2025-05-01 17:56   ` bluez.test.bot
  0 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-05-01 17:56 UTC (permalink / raw)
  To: linux-bluetooth, thomas.perale

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

---Test result---

Test Summary:
CheckPatch                    PENDING   0.27 seconds
GitLint                       PENDING   0.24 seconds
BuildEll                      PASS      20.39 seconds
BluezMake                     PASS      2592.88 seconds
MakeCheck                     PASS      20.49 seconds
MakeDistcheck                 PASS      198.00 seconds
CheckValgrind                 PASS      275.56 seconds
CheckSmatch                   PASS      301.80 seconds
bluezmakeextell               PASS      128.72 seconds
IncrementalBuild              PENDING   0.24 seconds
ScanBuild                     PASS      909.76 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] 6+ messages in thread

* Re: [PATCH BlueZ v2 0/2] fix build error with --enable-hid and --enable-hog options
  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 16:35 ` [PATCH BlueZ v2 2/2] input: fix HoG compilation w/o HID Thomas Perale
@ 2025-05-01 19:10 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+bluetooth @ 2025-05-01 19:10 UTC (permalink / raw)
  To: Thomas Perale; +Cc: linux-bluetooth

Hello:

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

On Thu,  1 May 2025 18:35:34 +0200 you wrote:
> 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:
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2,1/2] input: fix HID compilation w/o HoG
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b111b5e15eb7
  - [BlueZ,v2,2/2] input: fix HoG compilation w/o HID
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9c52188d7530

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] 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