Skip to contentSkip to conversation

btattach: Update for glibc 2.42 compatability

PATCH Applied Aaron Brice 4 participants 6 messages Sep 3 – Sep 4 Bluetooth drivers

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover btattach: Update for glibc 2.42 compatability

btattach is not setting the baud rate correctly on systems with newer glibc such as Ubuntu 26.04. In glibc 2.42 the baud rate termios.h constants changed value, B115200 was 0x1002 which was the struct termios c_cflag enum bits, but in 2.42 they changed cfsetspeed() to accept arbitrary rates and not just the baud enum values, and B115200 was changed to the value 115200. This means you can no longer set the speed with c_cflag |= B115200 and should use cfsetspeed() to be compatible with both versions.

Aaron Brice (1):
btattach: Update for glibc 2.42 compatability

 tools/btattach.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/1 btattach: Update for glibc 2.42 compatability

glibc 2.42 baud rate constants changed, use cfsetspeed to be compatible with newer glibc.

---
 tools/btattach.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/btattach.c +6 -1
index 5f7d19093..cdd7b125b 100644
@@ -64,7 +64,12 @@ static int open_serial(const char *path, unsigned int speed, bool flowctl)
 	memset(&ti, 0, sizeof(ti));
 	cfmakeraw(&ti);
 
-	ti.c_cflag |= (speed | CLOCAL | CREAD);
+	ti.c_cflag |= (CLOCAL | CREAD);
+	if (cfsetspeed(&ti, speed) < 0) {
+		perror("Failed to set serial port speed");
+		close(fd);
+		return -1;
+	}
 
 	if (flowctl) {
 		/* Set flow control */
Signature · 1 line
2.53.0
#2 lore raw
Quoted 3 lines · Aaron Brice

glibc 2.42 baud rate constants changed, use cfsetspeed to be compatible
with newer glibc.

The explanation in your cover letter, which will not be committed, should be in your patch's commit message, which will be committed.

Cheers

Quoted 23 lines

---
 tools/btattach.c | 7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)
tools/btattach.c +0 -0
index 5f7d19093..cdd7b125b 100644
@@ -64,7 +64,12 @@ static int open_serial(const char *path, unsigned
 int speed, bool flowctl)
  	memset(&ti, 0, sizeof(ti));
  	cfmakeraw(&ti);

tools/btattach.c +6 -1
-	ti.c_cflag |= (speed | CLOCAL | CREAD);
+	ti.c_cflag |= (CLOCAL | CREAD);
+	if (cfsetspeed(&ti, speed) < 0) {
+		perror("Failed to set serial port speed");
+		close(fd);
+		return -1;
+	}


  if (flowctl) {
  /* Set flow control */

#3 lore raw
In reply to Aaron Brice

Subject should be "compatibility" (3 "i"s)

Quoted 26 lines · Aaron Brice

glibc 2.42 baud rate constants changed, use cfsetspeed to be compatible
with newer glibc.
---
 tools/btattach.c | 7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)
tools/btattach.c +0 -0
index 5f7d19093..cdd7b125b 100644
@@ -64,7 +64,12 @@ static int open_serial(const char *path, unsigned
 int speed, bool flowctl)
  	memset(&ti, 0, sizeof(ti));
  	cfmakeraw(&ti);

tools/btattach.c +6 -1
-	ti.c_cflag |= (speed | CLOCAL | CREAD);
+	ti.c_cflag |= (CLOCAL | CREAD);
+	if (cfsetspeed(&ti, speed) < 0) {
+		perror("Failed to set serial port speed");
+		close(fd);
+		return -1;
+	}


  if (flowctl) {
  /* Set flow control */

#4 lore raw
In reply to Aaron Brice

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=1157334

---Test result---

Test Summary:

CheckPatch                    FAIL      0.30 seconds
GitLint                       PASS      0.21 seconds
BuildEll                      PASS      20.51 seconds
BluezMake                     PASS      607.12 seconds
CheckSmatch                   PASS      313.35 seconds
bluezmakeextell               PASS      102.40 seconds
IncrementalBuild              PASS      605.31 seconds
ScanBuild                     PASS      984.67 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,1/1] btattach: Update for glibc 2.42 compatability WARNING:TYPO_SPELLING: 'compatability' may be misspelled - perhaps 'compatibility'? #85:
Subject: [PATCH BlueZ 1/1] btattach: Update for glibc 2.42 compatability

                                                           ^^^^^^^^^^^^^

/github/workspace/src/patch/14788391.patch total: 0 errors, 1 warnings, 13 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14788391.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

https://github.com/bluez/bluez/pull/2487

---
Regards,
Linux Bluetooth

#5 lore raw
In reply to Aaron Brice
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 10 lines · On Thu, 3 Sep 2026 11:27:08 -0700 you wrote:

btattach is not setting the baud rate correctly on systems with newer glibc such as Ubuntu 26.04. In glibc 2.42 the baud rate termios.h constants changed value, B115200 was 0x1002 which was the struct termios c_cflag enum bits, but in 2.42 they changed cfsetspeed() to accept arbitrary rates and not just the baud enum values, and B115200 was changed to the value 115200. This means you can no longer set the speed with c_cflag |= B115200 and should use cfsetspeed() to be compatible with both versions.

[...]

Here is the summary with links:
- [BlueZ,1/1] btattach: Update for glibc 2.42 compatability

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=12f5eb726c6e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html