|
From: Mats F. <ma...@us...> - 2001-06-19 06:13:32
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bluetooth.c 1.183 1.184=20=20=20=20=20=20=20=20=20=20=20
btmem.c 1.42 1.43=20=20=20=20=20=20=20=20=20=20=20=20
rfcomm.c 1.113 1.114=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
We need to keep track of how many bytes there are in the BT-buf for each li=
ne
The diff of the modified file(s):
--- bluetooth.c 2001/06/15 12:30:03 1.183
+++ bluetooth.c 2001/06/19 06:13:01 1.184
@@ -470,12 +470,7 @@
static s32
bt_chars_in_buffer(struct tty_struct *tty)
{
- u16 n =3D buf_byte_count();
- /* what if multiple pppd are running and one pppd=20
- ends, then this won't be zero.... */
-
- /* fixme -- we must find number bytes belonging to=20
- this line */
+ u16 n =3D buf_byte_count(GET_TTYLINE(tty));
=20
BT_DRIVER("bt_chars_in_buffer : %d\n", n);=20=20
return n;
@@ -1578,7 +1573,7 @@
=20
/* If buffer usage is less than BTMEM_UNTHROTTLE_SIZE check if we=20
should wake up ldisc */
- if (buf_byte_count() >=3D BTMEM_UNTHROTTLE_SIZE) {
+ if (buf_byte_count(-1) >=3D BTMEM_UNTHROTTLE_SIZE) {
return;
}=09
=20=09
@@ -2624,7 +2619,7 @@
statename(SESSIONSTATE(line)), NBR_CTRL_FDS);
=20
pos +=3D sprintf(buf+pos, "\n[BTMEM]\n");
- pos +=3D sprintf(buf+pos, "Buffer holds : %d\n", buf_byte_count());
+ pos +=3D sprintf(buf+pos, "Buffer holds : %d\n", buf_byte_count(-1));
pos +=3D sprintf(buf+pos, "Bytes left : %d\n", buf_write_room());
=20
return pos;
--- btmem.c 2001/06/06 14:57:44 1.42
+++ btmem.c 2001/06/19 06:13:01 1.43
@@ -327,6 +327,7 @@
tx->magic =3D 0x4321;
tx->subscr_len =3D send_len;
tx->flushed =3D 0;
+ tx->line =3D -1;
=20
sti();
return tx;
@@ -341,9 +342,52 @@
=20
/* Returns total number of bytes in buffer (fragmented) */
=20
-s32 buf_byte_count()
+s32 buf_byte_count(s32 line)
{
+ u8 *pos =3D bt_buf.head;
+ bt_tx_buf *tx;
+ u32 sum =3D 0;
+
+ if (line < 0) {
+ //printk(__FUNCTION__": Total bytes in buffer %d\n", bt_buf.count);
return bt_buf.count;
+ } else {
+ if (bt_buf.free > bt_buf.send) {
+ /* read from send -> free */
+ pos =3D bt_buf.send;
+ while (pos < bt_buf.free) {
+ tx =3D (bt_tx_buf *)(pos);
+ if (tx->line =3D=3D line) {
+ sum +=3D tx->subscr_len;
+ }
+ pos +=3D BT_TX_HDRSIZE + tx->subscr_len;
+ }
+ } else if (bt_buf.free < bt_buf.send) {
+ /* read send -> toss_tail + read from head -> free */
+ pos =3D bt_buf.send;
+ while (pos < bt_buf.toss_tail) {
+ tx =3D (bt_tx_buf *)(pos);
+ if (tx->line =3D=3D line) {
+ sum +=3D tx->subscr_len;
+ }
+ pos +=3D BT_TX_HDRSIZE + tx->subscr_len;
+ }
+=09=09=09
+ pos =3D bt_buf.head;=20
+ while (pos < bt_buf.free) {
+ tx =3D (bt_tx_buf*)(pos);
+ if (tx->line =3D=3D line) {
+ sum +=3D tx->subscr_len;
+ }
+ pos +=3D BT_TX_HDRSIZE + tx->subscr_len;
+ }
+ } else {
+ /* Buffer empty */
+ sum =3D 0;
+ }
+ //printk(__FUNCTION__": %d chars in buf for line:%d, total:%d\n", sum, l=
ine, bt_buf.count);
+ return sum;
+ }
}
=20
/* Returns unfragmented buffer space */=20
--- rfcomm.c 2001/06/14 10:45:24 1.113
+++ rfcomm.c 2001/06/19 06:13:01 1.114
@@ -1926,6 +1926,7 @@
=20
/* FIXME - How should we propagate result up to higher layers ?
through len or success/no success? */
+ tx_buf->line =3D rfcomm->line;
l2cap_send_data(tx_buf, rfcomm->l2cap);
return len;
}
|