Skip to contentSkip to conversation

hciattach: makes set_speed return error if any one operation fail

PATCH In review Suraj Sumangala 2 participants 2 messages Nov 23, 2010 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hciattach: makes set_speed return error if any one operation fail

This patch lets set_speed function changing UART baud rate to return an error code if any one operation fails instead of returning only the last operation's status.

---
 tools/hciattach.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
tools/hciattach.c +10 -3
index fd53710..7cb8e9e 100644
@@ -144,9 +144,16 @@ static int uart_speed(int s)
 
 int set_speed(int fd, struct termios *ti, int speed)
 {
-	cfsetospeed(ti, uart_speed(speed));
-	cfsetispeed(ti, uart_speed(speed));
-	return tcsetattr(fd, TCSANOW, ti);
+	if (cfsetospeed(ti, uart_speed(speed)) < 0)
+		return -errno;
+
+	if (cfsetispeed(ti, uart_speed(speed)) < 0)
+		return -errno;
+
+	if (tcsetattr(fd, TCSANOW, ti) < 0)
+		return -errno;
+
+	return 0;
 }
 
 /*
Signature · 1 line
1.7.0.4
#1 lore raw

Hi Suraj,

Quoted 7 lines · Suraj Sumangala

This patch lets set_speed function changing UART baud rate to return an error code if any one operation fails instead of returning only the last operation's status.

---
 tools/hciattach.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

Pushed upstream. Thanks.

Johan