Skip to contentSkip to conversation

Fixes in rfcomm tty

PATCH New Denis KENZIOR 2 participants 2 messages Dec 14, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixes in rfcomm tty

Marcel,

This patch fixes two issues in the RFCOMM tty support:

1) If the TTY socket receives data before TTY is created, or the TTY is not opened (e.g. on devfs) then the data is discarded. This makes it impossible to support some protocols which send data right away, e.g. DUN and HFP

2) The serial core sends us lots of 1 byte requests when dealing with canonical ttys (e.g. ones that echo). This attempts to fix this issue by tweaking how the wfree is handled and also tries to be intelligent in the handling these 1 byte requests. Currently once the TTY runs out of TX_Credits, it will just append the pending 1 byte requests onto the tail of the TX_Queue.

-Denis

net/bluetooth/rfcomm/core.c +5 -1
diff -r -U5 a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
@@ -457,11 +457,10 @@
 	BT_DBG("dlc %p mtu %d len %d", d, d->mtu, len);
 
 	if (len > d->mtu)
 		return -EINVAL;
 
-	rfcomm_make_uih(skb, d->addr);
 	skb_queue_tail(&d->tx_queue, skb);
 
 	if (!test_bit(RFCOMM_TX_THROTTLED, &d->flags))
 		rfcomm_schedule(RFCOMM_SCHED_TX);
 	return len;
@@ -1021,10 +1020,11 @@
 		put_unaligned(htobs(__len16(len)), (__le16 *) &hdr->len);
 	} else {
 		hdr = (void *) skb_push(skb, 3);
 		hdr->len = __len8(len);
 	}
+	
 	hdr->addr = addr;
 	hdr->ctrl = __ctrl(RFCOMM_UIH, 0);
 
 	crc = skb_put(skb, 1);
 	*crc = __fcs((void *) hdr);
@@ -1673,19 +1673,23 @@
 	}
 
 	if (test_bit(RFCOMM_TX_THROTTLED, &d->flags))
 		return skb_queue_len(&d->tx_queue);
 
+	/* Need to lock this in case the tty driver might be messing with the tx queue */
+	rfcomm_dlc_lock(d);
 	while (d->tx_credits && (skb = skb_dequeue(&d->tx_queue))) {
+		rfcomm_make_uih(skb, d->addr);
 		err = rfcomm_send_frame(d->session, skb->data, skb->len);
 		if (err < 0) {
 			skb_queue_head(&d->tx_queue, skb);
 			break;
 		}
 		kfree_skb(skb);
 		d->tx_credits--;
 	}
+	rfcomm_dlc_unlock(d);
 
 	if (d->cfc && !d->tx_credits) {
 		/* We're out of TX credits.
 		 * Set TX_THROTTLED flag to avoid unnesary wakeups by dlc_send. */
 		set_bit(RFCOMM_TX_THROTTLED, &d->flags);
net/bluetooth/rfcomm/tty.c +76 -7

207 lines not on this page · raw message

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#1 lore raw

PATCH 1/1 Fixes in headset_send

Hello,

The following patch fixes headset_send(). It uses write() instead of g_io_channel_write().

Let me know if anything needs to be changed.

-Alok.

audio/headset.c +6 -7
index 446c1eb..2b9bfc8 100644
@@ -136,7 +136,8 @@ static int headset_send(struct headset *hs, char *format, ...)
 {
 	char rsp[BUF_SIZE];
 	va_list ap;
-	gsize total_written, written, count;
+	ssize_t total_written, written, count;
+	int fd;
 
 	va_start(ap, format);
 	count = vsnprintf(rsp, sizeof(rsp), format, ap);
@@ -151,14 +152,12 @@ static int headset_send(struct headset *hs, char *format, ...)
 	}
 
 	written = total_written = 0;
+	fd = g_io_channel_unix_get_fd(hs->rfcomm);
 
 	while (total_written < count) {
-		GIOError io_err;
-
-		io_err = g_io_channel_write(hs->rfcomm, rsp + total_written,
-						count - total_written,
-						&written);
-		if (io_err != G_IO_ERROR_NONE)
+		written = write(fd, rsp + total_written,
+				count - total_written);
+		if (written < 0)
 			return -errno;
 
 		total_written += written;

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel