|
From: Mattias A. <mat...@us...> - 2001-03-30 12:01:34
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap_con.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* updated according to changes in l2cap_con struct
* added l2ca_wait / l2ca_wakeup used to block on a connection
* always set con =3D NULL after deleting it
The diff of the modified file(s):
--- l2cap_con.c 2001/02/28 13:31:00 1.4
+++ l2cap_con.c 2001/03/30 12:01:33 1.5
@@ -161,7 +161,6 @@
con->hci_hdl =3D hci_hdl;
con->local_cid =3D lcid;
con->remote_cid =3D rcid;=09
- con->ping_sent =3D 0;
=20
con->next =3D con;
con->prev =3D con;
@@ -174,6 +173,7 @@
void=20
reset_con(l2cap_con* con)
{
+ con->psm =3D 0; /* invalid */
con->local_cid =3D 0;
con->remote_cid =3D 0;
con->local_mtu =3D MTU_DEFAULT;
@@ -184,9 +184,21 @@
con->conf_rsp_ready =3D TRUE; /* haven't started anything yet */
con->initiator =3D FALSE; /* Other side initiated (default) */=20
con->magic =3D L2CAP_CON_MAGIC;
- con->ping_sent=3D0;
- con->inforeq_sent=3D0;
con->upper_con =3D NULL;
+ con->c_status =3D 0;
+ con->c_flags =3D 0;
+
+ con->timer.rtx_action =3D RTX_ACTION_DISCONNECT;
+ con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
+ con->timer.rtx_inuse =3D 0;
+ con->timer.ertx_inuse =3D 0;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+ con->wq =3D NULL;
+#else
+ init_waitqueue_head(&con->wq);
+#endif
+
}
=20
l2cap_con* get_first_con(void)
@@ -202,7 +214,6 @@
return con->next;
}
=20
-
/* Searches list for remote bd addr and returns connection if found
and if the connection is in state STATE */
=20
@@ -212,7 +223,7 @@
=20=20=20
D_CON("get_con : look for connections in state %s (%d)\n",=20
state_name[STATE], STATE);
- PRINTPKT("get_con : bd ", bd, 6);
+ PRINTPKT("get_con : look for bd : ", bd, 6);
=20=20=20
while (i<con_list.count) {=20
if (memcmp(bd, con_list.cur->remote_bd, 6) =3D=3D 0) {
@@ -220,7 +231,7 @@
if (STATE =3D=3D ANY_STATE) {
/* simply look for all connections with
BD address bd*/
- PRINTPKT("get_con : con_list bd ",=20
+ PRINTPKT("get_con : found bd ",=20
con_list.cur->remote_bd, 6);
=20
if (PARANOIA_CHECKCON(con_list.cur)) {
@@ -442,6 +453,7 @@
con_list.cur =3D 0;
con_list.last =3D 0;
kfree(con);
+ con =3D NULL;
D_CON("Now connection list is empty !\n");
return 0;
}
@@ -459,6 +471,7 @@
con_list.count--;
=20=20=20
kfree(con);=20
+ con =3D NULL;
=20=20=20
return 0;=20=20
}
@@ -478,6 +491,51 @@
}
D_CON("count_con : %d l2cap_con's found with hci_hdl:%d\n",sum,hci_hdl);
return sum;
+}
+
+/* only supports one call at a time */
+void
+l2ca_wait(const char *str, l2cap_con *con)
+{
+ if (!(con->c_flags & FLAG_WAKEMEUP))
+ {
+ if (con->c_flags & FLAG_DONTSLEEP)
+ {
+ printk("l2ca_wait : don't sleep flag set\n");
+ return;
+ }
+=09=20=20
+ con->c_flags |=3D FLAG_WAKEMEUP;
+ printk("%s, sleep on wq 0x%x\n", str, (int)&con->wq);
+ interruptible_sleep_on(&con->wq);
+ printk("%s, woke up !\n", str);
+ }
+ else
+ {
+ printk("%s, wq already in use\n", str);
+ }
+}
+
+void=20
+l2ca_wakeup(const char *str, l2cap_con *con)
+{
+ if (con->c_flags & FLAG_WAKEMEUP)
+ {
+ if (con->c_flags & FLAG_DONTSLEEP)
+ {
+ printk("l2ca_wakeup : don't sleep flag set\n");
+ con->c_flags &=3D ~FLAG_DONTSLEEP;
+ return;
+ }
+=09=20=20
+ con->c_flags &=3D ~FLAG_WAKEMEUP;
+ printk("%s, wake up wq 0x%x\n", str,(int)&con->wq);
+ wake_up_interruptible(&con->wq);
+ }
+ else
+ {
+ printk("%s, wake up flag not set\n", str);
+ }
}
=20
#if L2CAP_SELFTEST
|