public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Perale <thomas.perale@mind.be>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 2/2] input: fix HoG compilation w/o HID
Date: Wed, 30 Apr 2025 22:50:52 +0200	[thread overview]
Message-ID: <e741bb41-aa96-42c4-bad0-e3e256ac64bf@mind.be> (raw)
In-Reply-To: <CABBYNZK8wTSAD=4A3Rvc59tLwr7JvC1wWZbSduQCUNonjhk68Q@mail.gmail.com>

Hi Luiz,

Thanks for your review

> This doesn't look correct, the input.conf is used to configure both
> HID and HOG, so why do you think it is a good idea to ignore it if HID
> has been disabled? What we probably should do is to move the portion
> of input_init that are HOG specific, e.g. LEAutoSecurity, which is
> what is being used above.
> This part we will probably have to duplicate the parsing of
> UserspaceHID from input_init.
My reasoning was that since I didn't saw the 'input.conf' file being 
read in the hog_init I thought it was for a reason. While for the 
'LEAutoSecurity' option it's indeed probably better to encapsulate the 
functions only in the HOG file. For the 'UserspaceHID' option as you 
said, reading the option will need to be duplicated in both input_init 
and hog_init. If this is OK for you to read this option two times then I 
can send a v2 of my patch.

Thomas

On 4/30/25 5:20 PM, Luiz Augusto von Dentz wrote:
> Hi Thomas,
>
> On Wed, Apr 30, 2025 at 10:42 AM Thomas Perale <thomas.perale@mind.be> wrote:
>> 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 introduces the HAVE_HID symbol to conditionally call the
>> HID-related code in the HoG plugin only when HID is enabled.
>>
>> Additionally, hog_disconnect() reverts to its pre-[1] behavior when
>> the HID plugin is unavailable.
>>
>> [1] 1782bfd79 input: Add support for UserspaceHID=persist
>>
>> Fixes: https://github.com/bluez/bluez/issues/1228
>> ---
>>   configure.ac         |  3 +++
>>   profiles/input/hog.c | 11 ++++++++++-
>>   2 files changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 1e089aaa7..aa56b7b81 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -194,6 +194,9 @@ AM_CONDITIONAL(NETWORK, test "${enable_network}" != "no")
>>   AC_ARG_ENABLE(hid, AS_HELP_STRING([--disable-hid],
>>                  [disable HID profile]), [enable_hid=${enableval}])
>>   AM_CONDITIONAL(HID, test "${enable_hid}" != "no")
>> +if test "${enable_hid}" != "no"; then
>> +       AC_DEFINE(HAVE_HID, 1, [Define to 1 if you have HID support.])
>> +fi
>>
>>   AC_ARG_ENABLE(hog, AS_HELP_STRING([--disable-hog],
>>                  [disable HoG profile]), [enable_hog=${enableval}])
>> diff --git a/profiles/input/hog.c b/profiles/input/hog.c
>> index 97224f0d1..7ad94c474 100644
>> --- a/profiles/input/hog.c
>> +++ b/profiles/input/hog.c
>> @@ -40,13 +40,16 @@
>>   #include "src/shared/gatt-client.h"
>>   #include "src/plugin.h"
>>
>> -#include "device.h"
>>   #include "suspend.h"
>>   #include "attrib/att.h"
>>   #include "attrib/gattrib.h"
>>   #include "attrib/gatt.h"
>>   #include "hog-lib.h"
>>
>> +#ifdef HAVE_HID
>> +#include "device.h"
>> +#endif /* HAVE_HID */
>> +
>>   struct hog_device {
>>          struct btd_device       *device;
>>          struct bt_hog           *hog;
>> @@ -181,8 +184,10 @@ static int hog_accept(struct btd_service *service)
>>          if (!device_is_bonded(device, btd_device_get_bdaddr_type(device))) {
>>                  struct bt_gatt_client *client;
>>
>> +#ifdef HAVE_HID
>>                  if (!input_get_auto_sec())
>>                          return -ECONNREFUSED;
>> +#endif /* HAVE_HID */
> This doesn't look correct, the input.conf is used to configure both
> HID and HOG, so why do you think it is a good idea to ignore it if HID
> has been disabled? What we probably should do is to move the portion
> of input_init that are HOG specific, e.g. LEAutoSecurity, which is
> what is being used above.
>
>>                  client = btd_device_get_gatt_client(device);
>>                  if (!bt_gatt_client_set_security(client,
>> @@ -202,10 +207,14 @@ static int hog_disconnect(struct btd_service *service)
>>   {
>>          struct hog_device *dev = btd_service_get_user_data(service);
>>
>> +#ifdef HAVE_HID
>>          if (input_get_userspace_hid() == UHID_PERSIST)
>>                  bt_hog_detach(dev->hog, false);
>>          else
>>                  bt_hog_detach(dev->hog, true);
>> +#else
>> +       bt_hog_detach(dev->hog, false);
>> +#endif /* HAVE_HID */
> This part we will probably have to duplicate the parsing of
> UserspaceHID from input_init.
>
>>          btd_service_disconnecting_complete(service, 0);
>>
>> --
>> 2.49.0
>>
>>
>

      reply	other threads:[~2025-04-30 20:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30 14:36 [PATCH BlueZ 0/2] fix build error with --enable-hid and --enable-hog options Thomas Perale
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
2025-04-30 14:36 ` [PATCH BlueZ 2/2] input: fix HoG compilation w/o HID Thomas Perale
2025-04-30 15:20   ` Luiz Augusto von Dentz
2025-04-30 20:50     ` Thomas Perale [this message]

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=e741bb41-aa96-42c4-bad0-e3e256ac64bf@mind.be \
    --to=thomas.perale@mind.be \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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