Skip to contentSkip to conversation

hciattach: download configuration at maximum baud rate possible

PATCH Superseded Suraj Sumangala 2 participants 4 messages Nov 22, 2010 – Nov 23, 2010 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hciattach: download configuration at maximum baud rate possible

This patch support downloading configuration files for Atheros AR300x HCI UART chip at user requested baud rate instead of the initial baud rate.

---
 tools/hciattach.c       |    2 +-
 tools/hciattach.h       |    3 +-
 tools/hciattach_ath3k.c |   97 +++++++++++++++++++++++++++++++++-------------
 3 files changed, 72 insertions(+), 30 deletions(-)
tools/hciattach.c +1 -1
index fd53710..a47fa55 100644
@@ -304,7 +304,7 @@ static int texasalt(int fd, struct uart_t *u, struct termios *ti)
 
 static int ath3k_ps(int fd, struct uart_t *u, struct termios *ti)
 {
-	return ath3k_init(fd, u->bdaddr, u->speed);
+	return ath3k_init(fd, u->speed, u->init_speed, u->bdaddr, ti);
 }
 
 static int ath3k_pm(int fd, struct uart_t *u, struct termios *ti)
tools/hciattach.h +2 -1
index 2d26b77..fed0d11 100644
@@ -50,6 +50,7 @@ int texas_post(int fd, struct termios *ti);
 int texasalt_init(int fd, int speed, struct termios *ti);
 int stlc2500_init(int fd, bdaddr_t *bdaddr);
 int bgb2xx_init(int dd, bdaddr_t *bdaddr);
-int ath3k_init(int fd, char *bdaddr, int speed);
+int ath3k_init(int fd, int speed, int init_speed, char *bdaddr,
+						struct termios *ti);
 int ath3k_post(int fd, int pm);
 int qualcomm_init(int fd, int speed, struct termios *ti, const char *bdaddr);
tools/hciattach_ath3k.c +69 -28

139 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

Hi Suraj,

Quoted 8 lines · Suraj Sumangala

This patch support downloading configuration files for Atheros AR300x HCI UART chip at user requested baud rate instead of the initial baud rate.

---
 tools/hciattach.c       |    2 +-
 tools/hciattach.h       |    3 +-
 tools/hciattach_ath3k.c |   97 +++++++++++++++++++++++++++++++++-------------
 3 files changed, 72 insertions(+), 30 deletions(-)

In general the patch looks ok'ish, but:

tools/hciattach_ath3k.c int ath3k_init(int fd, char *bdaddr, int speed) · line 983

Quoted 4 lines
tools/hciattach_ath3k.c +4 -0
+	if (set_speed(fd, ti, speed) < 0) {
+		perror("Can't set required baud rate");
+		return -1;
+	}

To be consistent with the other return values, instead of -1 you should be returning a proper errno here. I.e. probably something like:

	if (set_speed(fd, ti, speed) < 0) {
		err = -errno;
		perror("Can't set required baud rate");
		return err;
	}
Quoted 1 line

+exit:

Could you use a label name that's more consistent with the rest of the BlueZ code base. I think "failed" would be the most suitable one here.

Johan

#2 lore raw

Hi Johan,

Quoted 6 lines · Johan Hedberg

In general the patch looks ok'ish, but:

Quoted 4 lines
Quoted 4 lines

+ if (set_speed(fd, ti, speed)< 0) {
+ perror("Can't set required baud rate");
+ return -1;
+ }

Quoted 7 lines

To be consistent with the other return values, instead of -1 you should be returning a proper errno here. I.e. probably something like:

	if (set_speed(fd, ti, speed)<  0) {
		err = -errno;
		perror("Can't set required baud rate");
		return err;

The set_speed function is defined in hciattach.c as

int set_speed(...)

{
	cfsetospeed(...);
	cfsetispeed(...);
	return tcsetattr(...);
}

I think this function could end up returning Success even if the first two function calls failed?

Does it makes sense to rewrite it to

int set_speed(...)

{
	if(cfsetospeed(...) < 0)
		return -errno;
	if(cfsetispeed(...) < 0)
		return -errno;
	return tcsetattr(...);
}

Then, I can return the error code directly in my function call.

Regards
Suraj

#3 lore raw

Hi Suraj,

Quoted 11 lines · Suraj Sumangala

The set_speed function is defined in hciattach.c as

int set_speed(...)

{
	cfsetospeed(...);
	cfsetispeed(...);
	return tcsetattr(...);
}

I think this function could end up returning Success even if the first two function calls failed?

Seems so, yes.

Quoted 8 lines

Does it makes sense to rewrite it to

int set_speed(...)

{
	if(cfsetospeed(...) < 0)
		return -errno;
	if(cfsetispeed(...) < 0)
		return -errno;

This looks fine, except for the coding style: space between if and (

Quoted 1 line
	return tcsetattr(...);

I guess this should be a similar if statement as for the other two calls, and then a final "return 0" at the end of the function. This set_speed fix should be in a separate patch though.

Johan