|
From: Peter K. <pk...@us...> - 2001-09-12 12:13:00
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
hci.c 1.177 1.178=20=20=20=20=20=20=20=20=20=20=20
l2cap.c 1.116 1.117=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Improved the calculation of the number of active connections.
The diff of the modified file(s):
--- hci.c 2001/09/10 12:10:56 1.177
+++ hci.c 2001/09/12 12:12:29 1.178
@@ -823,15 +823,16 @@
D_CMD(__FUNCTION__ ": CONNECTION_COMPLETE: %s\n",
get_err_msg(buf[0]));
=20
-
-
link_type =3D buf[9];
hci_hdl =3D CHAR2INT12(buf[2], buf[1]);
test_hci_hdl =3D hci_hdl;
=20
if (link_type =3D=3D ACL_LINK) {
+ if (lp_connect_cfm(buf + 3, (u32) buf[0], hci_hdl)) {
+ hci_ctrl.nbr_of_connections++;
+ hci_update_load_factor();
+ }
=20
- lp_connect_cfm(buf + 3, (u32) buf[0], hci_hdl);
#ifndef HCI_EMULATION
if (buf[0]) {
/* remove hci handle if connection failed */
@@ -864,8 +865,6 @@
}
/* reset variable again */
i_am_initiator =3D 0;
- hci_ctrl.nbr_of_connections++;
- hci_update_load_factor();
}
#endif /* HCI_EMULATION */
=20
@@ -881,6 +880,7 @@
=20=09=09
break;
}
+
case CONNECTION_REQUEST:
D_CMD(__FUNCTION__ ": CONNECTION_REQUEST\n");
=20
@@ -898,15 +898,17 @@
release_cmd_timer();
wake_up_interruptible(&hci_wq);
=20
- lp_disconnect_ind(CHAR2INT12(buf[2], buf[1]));
+ if (lp_disconnect_ind(CHAR2INT12(buf[2], buf[1])))
+ if (hci_ctrl.nbr_of_connections > 0) {
+ hci_ctrl.nbr_of_connections--;
+ hci_update_load_factor();
+ }
=20
/* FIXME: No more NBR_OF_COMPLETE_PACKETS will arrive for this
connection handle, if we only support point-to-point
connections we can acl_num by reading the buffersizes again,
but this will not work in a multipoint connection. */
=20
- hci_ctrl.nbr_of_connections--;
- hci_update_load_factor();
reset_hci_con_bd(CHAR2INT12(buf[2], buf[1]));
=20=09=09
if (hci_ctrl.nbr_of_connections <=3D 0) {
@@ -1001,12 +1003,11 @@
D_CMD(__FUNCTION__ ": COMMAND_STATUS\n");
=20=09=09
if (buf[0]) {=09=09=09
-
- /* fixme -- add parser for command status e.g when trying
- to connect an acl link which already is connected, a
- command status with "ACL link already exist" is returned=20
- This must be signalled using lp_connect_cfm (neg)
- */
+ /* fixme -- add parser for command status e.g when
+ trying to connect an acl link which already is
+ connected, a command status with "ACL link already
+ exist" is returned. This must be signalled using
+ lp_connect_cfm (neg) */
D_ERR(__FUNCTION__ ": COMMAND_STATUS: %s\n", get_err_msg(buf[0]));
=20
#ifdef USE_INQTIMER
@@ -1018,6 +1019,7 @@
update_nhcp(buf[1]);
wake_up_interruptible(&hci_wq);
break;
+
case FLUSH_OCCURRED:
D_CMD(__FUNCTION__ ": FLUSH_OCCURRED on hci_hdl %d\n",
CHAR2INT12(buf[1],buf[0]));
@@ -2795,7 +2797,6 @@
c_pkt.len =3D 3;
=20=20=20
return send_cmd_block((u8*) &c_pkt, c_pkt.len + CMD_HDR_LEN + HCI_HDR_LEN=
, DEFAULT_TIMEOUT);
-=09
}
=20
=20
@@ -3340,7 +3341,7 @@
if (cfm) {
#ifdef CONFIG_BLUETOOTH_EARLY_MSSWITCH
if (force_msswitch) {
- DSYS("lp_connect_rsp : early m/s switch\n");
+ DSYS(__FUNCTION__ ": Early m/s switch\n");
return accept_connection_request(bd_addr, MS_SWITCH_BECOME_MASTER);
} else
return accept_connection_request(bd_addr, MS_SWITCH_REMAIN_SLAVE);
@@ -3649,7 +3650,11 @@
D_CMD(__FUNCTION__ ": DISCONNECT->disconnection complete\n");
o_len =3D set_discon_cpl_event(out_event, CHAR2INT12(cmd->data[1], cmd-=
>data[0]), 0x13);
bt_write_lower_driver(o_event, o_len);
- lp_disconnect_ind(CHAR2INT12(cmd->data[1],cmd->data[0]));
+ if (lp_disconnect_ind(CHAR2INT12(cmd->data[1],cmd->data[0])))
+ if (hci_ctrl.nbr_of_connections > 0) {
+ hci_ctrl.nbr_of_connections--;
+ hci_update_load_factor();
+ }
break;
=20
case ACCEPT_CONNECTION_REQUEST:
@@ -3660,7 +3665,10 @@
sleep(1);
#endif
bt_write_lower_driver(o_event, o_len);
- lp_connect_cfm(data + 4, 0, 0);
+ if (lp_connect_cfm(data + 4, 0, 0)) {
+ hci_ctrl.nbr_of_connections++;
+ hci_update_load_factor();
+ }
break;
=20
case REJECT_CONNECTION_REQUEST:
--- l2cap.c 2001/09/12 11:45:02 1.116
+++ l2cap.c 2001/09/12 12:12:29 1.117
@@ -1365,7 +1365,7 @@
Confirms the request to establish a baseband connection
*/
=20=20=20
-void
+s32
lp_connect_cfm(u8 *bd_addr, u32 status, u16 con_hdl)
{
l2cap_con *con;
@@ -1388,7 +1388,7 @@
/* search for the corresponding l2cap connection */
if ((con =3D get_con(bd_addr, CLOSED)) =3D=3D NULL) {
D_ERR(__FUNCTION__ ": couldn't find l2cap con!\n");
- return;
+ return 0;
}
=20
con->c_status =3D status;
@@ -1405,7 +1405,7 @@
D_STATE(__FUNCTION__" Return NOW\n");
/* clear flag & set status */
con->c_flags &=3D ~FLAG_RETURNNOW;
- return;
+ return 0;
}
#ifdef __CRIS__
bt_connections++;
@@ -1424,6 +1424,8 @@
=20=09=09=09
l2ca_wakeup(__FUNCTION__, con);
}
+
+ return 1;
} else {
/* neg cfm */
D_STATE(__FUNCTION__ ": (neg) %s\n",get_err_msg(status));
@@ -1433,7 +1435,7 @@
=20=09=09
if (con->c_flags & FLAG_RETURNNOW) {
con->c_flags &=3D ~FLAG_RETURNNOW;
- return;
+ return 0;
}
=20
if (con->initiator) {
@@ -1444,14 +1446,17 @@
/* delete connection if non-initiator */
delete_con(con);
}=20
+
+ return 0;
}
}
=20=20
/* Indicates that one of the baseband connections has been shutdown */
-void
+s32
lp_disconnect_ind(u32 con_hdl)
{
l2cap_con *con;
+ s32 found =3D 0;
=20
/* temp link down */
DSYS(__FUNCTION__": Connection handle %d disconnected\n",
@@ -1489,6 +1494,8 @@
/* notify upper layers that phys link is down */
get_upper(con->psm)->disc_ind(con);
}
+
+ found =3D 1;
}
=20
D_CON(__FUNCTION__ ": no more l2cap cons on this handle\n");
@@ -1502,6 +1509,8 @@
else
D_ERR(__FUNCTION__ ": bt_connections =3D=3D 0\n");
#endif
+
+ return found;
}
=20
/* FIXME - lp_qos_violation_ind() */
|