|
From: Peter K. <pk...@us...> - 2001-04-19 10:29:14
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap_con.c 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Replaced all FNC and function names in strings with __FUNCTION__.
The diff of the modified file(s):
--- l2cap_con.c 2001/04/18 15:47:13 1.7
+++ l2cap_con.c 2001/04/19 10:29:14 1.8
@@ -122,9 +122,9 @@
void=20
init_con_list(void)
{
- con_list.first =3D 0;
- con_list.last =3D 0;
- con_list.cur =3D 0;
+ con_list.first =3D NULL;
+ con_list.last =3D NULL;
+ con_list.cur =3D NULL;
con_list.count =3D 0;
/* l2cap->cid_count =3D MIN_CID; Moved to l2cap_init */
}
@@ -132,17 +132,17 @@
void=20
free_list(void)
{
- D_CON("free_list : Freeing connection list\n");
+ D_CON(__FUNCTION__ ": Freeing connection list\n");
while (con_list.count)
delete_con(con_list.first);
- D_CON("free_list : Connection list removed\n");
+ D_CON(__FUNCTION__ ": Connection list removed\n");
}=20
=20
l2cap_con*=20
create_con(u16 hci_hdl, CID lcid, CID rcid)
{=20
l2cap_con* con;
- D_CON("Create_con rcid %d\n", rcid);
+ D_CON(__FUNCTION__ ": rcid %d\n", rcid);
if (con_list.count =3D=3D MAX_CONLISTSIZE) {
D_ERR("Connection list full!\n");
return NULL;
@@ -150,9 +150,8 @@
/* Add check if already in list ?? or rely on that otherwhere ?*/
=20=20=20
/* Allocate new element */
- if ((con =3D (l2cap_con*)kmalloc(sizeof(l2cap_con), GFP_ATOMIC))<0)
- {
- D_ERR("create_con : could not allocate new l2cap con\n");
+ if ((con =3D kmalloc(sizeof *con, GFP_ATOMIC)) < 0) {
+ D_ERR(__FUNCTION__ ": could not allocate new l2cap con\n");
return NULL;
}
=20=09
@@ -223,27 +222,25 @@
{
s32 i =3D 0;
=20=20=20
- D_CON("get_con : look for connections in state %s (%d)\n",=20
+ D_CON(__FUNCTION__ ": look for connections in state %s (%d)\n",=20
state_name[STATE], STATE);
- PRINTPKT("get_con : look for bd : ", bd, 6);
+ PRINTPKT(__FUNCTION__ ": 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) {
-=09=09=09
if (STATE =3D=3D ANY_STATE) {
/* simply look for all connections with
BD address bd*/
- PRINTPKT("get_con : found bd ",=20
+ PRINTPKT(__FUNCTION__ ": found bd ",=20
con_list.cur->remote_bd, 6);
=20
if (PARANOIA_CHECKCON(con_list.cur)) {
- D_ERR("%s l.%d NULL/magic failed\n",=20
- __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return NULL;
}=20=20
return con_list.cur;
} else if (con_list.cur->current_state =3D=3D STATE) {
- PRINTPKT("get_con : con_list bd ",=20
+ PRINTPKT(__FUNCTION__": con_list bd ",=20
con_list.cur->remote_bd, 6);
return con_list.cur;=20
}
@@ -253,7 +250,7 @@
con_list.cur =3D con_list.cur->next;
i++;
}
- D_CON("get_con : connection not found\n");
+ D_CON(__FUNCTION__ ": connection not found\n");
return NULL;
}
=20
@@ -268,59 +265,51 @@
l2cap_con*=20
check_remote_cid(u16 hdl, CID remote_cid)
{
-#define FNC "check_remote_cid : "
l2cap_con *found;
l2cap_con *new_con;
=20=20=20=20=20=20=20=20=20
-=20=20
- D_CON(FNC"hdl %d remote_cid %d\n", hdl, remote_cid);
+ D_CON(__FUNCTION__ ": hdl %d remote_cid %d\n", hdl, remote_cid);
=20
found =3D get_con_hcihdl(hdl);
=20
- if (found !=3D NULL)
- {
- D_CON(FNC"con handle found...\n");
+ if (found !=3D NULL) {
+ D_CON(__FUNCTION__ ": con handle found...\n");
if (found->remote_cid =3D=3D 0) {
-=20=20=20=20=20=20=20=20=20=20=20=20
/* This is the first l2cap connection over=20
this hci handle (remote_cid is only set=20
to 0 when receiving a new baseband=20
connection) */
=20=20=20=20=20=20=20=20=20=20=20=20=20
- D_CON(FNC"single connection / handle \n");
+ D_CON(__FUNCTION__ ": single connection/handle \n");
found->remote_cid =3D remote_cid;
SHOW_LIST();
return found;
} else if ((found->remote_cid >=3D 0x0040)=20
&& (found->remote_cid <=3D 0xffff)) {
-
/* at least one l2cap connection with this hci
handle exist now let's create another=20
connection over same hci handle */
=20=20=20=20=20=20=20=20=20=20=20=20=20
- D_CON(FNC"multiple connections / handle \n");
+ D_CON(__FUNCTION__ ": multiple connections/handle \n");
new_con =3D create_con(hdl, get_cid(),remote_cid);
if (new_con =3D=3D NULL) {
- D_ERR("l2cap_create_con : no connection created\n");
+ D_ERR(__FUNCTION__ ": no connection created\n");
return NULL;
}
=20=20=20=20=20=20=20=20=20=20=20=20=20
new_con->link_up=3DTRUE;
new_con->initiator=3DFALSE;
/* set bd address in new connection */
- memcpy(new_con->remote_bd,=20
- found->remote_bd, 6);
+ memcpy(new_con->remote_bd, found->remote_bd, 6);
=20=20=20=20=20=20=20=20=20=20=20=20=20
insert_con(new_con);
SHOW_LIST();
return new_con;
}
-=20=20=20=20=20=20=20=20=20=20
} else {
- D_CON(FNC"connection not found\n");
+ D_CON(__FUNCTION__ ": connection not found\n");
}
return NULL;
-#undef FNC
}
=20
/* Searches list for hci handle and returns first connection found */
@@ -328,13 +317,12 @@
get_con_hcihdl(u16 hdl)
{
s32 i =3D 0;
- D_CON("get_con_hcihdl : hdl %d\n", hdl);
+ D_CON(__FUNCTION__ ": hdl %d\n", hdl);
=20=20=20
while (i<con_list.count) {=20
if (con_list.cur->hci_hdl =3D=3D hdl) {
if (PARANOIA_CHECKCON(con_list.cur)) {
- D_ERR("%s l.d%d NULL/magic failed\n",=20
- __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return NULL;
}
return con_list.cur;
@@ -344,26 +332,24 @@
con_list.cur =3D con_list.cur->next;
i++;
}
- D_CON("get_con_hcihdl : no more connections on this handle\n");
+ D_CON(__FUNCTION__ ": no more connections on this handle\n");
return NULL;=20=20
}
=20=20
=20
-
/* Searches list for local cid and returns connection if found */
l2cap_con*=20
get_lcon(CID lcid)
{
s32 i =3D 0;
- D_CON("get_lcon : lcid %d con_list.count =3D %d\n",=20
+ D_CON(__FUNCTION__ ": lcid %d con_list.count =3D %d\n",=20
lcid, con_list.count);
=20=20=20
while (i<con_list.count) {=20
if (lcid =3D=3D con_list.cur->local_cid) {
=20=09=09=09
if (PARANOIA_CHECKCON(con_list.cur)) {
- D_ERR("%s l.%d NULL/magic failed\n",=20
- __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return NULL;
}
return con_list.cur;
@@ -373,7 +359,7 @@
con_list.cur =3D con_list.cur->next;
i++;
}
- D_CON("get_lcon : connection lcid : %d not found\n", lcid);
+ D_CON(__FUNCTION__ ": connection lcid : %d not found\n", lcid);
return NULL;
}
=20
@@ -382,14 +368,13 @@
get_rcon(CID rcid)
{
s32 i =3D 0;
- D_CON("get_rcon : rcid %d con_list.count =3D %d\n",=20
+ D_CON(__FUNCTION__ ": rcid %d con_list.count =3D %d\n",=20
rcid, con_list.count);
=20=20=20
while (i<con_list.count) {=20
if (rcid =3D=3D con_list.cur->remote_cid) {
if (PARANOIA_CHECKCON(con_list.cur)) {
- D_ERR("%s l.%d NULL/magic failed\n",=20
- __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return NULL;
}
return con_list.cur;
@@ -399,7 +384,7 @@
con_list.cur =3D con_list.cur->next;
i++;
}
- D_CON("get_rcon : connection rcid : %d not found\n", rcid);
+ D_CON(__FUNCTION__ ": connection rcid : %d not found\n", rcid);
return NULL;
}
=20
@@ -407,15 +392,15 @@
insert_con(l2cap_con *newcon)
{
l2cap_con *oldcon;
- oldcon =3D con_list.first; /* mark oldcon first */
- SHOW_CON("insert_con()", newcon);
+
+ SHOW_CON(__FUNCTION__, newcon);
if (!con_list.count) {
/* Empty list */
con_list.first =3D newcon;=20
con_list.cur =3D newcon;
con_list.last =3D newcon;
con_list.count++;
- D_CON("insert_con : now %d connections\n", con_list.count);
+ D_CON(__FUNCTION__ ": now %d connections\n", con_list.count);
newcon->next =3D con_list.first; /* Pos32 at itself */
newcon->prev =3D con_list.first;
return;
@@ -423,6 +408,7 @@
=20=20=20
/* Not empty */
=20=20=20
+ oldcon =3D con_list.first; /* mark oldcon first */
newcon->next =3D oldcon;
con_list.last->next =3D newcon;
oldcon->prev =3D newcon;
@@ -431,18 +417,18 @@
con_list.cur =3D newcon; /* Set current to new element */
con_list.first =3D newcon; /* Set first to new element */
con_list.count++;
- D_CON("insert_con : now %d connections\n", con_list.count);
+ D_CON(__FUNCTION__ ": now %d connections\n", con_list.count);
}
=20
s32=20
delete_con(l2cap_con* con)
{=20=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return -1;
}
=20
- SHOW_CON("delete_con : ", con);
+ SHOW_CON(__FUNCTION__, con);
=20
/* Issue a warning if connection is not in CLOSED */
if (con->current_state!=3DCLOSED)
@@ -451,17 +437,16 @@
if (con_list.count =3D=3D 1) {
/* Last element */
con_list.count--;
- con_list.first =3D 0;
- con_list.cur =3D 0;
- con_list.last =3D 0;
+ con_list.first =3D NULL;
+ con_list.cur =3D NULL;
+ con_list.last =3D NULL;
kfree(con);
- con =3D NULL;
D_CON("Now connection list is empty !\n");
return 0;
}
=20=20=20
- (con->prev)->next =3D con->next; /* Take it out */
- (con->next)->prev =3D con->prev;
+ con->prev->next =3D con->next; /* Take it out */
+ con->next->prev =3D con->prev;
=20=20=20
if (con_list.first =3D=3D con) /* Update first pointer */
con_list.first =3D con->next;
@@ -473,7 +458,6 @@
con_list.count--;
=20=20=20
kfree(con);=20
- con =3D NULL;
=20
return 0;=20=20
}
@@ -491,18 +475,16 @@
con_list.cur =3D con_list.cur->next;
i++;
}
- D_CON("count_con : %d l2cap_con's found with hci_hdl:%d\n",sum,hci_hdl);
+ D_CON(__FUNCTION__ ": %d l2cap_con's found with hci_hdl:%d\n",sum,hci_hdl=
);
return sum;
}
=20
/* 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)
- {
+ if (!(con->c_flags & FLAG_WAKEMEUP)) {
+ if (con->c_flags & FLAG_DONTSLEEP) {
printk("l2ca_wait : don't sleep flag set\n");
return;
}
@@ -511,20 +493,16 @@
printk("%s, sleep on wq 0x%x\n", str, (int)&con->wq);
interruptible_sleep_on(&con->wq);
printk("%s, woke up !\n", str);
- }
- else
- {
+ } else {
printk("%s, wq already in use\n", str);
}
}
=20
void=20
l2ca_wakeup(const char *str, l2cap_con *con)
-{
- if (con->c_flags & FLAG_WAKEMEUP)
{
- if (con->c_flags & FLAG_DONTSLEEP)
- {
+ 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;
@@ -533,23 +511,19 @@
con->c_flags &=3D ~FLAG_WAKEMEUP;
printk("%s, wake up wq 0x%x\n", str,(int)&con->wq);
wake_up_interruptible(&con->wq);
- }
- else
- {
+ } else {
printk("%s, wake up flag not set\n", str);
}
}
=20
#if L2CAP_SELFTEST
-
-
s32=20
remove_rcid(CID rcid) /* Searches for remote_cid */
{
D_CON("remove_rcid\n");
=20=20=20
if (!con_list.count) {
- D_CON("del_con() no connections in list\n");
+ D_CON(__FUNCTION__ ": no connections in list\n");
return -1;
}
delete_con(get_rcon(rcid));
@@ -572,27 +546,27 @@
insert_con(create_con(5, 5, 5));
insert_con(create_con(6, 6, 6));
show_list();
- remove_rcid((u16)3);
+ remove_rcid(3);
show_list();
- remove_rcid((u16)5);
+ remove_rcid(5);
show_list();
free_list();
show_list();
/* ... */
}
-#endif
+#endif /* L2CAP_SELFTEST */
=20
void=20
show_con(const u8* head, l2cap_con* con)
{
if (con) {=20
- printk("show_con : %s (%d:%d) [%s] [%s] r_mtu[%d] C[%s] link_up[%s]\n",
+ printk(__FUNCTION__ ": %s (%d:%d) [%s] [%s] r_mtu[%d] C[%s] link_up[%s]\=
n",
head, con->local_cid, con->remote_cid,
state_name[con->current_state], psm2str(con->psm),
con->remote_mtu, bool2str[con->initiator],=20
bool2str[con->link_up]);=09=09
} else {
- printk("show_con : NULL\n");
+ printk(__FUNCTION__ ": NULL\n");
}
}
=20
@@ -618,7 +592,7 @@
void=20
init_flow(flow *f)
{
- D_MISC("init_flow\n");
+ D_MISC(__FUNCTION__ "\n");
f->flags =3D 0;
f->service =3D 0x01;
f->token_rate =3D 0x00000000; /* No token rate specified, default */
@@ -631,8 +605,6 @@
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -=
- */
/* Status functions for /proc files */
=20
-
-
s32 l2cap_sprint_con(u8 *buf, l2cap_con* con)
{
u16 pos=3D0;
|