|
From: Peter K. <pk...@us...> - 2001-04-18 14:25:31
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.99 1.100=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Made local functions static.
* insert_upper() now returns -ENOMEM if memory allocation failed.
* Changed a number of "return -1;" to return something more appropriate.
* Replaced all FNC and function names in strings with __FUNCTION__.
The diff of the modified file(s):
--- l2cap.c 2001/04/12 15:10:01 1.99
+++ l2cap.c 2001/04/18 14:25:30 1.100
@@ -63,6 +63,7 @@
#include <string.h>
#include <sys/time.h>
#include <signal.h>
+#include <errno.h>
#include "include/l2cap.h"
#include "include/hci.h"
#include "include/l2cap_internal.h"
@@ -212,9 +213,9 @@
static void print_flow(flow *f);
static s32 l2cap_cmdrej(s32 hci_hdl, u8 reason, u8 *opt_data, s32 opt_len);
=20
-void insert_upper(protocol_layer *upper_layer);
-protocol_layer* get_upper(u32 psm);
-void remove_all_upper(void);
+static s32 insert_upper(protocol_layer *upper_layer);
+static protocol_layer* get_upper(u32 psm);
+static void remove_all_upper(void);
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
=20
@@ -225,20 +226,20 @@
=20
=20
#ifdef __KERNEL__
-void l2cap_rtx_timeout(unsigned long ptr);
-void l2cap_ertx_timeout(unsigned long ptr);
+static void l2cap_rtx_timeout(unsigned long ptr);
+static void l2cap_ertx_timeout(unsigned long ptr);
#else /* usermode stack */
-l2cap_con *timeout_con =3D NULL;
-s32 timer_cancelled =3D 0;
-void l2cap_rtx_timeout(void);
-void l2cap_ertx_timeout(unsigned long ptr);
+static l2cap_con *timeout_con =3D NULL;
+static s32 timer_cancelled =3D 0;
+static void l2cap_rtx_timeout(void);
+static void l2cap_ertx_timeout(unsigned long ptr);
#endif
=20
-void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
-void disable_rtx(l2cap_con *con);
+static void start_rtx(l2cap_con *con, unsigned short timeout, unsigned sho=
rt action);
+static void disable_rtx(l2cap_con *con);
=20
-void start_ertx(l2cap_con *con, unsigned short timeout);
-void disable_ertx(l2cap_con *con);
+static void start_ertx(l2cap_con *con, unsigned short timeout);
+static void disable_ertx(l2cap_con *con);
=20
#endif
=20
@@ -292,8 +293,7 @@
(l2cap->my_bd[2] =3D=3D 0) && (l2cap->my_bd[3] =3D=3D 0) &&
(l2cap->my_bd[4] =3D=3D 0) && (l2cap->my_bd[5] =3D=3D 0))
D_ERR("Failed to get local BD addr\n");
- else
- {
+ else {
i =3D l2cap_sprint_bd(bd_name, l2cap->my_bd);
bd_name[i] =3D 0;
DSYS("Local bd [%s]\n", bd_name);
@@ -336,15 +336,14 @@
void=20
l2cap_register_default_upper(struct protocol_layer *prot)
{
- memcpy(&default_protocol, prot, sizeof(protocol_layer));
+ memcpy(&default_protocol, prot, sizeof default_protocol);
}
=20
s32=20
l2cap_shutdown(void)
{
DSYS("Shutting down L2CAP\n");
- if (!l2cap->initiated)
- {
+ if (!l2cap->initiated) {
D_ERR("L2CAP not initiated\n");
return -1;
}
@@ -368,6 +367,7 @@
#ifdef __CRIS__
bt_connections =3D 0;
#endif
+
/*ALWAYS SUCCESS*/
return 0;
}
@@ -379,49 +379,44 @@
l2cap_register_upper(u16 psm, struct protocol_layer *prot)=20
{
if (((psm % 2) =3D=3D 0) || (prot =3D=3D NULL)) {
- D_ERR("l2cap_register_upper : incorrect parameters\n");
- return -1;
+ D_ERR(__FUNCTION__ ": incorrect parameters\n");
+ return -EINVAL;
}
=20=20=20=20=20
- D_MISC("l2cap_register_upper : psm 0x%x\n", psm);
+ D_MISC(__FUNCTION__ ": psm 0x%x\n", psm);
=20
if ((psm > MAX_PSM) && (psm < MIN_DYNAMIC_PSM)) {
- D_ERR("l2cap_register_upper : value of psm reserved\n");
- return -1;
+ D_ERR(__FUNCTION__ ": value of psm reserved\n");
+ return -EINVAL;
}
=20
if (psm > MAX_DYNAMIC_PSM) {
- D_ERR("l2cap_register_upper : psm not valid!\n");
- return -1;
+ D_ERR(__FUNCTION__ ": psm not valid!\n");
+ return -EINVAL;
}
=20
prot->psm =3D psm;
- insert_upper(prot);
- return 1;
+ return insert_upper(prot);
}
=20
/* Inserts the function pointers to a new upper layer in the list */
=20
-void
+s32
insert_upper(protocol_layer *upper_layer)
{
- protocol_layer *tmp_layer, *new_layer;
- D_MISC("insert_upper: Inserting layer psm:0x%x\n",upper_layer->psm);
+ protocol_layer *new_layer;
+ D_MISC(__FUNCTION__ ": Inserting layer psm:0x%x\n", upper_layer->psm);
=20=09
- new_layer =3D (protocol_layer*) kmalloc(sizeof(protocol_layer),
- GFP_ATOMIC);
- memcpy(new_layer, upper_layer, sizeof(protocol_layer));
- new_layer->next_layer =3D NULL;
+ if (!(new_layer =3D kmalloc(sizeof *new_layer, GFP_ATOMIC)))
+ return -ENOMEM;
=20=09
- tmp_layer =3D l2cap->upper_layers;
- if (tmp_layer !=3D NULL) {
- while (tmp_layer->next_layer !=3D NULL) {
- tmp_layer =3D tmp_layer->next_layer;
- }
- tmp_layer->next_layer =3D new_layer;
- } else {
+ memcpy(new_layer, upper_layer, sizeof *new_layer);
+
+ /* Add to head of list of upper layers */
+ new_layer->next_layer =3D l2cap->upper_layers;
l2cap->upper_layers =3D new_layer;
- }
+
+ return 0;
}
=20=20
protocol_layer*
@@ -431,29 +426,29 @@
=20=09
/* Check PSM value */
if((psm % 2) =3D=3D 0) {
- D_ERR("get_upper : incorrect psm\n");
+ D_ERR(__FUNCTION__ ": incorrect psm\n");
return &default_protocol;
}
if((psm > MAX_PSM) && (psm < MIN_DYNAMIC_PSM)) {
- D_ERR("get_upper : value of psm reserved\n");
+ D_ERR(__FUNCTION__ ": value of psm reserved\n");
return &default_protocol;
}
if(psm > MAX_DYNAMIC_PSM) {
- D_ERR("get_upper : psm not valid!\n");
+ D_ERR(__FUNCTION__ ": psm not valid!\n");
return &default_protocol;
}
=20
- D_MISC("get_upper: Try to retrieve psm 0x%x\n",psm);
+ D_MISC(__FUNCTION__ ": Try to retrieve psm 0x%x\n",psm);
tmp_layer =3D l2cap->upper_layers;
while (tmp_layer !=3D NULL) {
if (tmp_layer->psm =3D=3D psm) {
- D_MISC("get_upper: Actually got psm:0x%x\n",
+ D_MISC(__FUNCTION__ ": Actually got psm:0x%x\n",
tmp_layer->psm);
return tmp_layer;
}
tmp_layer =3D tmp_layer->next_layer;
}
- D_MISC("get_upper: Didn't get any layer, returning default\n");
+ D_MISC(__FUNCTION__ ": Didn't get any layer, returning default\n");
return &default_protocol;
}
=20
@@ -462,13 +457,12 @@
{
protocol_layer *tmp_layer;
=20
- D_MISC("remove_all_upper: Freeing all upper layers\n");
+ D_MISC(__FUNCTION__ ": Freeing all upper layers\n");
=20
while (l2cap->upper_layers !=3D NULL) {
tmp_layer =3D l2cap->upper_layers;
l2cap->upper_layers =3D tmp_layer->next_layer;
kfree(tmp_layer);
- tmp_layer =3D NULL;
}
}
=20
@@ -516,21 +510,20 @@
l2cap_receive_data(u8 *data, u32 len, u16 hci_handle, /*u8 pb_flag,*/=20=
=20
/*u8 bc_flag,*/ u32 *l2cap_len)
{
-#define FNC "l2cap_receive_data : "
l2cap_packet *pkt =3D NULL;
l2cap_con *con;
u16 pkt_len;
CID pkt_cid;
=20
- D_RCV(FNC" got %d bytes on hci_handle : %d\n", len, hci_handle);
- PRINTPKT("l2cap_receive_data : ", data, len);
+ D_RCV(__FUNCTION__ ": got %d bytes on hci_handle : %d\n", len, hci_handl=
e);
+ PRINTPKT(__FUNCTION__ ": ", data, len);
=20
if (*l2cap_len =3D=3D 0) {
/* Start of a new frame received,=20
parse header and set l2cap_len */
=20=09=09
if (len < 4) {
- D_RCV(FNC"Incomplete frame header!\n");
+ D_RCV(__FUNCTION__ ": Incomplete frame header!\n");
return;
}
=20
@@ -543,7 +536,7 @@
has been received in hci this function is called again */
*l2cap_len =3D pkt_len + L2CAP_HDRSIZE;
=20=20=20=20=20
- D_RCV(FNC"New frame len:%d cid:%d\n", pkt_len, pkt_cid);
+ D_RCV(__FUNCTION__ ": New frame len:%d cid:%d\n", pkt_len, pkt_cid);
=20
/* check length */
if (!(pkt_len =3D=3D (len - L2CAP_HDRSIZE)))
@@ -552,7 +545,7 @@
/* Not recieved full frame yet or BIG packet */
=20=09=09
if (len > *l2cap_len) {
- DSYS(FNC"BIG PACKET ! (%d bytes) discard\n", len);
+ DSYS(__FUNCTION__ ": BIG PACKET ! (%d bytes) discard\n", len);
hci_clear_buffer(hci_handle);
}
return;
@@ -566,7 +559,7 @@
switch (pkt_cid) {
case CIDSIG:
/* Signalling channel */
- D_RCV("l2cap_receive_data : Signal data !\n");
+ D_RCV(__FUNCTION__ ": Signal data !\n");
=20=09=09
signal_handler(hci_handle, data + L2CAP_HDRSIZE,=20
len-L2CAP_HDRSIZE);
@@ -578,7 +571,7 @@
return;
}
=20=09=09
- D_RCV("l2cap_receive_data: Connectionless data\n");
+ D_RCV(__FUNCTION__ ": Connectionless data\n");
=20
/* FIXME: Move data 2 bytes ahead since there is a psm value
in the connection less packet */
@@ -598,14 +591,13 @@
if (con->current_state =3D=3D OPEN ) {=20=20=20=20=20=20
process_frame(con, pkt->data, pkt_len);
} else {
- D_ERR("l2cap_receive_data : not OPEN yet, discard data\n");
+ D_ERR(__FUNCTION__ ": not OPEN yet, discard data\n");
}
break;
}
=20
/* free hci inbuffer */
hci_clear_buffer(hci_handle);=20
-#undef FNC
}
=20
/* Signalling between two l2cap entities on remote devices */
@@ -614,7 +606,6 @@
signal_handler(u16 hci_handle, u8 *data,=20
u32 len)
{
-#define FNC "signal_handler : "=20=20=20=20=20=20=20
sig_cmd *cmd;
s32 pos =3D 0; /* position in packet */
=20
@@ -622,20 +613,20 @@
=20=20=20
cmd->len =3D le16_to_cpu(cmd->len);
=20
- D_RCV(FNC"received %d bytes\n", len);
- PRINTPKT(FNC"data", data, len);
+ D_RCV(__FUNCTION__ ": received %d bytes\n", len);
+ PRINTPKT(__FUNCTION__ ": data", data, len);
=20
if (len < (cmd->len + 4)) {
- D_ERR(FNC"Length doesn't match\n");
+ D_ERR(__FUNCTION__ ": Length doesn't match\n");
return;=20
} else if (len > (cmd->len + 4)) {=20=20
- D_RCV(FNC"Multiple commands !\n");=20=20
+ D_RCV(__FUNCTION__ ": Multiple commands !\n");=20=20
} else {
- D_RCV(FNC"Single command\n");
+ D_RCV(__FUNCTION__ ": Single command\n");
}=20=20
=20
while (pos < len) {
- D_RCV(FNC"got packet (%d bytes) with ID : %d\n",
+ D_RCV(__FUNCTION__ ": got packet (%d bytes) with ID : %d\n",
cmd->len, cmd->id);
=20=20=20=20=20
if (ISREQUEST(cmd->code)) {=20
@@ -654,19 +645,16 @@
cmd->len);
}
}=20
-#undef FNC=09=09
}
=20
=20
void process_request(u16 hci_handle, struct sig_cmd *req)
{
-#define FNC "process_request : "
-=20
sig_conreq *conreq;
sig_confreq *confreq;
sig_discreq *discreq;
l2cap_con *con =3D NULL;
- D_STATE(FNC"Got request : 0x%x id:%d\n", req->code, req->id);
+ D_STATE(__FUNCTION__ ": Got request : 0x%x id:%d\n", req->code, req->id);
=20=09
/* FIXME -- Add check for cmd len in each request type=20
(used to detect corrupt packets) */
@@ -678,8 +666,8 @@
conreq->psm =3D le16_to_cpu(conreq->psm);
conreq->src_cid =3D le16_to_cpu(conreq->src_cid);
=20=09=09
- D_STATE(FNC"Connection request\n");
- D_STATE(FNC"id:%d len:%d PSM 0x%x src_cid:%d\n",
+ D_STATE(__FUNCTION__ ": Connection request\n");
+ D_STATE(__FUNCTION__ ": id:%d len:%d PSM 0x%x src_cid:%d\n",
req->id, req->len, conreq->psm, conreq->src_cid);
/*=20
Two cases :
@@ -697,15 +685,14 @@
=20=09=09
if ((con =3D check_remote_cid(hci_handle,=20
conreq->src_cid)) =3D=3D NULL) {
- D_ERR(FNC"couldn't find l2cap connection\n");
+ D_ERR(__FUNCTION__ ": couldn't find l2cap connection\n");
l2cap_cmdrej(hci_handle, CMDREJ_INVALIDCID,
"Invalid CID", 13);
return;
}
=20=09=09
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n",=20
- __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
}
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
@@ -736,7 +723,7 @@
confreq->dst_cid =3D le16_to_cpu(confreq->dst_cid);
confreq->flags =3D le16_to_cpu(confreq->flags);
=20=09=09
- D_STATE(FNC"config request cid:%d flags: 0x%x\n",=20
+ D_STATE(__FUNCTION__ ": config request cid:%d flags: 0x%x\n",=20
confreq->dst_cid, confreq->flags);
=20=09=09
if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) {
@@ -844,7 +831,7 @@
discreq->dst_cid =3D le16_to_cpu(discreq->dst_cid);
discreq->src_cid =3D le16_to_cpu(discreq->src_cid);
=20
- D_STATE(FNC"disconnection request id %d\n",=20
+ D_STATE(__FUNCTION__ ": disconnection request id %d\n",=20
req->id);
=20
if ((con =3D get_rcon(discreq->src_cid)) =3D=3D NULL) {
@@ -858,7 +845,7 @@
=20
/* if already closed, simply acknowledge */
if ((con->current_state =3D=3D CLOSED)) {
- D_STATE(FNC"connection closed, send disc rsp\n");
+ D_STATE(__FUNCTION__ ": connection closed, send disc rsp\n");
l2cap_disconnect_rsp(con);
return;
}
@@ -872,7 +859,7 @@
=20=20=20=20=20=20=20=20
case SIG_ECHOREQ: {
sig_echo_pkt* echo;
- D_STATE(FNC"Echo request\n");
+ D_STATE(__FUNCTION__ ": Echo request\n");
=20=09=09
echo =3D (sig_echo_pkt *)(req->data);=09=09
=20
@@ -884,7 +871,7 @@
case SIG_INFOREQ: {
/* Implementation specific */
sig_info_req *info;
- D_STATE(FNC"Info request\n");
+ D_STATE(__FUNCTION__ ": Info request\n");
=20=09=09
info =3D (sig_info_req*)(req->data);
info->type =3D le16_to_cpu(info->type);
@@ -907,22 +894,19 @@
}=20=20=20=20
=20=20=20=20=20=20=20=20
case SIG_RESERVED:
- D_STATE(FNC"Reserved !\n");
+ D_STATE(__FUNCTION__ ": Reserved!\n");
break;
=20=20=20=20=20=20=20=20=20
default:
/* Not a valid command */
- DSYS(FNC"Invalid command (code 0x%x)s\n", req->code);
+ DSYS(__FUNCTION__ ": Invalid command (code 0x%x)s\n", req->code);
l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD, NULL, 0);
break;
}
-#undef FNC
}
=20
void process_response(u16 hci_handle, struct sig_cmd *rsp)
{
-#define FNC "process_response :"
-
sig_conrsp *conrsp;
sig_confrsp *confrsp;
sig_discrsp *discrsp;
@@ -933,7 +917,7 @@
s32 failure =3D 0;
u16 opt_len =3D 0;
=20
- D_STATE(FNC"Got response : 0x%x id:%d\n",=20
+ D_STATE(__FUNCTION__ ": Got response: 0x%x id:%d\n",
rsp->code, rsp->id);
=20
/* FIXME -- Add check for cmd len in each response type=20
@@ -941,31 +925,31 @@
=20
switch (rsp->code) {
case SIG_CMDREJECT:
- D_STATE(FNC"Command reject - \n");
+ D_STATE(__FUNCTION__ ": Command reject - \n");
DSYS("Got command reject\n");
cmdreject =3D (sig_cmdreject*)rsp->data;
cmdreject->reason =3D le16_to_cpu(cmdreject->reason);
opt_len =3D rsp->len - sizeof(sig_cmdreject);
switch (cmdreject->reason) {
case 0:
- D_STATE(FNC"Command not understood\n");=20
+ D_STATE(__FUNCTION__ ": Command not understood\n");=20
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case 1:
- D_STATE(FNC"Signalling MTU exceeded\n");
+ D_STATE(__FUNCTION__ ": Signalling MTU exceeded\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case 2:
- D_STATE(FNC"Invalid CID in request\n");
+ D_STATE(__FUNCTION__ ": Invalid CID in request\n");
break;
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_STATE(FNC"Not recognized cmd reject reason\n");
+ D_STATE(__FUNCTION__ ": Not recognized cmd reject reason\n");
break;
}
=20=09=09
if (opt_len > 0)
- print_data(FNC"optional data : ",=20
+ print_data(__FUNCTION__ ": optional data : ",=20
cmdreject->data, rsp->len-2);
=20
/* fixme -- set 'real' reason code */
@@ -980,7 +964,7 @@
=20=20=20=20=20=20=20=20
case SIG_CONRSP:
/* client */
- D_STATE(FNC"Got connection response\n");
+ D_STATE(__FUNCTION__ ": Got connection response\n");
conrsp =3D (sig_conrsp *)rsp->data;
conrsp->src_cid =3D le16_to_cpu(conrsp->src_cid);
conrsp->dst_cid =3D le16_to_cpu(conrsp->dst_cid);
@@ -989,7 +973,7 @@
=20
/* find connection */
if ((con =3D get_lcon(conrsp->src_cid)) =3D=3D NULL) {
- D_ERR(FNC"con rsp, NO CONNECTION FOUND\n");
+ D_ERR(__FUNCTION__ ": con rsp, NO CONNECTION FOUND\n");
return;
}
=20
@@ -997,7 +981,7 @@
=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n", con->sig_id_sent, rsp->id);
+ D_ERR(__FUNCTION__ ": ID doesn't match ! [%d:%d]\n", con->sig_id_sent, =
rsp->id);
return;
}
=20=20=20=20=20=20=20=20=20=20
@@ -1022,27 +1006,27 @@
disable_rtx(con);
start_ertx(con, ERTX_TIMEOUT);
#endif
- D_STATE(FNC"connection pending\n");
+ D_STATE(__FUNCTION__ ": connection pending\n");
break;
=20
case RES_PSMNEG:
- DSYS(FNC"connection refused, psm 0x%x not supp\n",=20
+ DSYS(__FUNCTION__ ": connection refused, psm 0x%x not supp\n",=20
con->psm);
failure =3D 1;
break;
=20
case RES_SECNEG:
- DSYS(FNC"connection refused, security block\n");
+ DSYS(__FUNCTION__ ": connection refused, security block\n");
failure =3D 1;
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case RES_NOSRC:
- DSYS(FNC"connection refused, no resources\n");
+ DSYS(__FUNCTION__ ": connection refused, no resources\n");
failure =3D 1;
break;
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_ERR(FNC"SIG_CONRSP\n");
+ D_ERR(__FUNCTION__ ": SIG_CONRSP\n");
break;
}
=20=20=20=20=20=20=20=20=20=20
@@ -1063,28 +1047,28 @@
break;
=20=20=20=20=20=20=20=20
case SIG_CONFRSP:
- D_STATE(FNC"Got configuration response\n");
+ D_STATE(__FUNCTION__ ": Got configuration response\n");
confrsp =3D (sig_confrsp *)rsp->data;
confrsp->src_cid =3D le16_to_cpu(confrsp->src_cid);
confrsp->flags =3D le16_to_cpu(confrsp->flags);
confrsp->result =3D le16_to_cpu(confrsp->result);
opt_len =3D rsp->len - sizeof(sig_confrsp);
=20
- PRINTPKT(FNC"config response", rsp->data, rsp->len);
+ PRINTPKT(__FUNCTION__ ": config response", rsp->data, rsp->len);
=20
/* check that remote CID is in list */
if ((con =3D get_lcon(confrsp->src_cid)) =3D=3D NULL)
return;
=20
if (con->current_state !=3D CONFIG) {
- D_ERR(FNC"SIG_CONFRSP invalid state\n");
+ D_ERR(__FUNCTION__ ": SIG_CONFRSP invalid state\n");
PRINTSTATE(con);
return;=20
}
=20=09=09=09=20=20=20=20=20=20=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n", con->sig_id_sent, rsp->id);=09=
=09=09
+ D_ERR(__FUNCTION__ ": ID doesn't match ! [%d:%d]\n", con->sig_id_sent, =
rsp->id);=09=09=09
return;
}
=20
@@ -1121,22 +1105,22 @@
/* store remote side configuration */
parse_options(con, confrsp->options, opt_len);
=20
- D_STATE(FNC"config failure, unacceptable params\n");
+ D_STATE(__FUNCTION__ ": config failure, unacceptable params\n");
l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case CONF_REJ:
- D_STATE(FNC"connection refused, no reason\n");
+ D_STATE(__FUNCTION__ ": connection refused, no reason\n");
l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20
case CONF_UNKNOWN:
- D_STATE(FNC"connection refused, unknown options\n");
+ D_STATE(__FUNCTION__ ": connection refused, unknown options\n");
l2ca_config_cfm(con, confrsp->result);
break;
=20=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_ERR(FNC"SIG_CONFRSP\n");
+ D_ERR(__FUNCTION__ ": SIG_CONFRSP\n");
break;
}
=20=20=20=20=20=20
@@ -1147,7 +1131,7 @@
#endif
=20
if (con->current_state !=3D CONFIG)
- D_ERR(FNC"SIG_CONFRSP invalid state\n");
+ D_ERR(__FUNCTION__ ": SIG_CONFRSP invalid state\n");
PRINTSTATE(con);
=20
/* print failed options */
@@ -1158,25 +1142,25 @@
break;
=20=20=20=20=20=20=20=20=20
case SIG_DISCRSP:
- D_STATE(FNC"Got disconnect response\n");
+ D_STATE(__FUNCTION__ ": Got disconnect response\n");
discrsp =3D (sig_discrsp *)rsp->data;
discrsp->dst_cid =3D le16_to_cpu(discrsp->dst_cid);
discrsp->src_cid =3D le16_to_cpu(discrsp->src_cid);
- PRINTPKT(FNC"disconnect response", rsp->data, rsp->len);
+ PRINTPKT(__FUNCTION__ ": disconnect response", rsp->data, rsp->len);
=20
/* find connection */
if ((con =3D get_lcon(discrsp->src_cid)) =3D=3D NULL)
return;
=20=20=20=20=20=20=20=20=20=20
if (con->current_state !=3D W4_L2CAP_DISCONNECT_RSP) {
- D_ERR(FNC"SIG_DISCRSP invalid state\n");
+ D_ERR(__FUNCTION__ ": SIG_DISCRSP invalid state\n");
PRINTSTATE(con);
return;=20
}
=20=09=20=20=20=20=20=20=20=09=20=20=20=20=20=20=20
/* match id with request */
if (!id_matched(con, rsp->id)) {
- D_ERR(FNC"ID doesn't match ! [%d:%d]\n",=20
+ D_ERR(__FUNCTION__ ": ID doesn't match ! [%d:%d]\n",=20
con->sig_id_sent, rsp->id);
return;
}
@@ -1192,7 +1176,7 @@
case SIG_ECHORSP: {
l2cap_con *tempcon;
=20=09=09
- D_STATE(FNC"Got echo response\n");=09=09
+ D_STATE(__FUNCTION__ ": Got echo response\n");=09=09
=20
if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
D_STATE("Echo rsp : could not find connection\n");
@@ -1203,7 +1187,7 @@
opt_len =3D rsp->len;
=20=09=09=09
if (opt_len > 0)
- PRINTPKT(FNC"optional data ",=20
+ PRINTPKT(__FUNCTION__ ": optional data ",=20
echo->data, rsp->len-sizeof(sig_echo_pkt));
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
@@ -1230,7 +1214,7 @@
info->type =3D le16_to_cpu(info->type);
info->result =3D le16_to_cpu(info->result);
=20=09=09
- D_STATE(FNC"Got info response : result %d\n", info->result);
+ D_STATE(__FUNCTION__ ": Got info response: result %d\n", info->result);
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
disable_rtx(tempcon);
@@ -1245,12 +1229,10 @@
=20=09
default:
/* Not a valid command */
- DSYS(FNC"Invalid command 0x%x\n", rsp->code);
+ DSYS(__FUNCTION__ ": Invalid command 0x%x\n", rsp->code);
l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD, NULL, 0);
break;
}
-=09
-#undef FNC
}
=20
=20
@@ -1278,12 +1260,12 @@
void=20
lp_connect_ind(BD_ADDR bd_addr)
{
- PRINTPKT("lp_connect_ind from :",bd_addr, 6);
+ PRINTPKT(__FUNCTION__ ": from: ", bd_addr, 6);
=20
/* Check BD_ADDR */
if ((bd_addr[0]=3D=3D0) && (bd_addr[1]=3D=3D0) && (bd_addr[2]=3D=
=3D0) &&
(bd_addr[3]=3D=3D0) && (bd_addr[4]=3D=3D0) && (bd_addr[5]=3D=
=3D0)) {
- D_ERR("lp_connect_ind : no BD addr\n");
+ D_ERR(__FUNCTION__ ": no BD addr\n");
return;
}
=20=20
@@ -1292,7 +1274,7 @@
/* We are server and creates an l2cap connection object=20
which we set hci handle when we received lp_connect_cfm */
=20=20=20
- D_CON("lp_connect_ind: Accepting connection\n");
+ D_CON(__FUNCTION__ ": Accepting connection\n");
l2cap_create_con(bd_addr);
lp_connect_rsp(bd_addr,1);
}
@@ -1302,8 +1284,8 @@
l2cap_create_con(BD_ADDR bd)
{
l2cap_con *con;
- D_RCV("l2cap_create_con\n");=09
- PRINTPKT("l2cap_create_con : bd ", bd, 6);
+ D_RCV(__FUNCTION__ "\n");=09
+ PRINTPKT(__FUNCTION__ ": bd ", bd, 6);
=20
/* create a new l2cap connection obj and insert it in list */
=20
@@ -1314,7 +1296,7 @@
=20=09
/* Check connection */
if (con =3D=3D NULL) {
- D_ERR("l2cap_create_con : no connection created");
+ D_ERR(__FUNCTION__ ": no connection created");
return;
}
=20=20=20=20=20=20=20=20=20
@@ -1336,17 +1318,17 @@
lp_connect_cfm(u8 *bd_addr, u32 status, u16 con_hdl)
{
l2cap_con *con;
- D_STATE("lp_connect_cfm: %s (hci_handle : %d)\n",=20
+ D_STATE(__FUNCTION__ ": %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
=20
- D_STATE("lp_connect_cfm : bd %s\n", bd2str(bd_addr));
+ D_STATE(__FUNCTION__ ": bd %s\n", bd2str(bd_addr));
=20
/* FIXME -- use bt session list to notify upper layers that=20
con failed !!! */
=20
/* search for the corresponding l2cap connection */
if ((con =3D get_con(bd_addr, CLOSED)) =3D=3D NULL) {
- D_ERR("lp_connect_cfm : couldn't find l2cap con!\n");
+ D_ERR(__FUNCTION__ ": couldn't find l2cap con!\n");
return;
}
=20
@@ -1360,8 +1342,7 @@
/* see if there is someone to wakeup */
l2ca_wakeup("lp_connect_cfm (pos)", con);
=20=09=09
- if (con->c_flags & FLAG_RETURNNOW)
- {
+ if (con->c_flags & FLAG_RETURNNOW) {
printk("Return NOW\n");
/* clear flag & set status */
con->c_flags &=3D ~FLAG_RETURNNOW;
@@ -1376,23 +1357,22 @@
/* now wait for a connection request */
} else {
D_STATE("We are client\n");
- PRINTPKT("lp_connect_cfm : HCI connected to ",=20
+ PRINTPKT(__FUNCTION__ ": HCI connected to ",=20
bd_addr,6);
=20=20=20=20=20=20=20
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
PRINTSTATE(con);
=20=09=09=09
- l2ca_wakeup("lp_connect_cfm", con);
+ l2ca_wakeup(__FUNCTION__, con);
}
} else {
/* neg cfm */
- D_STATE("lp_connect_cfm : (neg) %s\n",get_err_msg(status));
+ D_STATE(__FUNCTION__ ": (neg) %s\n",get_err_msg(status));
con->link_up =3D FALSE;
=20
- l2ca_wakeup("lp_connect_cfm (neg)", con);
+ l2ca_wakeup(__FUNCTION__ " (neg)", con);
=20=09=09
- if (con->c_flags & FLAG_RETURNNOW)
- {
+ if (con->c_flags & FLAG_RETURNNOW) {
con->c_flags &=3D ~FLAG_RETURNNOW;
return;
}
@@ -1448,7 +1428,7 @@
}
}
=20=20=20=20
- D_CON("lp_disconnect_ind : no more l2cap cons on this handle\n");
+ D_CON(__FUNCTION__ ": no more l2cap cons on this handle\n");
=20
/* flush old buffers waiting to be sent on this handle */
btmem_flushhandle((u16)con_hdl);
@@ -1480,11 +1460,11 @@
void=20
process_frame(l2cap_con *con, u8 *data, u32 len)
{=20=20
- PRINTPKT("process_frame : ", data, len);
+ PRINTPKT(__FUNCTION__ ": ", data, len);
=20
if (len > (con->local_mtu)) {
- DSYS("l2cap process_frame : len > local_mtu (%d/%d)\n",=20
- len- L2CAP_HDRSIZE, con->local_mtu);
+ DSYS("l2cap process_frame : len > local_mtu (%ld/%d)\n",=20
+ (long)(len - L2CAP_HDRSIZE), con->local_mtu);
l2cap_cmdrej(con->hci_hdl, CMDREJ_MTUEXCEEDED, NULL, 0);
return;
}=20
@@ -1505,28 +1485,28 @@
s32 i;
u8 rev_bd[6];
=20
- D_RCV("l2ca_connect_req\n");
- PRINTPKT("l2ca_connect_req : sent to bd ",bd, 6);
+ D_RCV(__FUNCTION__ "\n");
+ PRINTPKT(__FUNCTION__ ": sent to bd ",bd, 6);
=20
/* Check bd_addr */
if ((bd[0]=3D=3D0) && (bd[1]=3D=3D0) && (bd[2]=3D=3D0) && (bd[3]=3D=3D0) =
&&
(bd[4]=3D=3D0) && (bd[5]=3D=3D0)) {
- D_ERR("l2ca_connect req : No BD-addr\n");
- return -1;
+ D_ERR(__FUNCTION__ ": No BD-addr\n");
+ return -EINVAL;
}
=20
/* Check PSM */
if ((psm % 2) =3D=3D 0) {
- D_ERR("l2ca_connect_req : incorrect PSM value\n");
- return -1;
+ D_ERR(__FUNCTION__ ": incorrect PSM value\n");
+ return -EINVAL;
}
if ((psm > MAX_PSM) && (psm < MIN_DYNAMIC_PSM)) {
- D_ERR("l2ca_connect_req : value of PSM preserved\n");
- return -1;
+ D_ERR(__FUNCTION__ ": value of PSM preserved\n");
+ return -EINVAL;
}
if (psm > MAX_DYNAMIC_PSM) {
- D_ERR("l2ca_connect_req : PSM value not valid\n");
- return -1;
+ D_ERR(__FUNCTION__ ": PSM value not valid\n");
+ return -EINVAL;
}
=20=09
/* bd is big endian, reverse byte order to little endian */
@@ -1540,8 +1520,8 @@
con =3D create_con(0/* not yet set */, get_cid(), 0/* not yet set */);
/* Check connection */
if (con =3D=3D NULL) {
- D_ERR("l2ca_connect_req : no connection created\n");
- return -1;
+ D_ERR(__FUNCTION__ ": no connection created\n");
+ return -ENOMEM;
}
=20
memcpy(con->remote_bd, rev_bd, 6);
@@ -1563,7 +1543,7 @@
=20
/* if this physical bd link exist for another l2cap con, use that!*/
if (tmpcon) {
- D_STATE("l2ca_connect_req : hci handle already exist.\n");
+ D_STATE(__FUNCTION__ ": hci handle already exist.\n");
con->hci_hdl =3D tmpcon->hci_hdl;
con->link_up =3D 1;
ENTERSTATE(con, W4_L2CAP_CONNECT_RSP);
@@ -1571,19 +1551,19 @@
=20
l2cap_connect_req(con, psm);
=20
- l2ca_wait("l2cap_connect_req : wait rsp", con);
+ l2ca_wait(__FUNCTION__ ": wait rsp", con);
=20
/* fixme -- use con->c_status */
return 0;
} else {
- D_STATE("l2ca_connect_req : create new baseband link\n");
+ D_STATE(__FUNCTION__ ": create new baseband link\n");
lp_connect_req(con->remote_bd);=20=20
=20
/* wait here until we received a lp_connect_cfm */
- l2ca_wait("l2ca_connect_req : wait baseband", con);
+ l2ca_wait(__FUNCTION__ ": wait baseband", con);
=20=09=09
if (con->c_status !=3D RES_SUCCESS) {
- D_ERR("l2cap_connect_req failed !\n");
+ D_ERR(__FUNCTION__ ": failed !\n");
delete_con(con);
return -1;
}
@@ -1593,15 +1573,13 @@
con->c_status =3D CSTATUS_RTX_TIMEOUT;
=20
/* Leave loop when either status failed or success */
- while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT)
- {
+ while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
/* baseband is up, now initiate send connect req */
l2cap_connect_req(con, con->psm);
=20
/* wait until we received a response or after timeout */
=20
- l2ca_wait("l2cap_connect_req : wait rsp", con);
-
+ l2ca_wait(__FUNCTION__ ": wait rsp", con);
}
=20
return con->c_result;
@@ -1613,8 +1591,8 @@
u16 flush_timeout, u16 link_to)
{=20=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
D_STATE("l2ca_config_req remote cid %d, in_mtu %d\n",=20
@@ -1648,9 +1626,8 @@
=20
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
- return -1;
} else {
- D_ERR("l2cap_config_req : invalid state\n");
+ D_ERR(__FUNCTION__ ": invalid state\n");
PRINTSTATE(con);
return -1;
}
@@ -1662,11 +1639,11 @@
s32 result =3D -1;
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
- D_STATE("l2ca_disconnect_req remote cid : %d\n", con->remote_cid);
+ D_STATE(__FUNCTION__ ": remote cid : %d\n", con->remote_cid);
=20
if (con->current_state =3D=3D OPEN || con->current_state =3D=3D CONFIG) {
=20
@@ -1675,13 +1652,13 @@
ENTERSTATE(con, W4_L2CAP_DISCONNECT_RSP);
PRINTSTATE(con);
} else {
- D_ERR("l2ca_disconnect_req : Invalid state !\n");
+ D_ERR(__FUNCTION__ ": Invalid state!\n");
PRINTSTATE(con);
return -1;=20=20=20=20
}
=20=09
/* wait here until we get a confirm */
- l2ca_wait("l2ca_disconnect_req", con);
+ l2ca_wait(__FUNCTION__, con);
=20
return con->c_result;
}
@@ -1694,17 +1671,17 @@
{
s32 result;
=20
- D_STATE("l2ca_connect_rsp\n");
+ D_STATE(__FUNCTION__ "\n");
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
/* optionally send l2cap_connect_rsp_pnd() */=20=20
=20
if (con->current_state !=3D W4_L2CA_CONNECT_RSP) {
- D_ERR("l2ca_connect_rsp : invalid state \n");
+ D_ERR(__FUNCTION__ ": invalid state \n");
PRINTSTATE(con);
return -1;
}
@@ -1714,11 +1691,9 @@
if (response =3D=3D RES_SUCCESS) {=20=20
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
- }=20
- else if (response =3D=3D RES_PENDING) {
+ } else if (response =3D=3D RES_PENDING) {
/* remain in same state */
- }
- else if (response >=3D RES_PSMNEG) {
+ } else if (response >=3D RES_PSMNEG) {
/* 'l2ca_connect_rsp_neg()' */
ENTERSTATE(con, CLOSED);
PRINTSTATE(con);
@@ -1732,19 +1707,18 @@
s32=20
l2ca_config_rsp(l2cap_con* con, u32 out_mtu, flow *in_flow, s32 result)
{
-#define FNC "l2ca_config_rsp : "
s32 ret_val =3D -1;
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
- D_STATE(FNC"remote cid %d remote mtu %d\n",=20
+ D_STATE(__FUNCTION__ ": remote cid %d remote mtu %d\n",=20
con->remote_cid, con->remote_mtu);
=20
if (con->current_state !=3D CONFIG) {
- D_ERR("l2ca_config_rsp : invalid state\n");
+ D_ERR(__FUNCTION__": invalid state\n");
PRINTSTATE(con);
return -1;
}
@@ -1771,7 +1745,7 @@
l2ca_config_cfm(con, RES_SUCCESS);
=20
} else {
- D_STATE(FNC"Conf not done or flags set\n");
+ D_STATE(__FUNCTION__ ": Conf not done or flags set\n");
}
} else {
D_STATE("We don't accepted remote options\n");
@@ -1779,18 +1753,17 @@
}
=20
return ret_val;
-#undef FNC
}
=20
s32=20
l2ca_disconnect_rsp(l2cap_con* con)
{
s32 result =3D -1;
- D_STATE("l2ca_disconnect_rsp\n");
+ D_STATE(__FUNCTION__ "\n");
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
- return -1;
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
+ return -EINVAL;
}
=20
SHOW_CON("disconnecting : ", con);
@@ -1820,7 +1793,7 @@
/* If this con is the last with this hci_hdl, it is deleted=20
when the baseband link goes down */
} else {
- D_ERR("l2ca_disconnect_rsp : invalid state !\n\n");
+ D_ERR(__FUNCTION__ ": invalid state !\n\n");
PRINTSTATE(con);
}
return result;=20=20=20=20
@@ -1858,17 +1831,15 @@
/* do some paranoia checks */
=20
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
}
=20
- D_TIM("l2cap_rtx_timeout (current no rtx : %d)\n",=20
- con->timer.rtx_no);
+ D_TIM(__FUNCTION__ ": current no rtx : %d\n", con->timer.rtx_no);
=20=20=20=20=20=20=20
con->timer.rtx_inuse =3D 0;
=20=20=20
- if (con->timer.rtx_no =3D=3D MAX_NO_RTX)
- {
+ if (con->timer.rtx_no =3D=3D MAX_NO_RTX) {
con->c_status =3D CSTATUS_MAX_NO_RTX;
=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
D_TIM("Connection unresponsive\n");
@@ -1887,21 +1858,17 @@
/* start ertx timer */
D_TIM("Starting ERTX\n");
start_ertx(con, ERTX_TIMEOUT);
- }
- else if (con->timer.rtx_action =3D=3D RTX_ACTION_TERMINATE){
+ } else if (con->timer.rtx_action =3D=3D RTX_ACTION_TERMINATE) {
D_TIM("Removing connection\n");
l2ca_disconnect_ind(con);
ENTERSTATE(con, CLOSED);
delete_con(con);
- }
}
- else
- {=20=20
+ } else {
con->timer.rtx_no++;
l2ca_timeoutind(con);=09
}
=20=09
-=09
#ifndef __KERNEL__
timeout_con =3D NULL;
#endif
@@ -1911,12 +1878,12 @@
l2cap_ertx_timeout(unsigned long ptr)
{
l2cap_con *con;
- D_TIM("l2cap_ertx_timeout\n");
+ D_TIM(__FUNCTION__ "\n");
con =3D (l2cap_con*)ptr;
=20
/* do paranoia check */
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
return;
}
=20
@@ -1976,11 +1943,11 @@
sig_conreq *req;
u16 payload_len;
=20
- D_XMIT("l2cap_connect_req: Connecting %s (rcid:%d)\n",psm2str(psm)=
,=20
+ D_XMIT(__FUNCTION__ ": Connecting %s (rcid:%d)\n",psm2str(psm),=20
con->remote_cid);
=20=09
if (con->current_state !=3D W4_L2CAP_CONNECT_RSP) {
- D_ERR("l2cap_connect_req : Invalid state !!!\n");
+ D_ERR(__FUNCTION__ ": Invalid state !!!\n");
return -1;
}
=20
@@ -1988,8 +1955,8 @@
=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_connect_req : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2034,7 +2001,7 @@
s32 opt_len=3D0;
struct l2cap_option *opt;
=20
- D_XMIT("l2cap_config_req : rcid :%d\n", con->remote_cid);
+ D_XMIT(__FUNCTION__ ": rcid :%d\n", con->remote_cid);
=20
/******************************************************************/
/* | len2 | CID2 || code1 | id1 || destcid2 | flags1 | options? | */
@@ -2042,7 +2009,7 @@
/* | l2cap hdr || sig cmd hdr || data | */
/******************************************************************/
=20
- D_STATE("l2cap_config_req: inmtu : %d, local mtu : %d\n",
+ D_STATE(__FUNCTION__ ": inmtu : %d, local mtu : %d\n",
in_mtu, con->local_mtu);
=20
if (in_mtu !=3D 0) {
@@ -2060,15 +2027,15 @@
=20=09
if (outflow !=3D NULL){
/* We inform peer about our QOS settings */
- opt_len +=3Dsizeof(flow);
+ opt_len +=3D sizeof *outflow;
}
=20=09
payload_len =3D SIGCMD_HDRSIZE + CONF_REQSIZE + opt_len;=20=20
=20=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_config_req : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2108,8 +2075,8 @@
printk("Sending conf req outflow\n");
print_flow(outflow);
opt->type =3D OPT_QOS;
- opt->len =3D sizeof(flow);
- memcpy((char*)opt+2, outflow, sizeof(flow));
+ opt->len =3D sizeof *outflow;
+ memcpy((char*)opt+2, outflow, sizeof *outflow);
}
}
=20
@@ -2150,14 +2117,14 @@
sig_discreq *req;
u16 payload_len;
=20=20
- D_XMIT("l2cap_disconnect_req : rcid %d\n", con->remote_cid);
+ D_XMIT(__FUNCTION__ ": rcid %d\n", con->remote_cid);
=20
payload_len =3D SIGCMD_HDRSIZE + DISC_REQSIZE;=20=20
=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_disconnect_req : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2197,11 +2164,11 @@
=20
payload_len =3D SIGCMD_HDRSIZE + sizeof(sig_echo_pkt) + opt_len;
=20
- D_XMIT("l2cap_echo_req\n");
+ D_XMIT(__FUNCTION__ "\n");
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_echo_req : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2242,14 +2209,14 @@
sig_echo_pkt *rsp;
u16 payload_len;
=20
- D_XMIT("l2cap_echo_rsp\n");
+ D_XMIT(__FUNCTION__ "\n");
=20
payload_len =3D SIGCMD_HDRSIZE + opt_len;
=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_echo_rsp : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}=20
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2287,12 +2254,12 @@
=20
payload_len =3D SIGCMD_HDRSIZE + sizeof(sig_info_req);
=20
- D_XMIT("l2cap_info_req\n");
+ D_XMIT(__FUNCTION__ "\n");
=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_info_req : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2328,14 +2295,14 @@
sig_info_rsp *rsp;
s32 payload_len;
=20
- D_XMIT("l2cap_info_rsp\n");
+ D_XMIT(__FUNCTION__ "\n");
=20
payload_len =3D SIGCMD_HDRSIZE + sizeof(sig_info_rsp) + info_len;
=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE + payload_le=
n);
if (!tx) {
- D_ERR("l2cap_echo_rsp : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}=20
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2376,12 +2343,12 @@
=20
payload_len =3D SIGCMD_HDRSIZE + sizeof(sig_cmdreject) + opt_len;
=20
- D_XMIT("l2cap_cmdrej : %s\n", cmdrej_reason[reason]);
+ D_XMIT(__FUNCTION__ ": %s\n", cmdrej_reason[reason]);
=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_cmdrej : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}=20=20
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2424,15 +2391,15 @@
sig_conrsp *rsp;
u16 payload_len;
=20=20=20
- D_XMIT("l2cap_connect_rsp : rcid:%d lcid:%d result:%d status:%d \n",
+ D_XMIT(__FUNCTION__ ": rcid:%d lcid:%d result:%d status:%d \n",
con->remote_cid, con->local_cid, response, status);
=20
payload_len =3D SIGCMD_HDRSIZE + CON_RSPSIZE;
=20=20=20
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_connect_rsp : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2476,7 +2443,7 @@
int opt_len =3D 0;
struct l2cap_option *opt;
=20
- D_XMIT("l2cap_config_rsp : rcid : %d, out_mtu: %d \n",=20
+ D_XMIT(__FUNCTION__ ": rcid : %d, out_mtu: %d \n",=20
con->remote_cid, out_mtu);
=20
/* If negative, the accepted options are sent back */
@@ -2490,7 +2457,7 @@
}
if (in_flow !=3D NULL){
/* The accepted settings for incoming traffic */
- opt_len +=3Dsizeof(flow);
+ opt_len +=3D sizeof *in_flow;
}
}
=20
@@ -2499,8 +2466,8 @@
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) +=20
L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_config_rsp : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2515,8 +2482,7 @@
rsp->result =3D cpu_to_le16((u16)result);
=20
/* Include unaccepted options if any */
- if (opt_len)
- {
+ if (opt_len) {
opt =3D (struct l2cap_option*)(rsp + CONF_RSPSIZE);
=20
if (out_mtu !=3D 0) {
@@ -2534,8 +2500,8 @@
printk("Sending conf req in_flow\n");
print_flow(in_flow);
opt->type =3D OPT_QOS;
- opt->len =3D sizeof(flow);
- memcpy((char*)opt+2, in_flow, sizeof(flow));
+ opt->len =3D sizeof *in_flow;
+ memcpy((char*)opt+2, in_flow, sizeof *in_flow);
}
print_data("options : ", (u8*)rsp, opt_len + CONF_RSPSIZE);
}
@@ -2571,11 +2537,11 @@
=20=20
payload_len =3D SIGCMD_HDRSIZE + sizeof(sig_discrsp);
=20
- D_XMIT("l2cap_disconnect_rsp : rcid %d\n", con->remote_cid);
+ D_XMIT(__FUNCTION__ ": rcid %d\n", con->remote_cid);
tx =3D subscribe_bt_buf(sizeof(l2cap_tx_buf) + L2CAP_HDRSIZE+payload_len);
if (!tx) {
- D_ERR("l2cap_disconnect_rsp : didn't get a valid tx buf\n");
- return -1;
+ D_ERR(__FUNCTION__ ": didn't get a valid tx buf\n");
+ return -ENOMEM;
}
=20
l2cap_buf =3D (l2cap_tx_buf *)(tx->data);
@@ -2610,13 +2576,13 @@
{
l2cap_tx_buf *l2cap_buf;
=20=20=20
- D_XMIT("l2cap_send_data : hdl : %d, rcid : %d, len:%d \n",
+ D_XMIT(__FUNCTION__ ": hdl : %d, rcid : %d, len:%d \n",
con->hci_hdl, con->remote_cid, tx->cur_len);
=20=09
if (PARANOIA_CHECKCON(con)) {
- D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ D_ERR(__FUNCTION__ ": Paranoia check failed\n");
tx->flushed =3D 1; /* flush this buffer */
- return -1;
+ return -EINVAL;
}
=20
if (tx->cur_len > con->remote_mtu) {
@@ -2625,13 +2591,12 @@
=20=09=20=20=20=20
D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n");
tx->flushed=3D1;
-=09=20=20=20=20
return -1;
}
=20
/* Only send on an OPEN channel */
if (con->current_state !=3D OPEN) {
- D_ERR("l2cap_send_data : not in open state\n");
+ D_ERR(__FUNCTION__ ": not in open state\n");
D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n");
tx->flushed=3D1;
return -1;
@@ -2649,7 +2614,7 @@
payload len of l2cap i.e an entire
frame of upper layers*/
=20
- PRINTPKT("l2cap_send_data : ", l2cap_buf->frame, tx->cur_len);
+ PRINTPKT(__FUNCTION__ ": ", l2cap_buf->frame, tx->cur_len);
=20
return hci_send_data(tx);
}
@@ -2661,11 +2626,11 @@
void=20
l2ca_connect_ind(l2cap_con *con)=20
{
- D_STATE("l2ca_connect_ind : remote cid : %d psm 0x%x\n",=20
+ D_STATE(__FUNCTION__ ": remote cid : %d psm 0x%x\n",=20
con->remote_cid, con->psm);
=20
if (get_upper(con->psm) =3D=3D &default_protocol) {
- D_STATE("l2ca_connect_ind : PSM not registered\n");
+ D_STATE(__FUNCTION__ ": PSM not registered\n");
l2ca_connect_rsp(con, RES_PSMNEG, STAT_NOINFO);
return;
}
@@ -2676,11 +2641,11 @@
void=20
l2ca_connect_pnd(l2cap_con *con, s32 status)
{
- D_STATE("l2ca_connect_pnd : rCID %d, status %d\n",=20
+ D_STATE(__FUNCTION__ ": rCID %d, status %d\n",=20
con->remote_cid, status);
=20=09
if (!con->initiator) {=20
- D_ERR(" l2ca_connect_cfm : server is not initiator !!!\n")=
;=20
+ D_ERR(__FUNCTION__": server is not initiator !!!\n");=20
return;
}
=20=09
@@ -2692,11 +2657,11 @@
void=20
l2ca_connect_cfm(l2cap_con *con, s32 result)
{
- D_STATE("l2ca_connect_cfm : rCID %d, result %d\n",=20
+ D_STATE(__FUNCTION__ ": rCID %d, result %d\n",=20
con->remote_cid, result);
=20=09
if (!con->initiator) {=20
- D_ERR(" l2ca_connect_cfm : server is not initiator !!!\n")=
;=20
+ D_ERR(__FUNCTION__ ": server is not initiator !!!\n");=20
return;
}
=20
@@ -2706,7 +2671,7 @@
void=20
l2ca_config_ind(l2cap_con* con)
{=20=20
- D_STATE("l2ca_config_ind : remote cid : %d\n", con->remote_cid);=20
+ D_STATE(__FUNCTION__ ": remote cid : %d\n", con->remote_cid);=20
=20=20=20
get_upper(con->psm)->conf_ind(con);=20
}
@@ -2718,7 +2683,7 @@
void=20
l2ca_config_cfm(l2cap_con *con, s32 result)
{
- D_STATE("l2ca_config_cfm : remote cid : %d result %d\n",=20
+ D_STATE(__FUNCTION__ ": remote cid : %d result %d\n",=20
con->remote_cid, result);
=20
get_upper(con->psm)->conf_cfm(con, result);=20
@@ -2727,7 +2692,7 @@
void=20
l2ca_disconnect_ind(l2cap_con *con)
{
- D_STATE("l2ca_disconnect_ind \n");
+ D_STATE(__FUNCTION__ "\n");
=20
get_upper(con->psm)->disc_ind(con);
}
@@ -2737,7 +2702,7 @@
{
s32 tmp_hdl;
=20
- D_STATE("l2ca_disconnect_cfm : remote cid : %d\n", con->remote_cid);
+ D_STATE(__FUNCTION__ ": remote cid : %d\n", con->remote_cid);
=20
/* tell upper layers that connection is down */
get_upper(con->psm)->disc_cfm(con);
@@ -2754,7 +2719,7 @@
delete_con(con);
=20
#ifdef __KERNEL__
- l2ca_wakeup("l2ca_disconnect_cfm", con);
+ l2ca_wakeup(__FUNCTION__, con);
#endif
=20
/* fixme -- if we want to keep baseband connection we must=20
@@ -2762,7 +2727,7 @@
simply just clear l2cap params but keep hci handle ! */
=20=09
if (count_con(tmp_hdl) =3D=3D 0) {
- DSYS("l2ca_disconnect_cfm : (C) no more l2cap connections\n");
+ DSYS(__FUNCTION__ ": (C) no more l2cap connections\n");
DSYS("Shutdown baseband\n");
lp_disconnect(tmp_hdl);
}
@@ -2785,12 +2750,12 @@
con =3D get_con(rev_bd, ANY_STATE);
=20
if (con =3D=3D NULL) {
- D_STATE("l2ca_ping : create new baseband link\n");
+ D_STATE(__FUNCTION__ ": create new baseband link\n");
con =3D create_con(0/* not yet set */,=20
get_cid(), 0/* not yet set */);
if (con =3D=3D NULL) {
- D_ERR("l2ca_ping : no connection created");
- return -1;
+ D_ERR(__FUNCTION__ ": no connection created");
+ return -ENOMEM;
}
=20
memcpy(con->remote_bd, rev_bd, 6);
@@ -2805,14 +2770,13 @@
lp_connect_req(con->remote_bd);
=20
/* wait here until we received a lp_connect_cfm */
- l2ca_wait("l2ca_ping : wait baseband", con);
+ l2ca_wait(__FUNCTION__ ": wait baseband", con);
=20=09=09
=20
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
printk("Now we got baseband, send echo req !\n");
- }
- else {
+ } else {
printk("Ping failed !\n");
delete_con(con);
return -1;
@@ -2824,21 +2788,19 @@
con->c_status =3D CSTATUS_RTX_TIMEOUT;
=20
/* leave loop when either status failed or success */
- while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT)
- {
+ while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
printk("Sending echo req...\n");
l2cap_echo_req(con, opt_data, len);=09
/* wait until we received a response or after timeout */
=20=09=09
printk("Waiting for response or timeout\n");
=20
- l2ca_wait("l2ca_ping wait echo resp", con);
+ l2ca_wait(__FUNCTION__ ": wait echo resp", con);
=20
printk("Woke up after sending echo req\n");
}
=20
- if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX)
- {
+ if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
/* max number reached, try to disconnect */
l2ca_disconnect_req(con);
}
@@ -2862,12 +2824,12 @@
con =3D get_con(rev_bd, ANY_STATE);
=20
if (con =3D=3D NULL) {
- D_STATE("l2ca_getinfo : create new baseband link\n");
+ D_STATE(__FUNCTION__ ": create new baseband link\n");
con =3D create_con(0/* not yet set */,=20
get_cid(), 0/* not yet set */);
if (con =3D=3D NULL) {
- D_ERR("l2ca_getinfo : no connection created");
- return -1;
+ D_ERR(__FUNCTION__ ": no connection created");
+ return -ENOMEM;
}
=20
memcpy(con->remote_bd, rev_bd, 6);
@@ -2883,13 +2845,12 @@
lp_connect_req(con->remote_bd);
=20
/* wait here until we received a lp_connect_cfm */
- l2ca_wait("l2ca_getinfo : wait baseband", con);
+ l2ca_wait(__FUNCTION__ ": wait baseband", con);
=20=09=09
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
printk("Now we got baseband, send info req !\n");
- }
- else {
+ } else {
printk("GetInfo failed ! [cstatus %d]\n",=20
con->c_status);
delete_con(con);
@@ -2897,21 +2858,19 @@
}
}
=20=09
-
/* Now send info req */=09
=20
con->c_status =3D CSTATUS_RTX_TIMEOUT;
=20
/* leave loop when either status failed or success */
- while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT)
- {
+ while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
printk("Sending info req...\n");
l2cap_info_req(con, infotype);=09
/* wait until we received a response or after timeout */
=20=09=09
printk("Waiting for response or timeout\n");
=20
- l2ca_wait("l2ca_ping wait echo resp", con);
+ l2ca_wait(__FUNCTION__ ": wait echo resp", con);
=20
printk("Woke up after sending info req\n");
}
@@ -2943,9 +2902,8 @@
D_TIM("Starting RTX timer (%d sec)\n", timeout);
=20
/* fixme -- add timer list for multiple calls */
- if (con->timer.rtx_inuse)
- {
- D_ERR("start_rtx : timer already used\n");
+ if (con->timer.rtx_inuse) {
+ D_ERR(__FUNCTION__ ": timer already used\n");
return;
}
=20
@@ -2995,8 +2953,7 @@
con->timer.rtx_inuse =3D 0;
con->timer.rtx_no =3D 0;
con->timer.rtx_action =3D RTX_ACTION_DISCONNECT;
- }
- else
+ } else
D_TIM("RTX never started\n");
#else
timer_cancelled =3D 1;
@@ -3010,9 +2967,8 @@
{
D_TIM("Starting ERTX timer (%d sec)\n", timeout);
=20
- if (con->timer.ertx_inuse)
- {
- D_TIM("start_ertx : timer already used\n");
+ if (con->timer.ertx_inuse) {
+ D_TIM(__FUNCTION__ ": timer already used\n");
return;
}
=20
@@ -3038,8 +2994,7 @@
del_timer(&con->timer.ertx);
con->timer.ertx_inuse =3D 0;
con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
- }
- else
+ } else
D_TIM("ERTX never started\n");
#else /* Usermode stack */
/* FIXME */
@@ -3077,10 +3032,10 @@
l2cap_option *opt;
s32 found_option =3D 0;
=20
- D_RCV("parse_options : Storing remote options on rCID %d\n",=20
+ D_RCV(__FUNCTION__ ": Storing remote options on rCID %d\n",=20
con->remote_cid);
=20
- PRINTPKT("parse_options : ", data, len);
+ PRINTPKT(__FUNCTION__ ": ", data, len);
=20
while (pos < len) {
opt =3D (l2cap_option*)(data + pos);
@@ -3105,7 +3060,7 @@
=20
/* FIXME -- return error code if not accepted */
=20=09=09=09
- D_RCV("parse_options : flush timeout %d ms\n",=20
+ D_RCV(__FUNCTION__ ": flush timeout %d ms\n",=20
con->flush_timeout);
=20
found_option =3D 1;
@@ -3117,20 +3072,20 @@
=20=09=09=09
/* FIXME -- return error code if not accepted */
=20
- D_RCV("parse_options : qos\n");
+ D_RCV(__FUNCTION__ ": qos\n");
print_flow(&con->remote_qos);
found_option =3D 1;
break;
=20=20=20=20=20=20=20
default:
- D_RCV("parse_options : Invalid type !\n");
+ D_RCV(__FUNCTION__ ": Invalid type !\n");
break;
}
pos +=3D opt->len + 2; /* 2 bytes header */
}
=20
if (!found_option)
- D_WARN("parse_options found NO valid options !\n");
+ D_WARN(__FUNCTION__ ": found NO valid options !\n");
=20=09
return RES_SUCCESS;
}
|