From: Gordon M. <gm...@us...> - 2001-03-24 21:12:10
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.7.2.1 1.7.2.2=20=20=20=20=20=20=20=20=20 bluetooth.c 1.154.2.3 1.154.2.4=20=20=20=20=20=20=20 btmem.c 1.37 1.37.2.1=20=20=20=20=20=20=20=20 hci.c 1.132.2.3 1.132.2.4=20=20=20=20=20=20=20 sdp.c 1.67 1.67.2.1=20=20=20=20=20=20=20=20 The accompanying log: Merged from trunk The diff of the modified file(s): --- Config.in 2001/03/20 16:48:15 1.7.2.1 +++ Config.in 2001/03/24 21:11:38 1.7.2.2 @@ -15,7 +15,7 @@ bool ' Allow connectionless L2CAP' CONFIG_BLUETOOTH_L2CAP_CONNECTIONLESS bool ' Enable TCI' CONFIG_BLUETOOTH_USE_TCI bool ' HCI Inquiry' CONFIG_BLUETOOTH_HCI_INQUIRY - bool ' Kernel Thread' CONFIG_BLUETOOTH_KERNEL_THREAD + bool ' Enable M/S Switch' CONFIG_BLUETOOTH_ENABLE_MSSWITCH =20 choice ' Bluetooth hardware type' \ "None CONFIG_BLUETOOTH_NOINIT \ --- bluetooth.c 2001/03/24 19:37:17 1.154.2.3 +++ bluetooth.c 2001/03/24 21:11:38 1.154.2.4 @@ -735,8 +735,9 @@ inq_res)) < 0) goto end_inquiry; =20 - copy_to_user((s32*)arg, inq_res, sizeof(inquiry_results) + 6 *=20 - inq_res->nbr_of_units); + copy_to_user((s32*)arg, inq_res, sizeof(inquiry_results) + + 6 * inq_res->nbr_of_units); + end_inquiry: kfree(inq_res); return ret; --- btmem.c 2001/03/02 21:52:15 1.37 +++ btmem.c 2001/03/24 21:11:38 1.37.2.1 @@ -214,7 +214,6 @@ =20 bt_tx_buf* subscribe_bt_buf(s32 send_len) { -#define FNC "subscribe_bt_buf : " bt_tx_buf *tx; s32 buf_len; /* Total size of bt_tx_object */ u32 head_free; @@ -222,7 +221,7 @@ =20 cli(); buf_len =3D send_len + BT_TX_HDRSIZE;=20=20 - D_MEM(FNC"buf_len %d\n", buf_len); + D_MEM(__FUNCTION__ ": buf_len %d\n", buf_len); =20 /*=20=20 'Normal' case @@ -239,13 +238,11 @@ get_bt_buf(); =20 if (bt_buf.free > bt_buf.send) { -=20=20=20=20 tail_free =3D (bt_buf.tail - bt_buf.free); head_free =3D (bt_buf.send - bt_buf.head); =20 if (tail_free >=3D buf_len) { - - D_MEM(FNC"subscribe in tail at pos %d\n",=20 + D_MEM(__FUNCTION__ ": subscribe in tail at pos %d\n",=20 bt_buf.free - bt_buf.head); tx =3D (bt_tx_buf *)bt_buf.free; /* Don't touch send, only update free and count */ @@ -253,7 +250,6 @@ bt_buf.count +=3D buf_len; bt_buf.nbr_bufs++; } else if (head_free >=3D buf_len) {=20=20 - D_MEM("No room in tail, subscribe at head (WRAP!)\n"); tx =3D (bt_tx_buf *)bt_buf.head; =20=09=09=09 @@ -264,9 +260,8 @@ bt_buf.nbr_bufs++; bt_buf.count +=3D buf_len; } else { - - D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len); - D_ERR(FNC"Only %d available (non - fragmented)\n", + D_ERR(__FUNCTION__ ": Cannot subscribe %d bytes !\n", send_len); + D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n", buf_write_room()); =20 #if PANIC_AT_ERROR @@ -277,7 +272,6 @@ return NULL; } } else if (bt_buf.free <=3D bt_buf.send) { -=20=20=20=20 /* 'Wrap' case */ tail_free =3D (bt_buf.send - bt_buf.free); head_free =3D 0; /* head_free is not interesting since we cannot=20 @@ -286,7 +280,6 @@ buffer! (Fragmentation) */ =20=20=20=20=20 if (tail_free >=3D buf_len) { - D_MEM("Wrapped buffer, subscribe at free (pos %d)\n",=20 bt_buf.free - bt_buf.head); tx =3D (bt_tx_buf *)bt_buf.free; @@ -294,13 +287,12 @@ bt_buf.count +=3D buf_len; bt_buf.nbr_bufs++; } else if (!bt_buf.count) { - /* If buffer empty, reset buffer */=20=20=20=20=20=20=20=20=20=20 btmem_reset(); =20=09=09=09 if (buf_len > bt_buf.size) { - D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len);=20 - D_ERR(FNC"Only %d available (non - fragmented)\n", + D_ERR(__FUNCTION__ ": Cannot subscribe %d bytes !\n", send_len);=20 + D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n", buf_write_room()); btmem_get_status(NULL); sti(); @@ -314,9 +306,9 @@ bt_buf.count +=3D buf_len; bt_buf.nbr_bufs++; } else { - D_ERR(FNC"Cannot subscribe requested size (%d) !\n",=20 + D_ERR(__FUNCTION__ ": Cannot subscribe requested size (%d) !\n",=20 send_len); - D_ERR(FNC"Only %d available (non - fragmented)\n", + D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n", buf_write_room()); btmem_get_status(NULL); #if PANIC_AT_ERROR @@ -333,7 +325,6 @@ =20 sti(); return tx; -#undef FNC } =20 /* Returns number of buffers */ @@ -343,7 +334,6 @@ return bt_buf.nbr_bufs; } =20 - /* Returns total number of bytes in buffer (fragmented) */ =20 s32 buf_byte_count() @@ -351,7 +341,6 @@ return bt_buf.count; } =20 - /* Returns unfragmented buffer space */=20 =20 #define BTMEM_EXTRASPACE BT_BUF_SIZE/10 /* always an extra 10 % marginal @@ -375,7 +364,6 @@ don't count a tossed tail ! */ space_left =3D (BT_BUF_SIZE -=20 (bt_buf.tail - bt_buf.toss_tail) - bt_buf.count); -=20=20 } =20 space_left -=3D (BT_TX_HDRSIZE+BTMEM_EXTRASPACE); @@ -412,8 +400,7 @@ =20 tx =3D (bt_tx_buf *)(bt_buf.send); =20 - if (tx->magic !=3D 0x4321) - { + if (tx->magic !=3D 0x4321) { D_ERR("get_bt_buf : wrong magic!\n"); #if PANIC_AT_ERROR panic("lets stop here...\n"); @@ -442,32 +429,32 @@ =20 void unsubscribe_bt_buf(bt_tx_buf *tx) { -#define FNC "unsubscribe_bt_buf : " s32 tail_free; /* for debug */ s32 head_free; =20=20=20 - D_MEM(FNC"%d bytes (not incl hdrs) at pos %d\n",=20 + if (!tx) + return; + + D_MEM(__FUNCTION__ ": %d bytes (not incl hdrs) at pos %d\n",=20 tx->subscr_len, (u8 *)tx - bt_buf.head); =20=20=20 /* Check that tx is valid for unssubscribe. We must process the=20 buffers in fifo order ! */ =20 cli(); - if (tx && (bt_buf.send =3D=3D (u8*)tx)) { - + if (bt_buf.send =3D=3D (u8*)tx) { if ((u8*)(tx->data + tx->subscr_len) <=3D bt_buf.tail) { -=20=20=20=20=20=20 /* don't touch free, only subscribe_bt_buf change free */ bt_buf.send +=3D (tx->subscr_len + BT_TX_HDRSIZE); bt_buf.count -=3D (tx->subscr_len + BT_TX_HDRSIZE); bt_buf.nbr_bufs--;=20=20=20=20=20=20 } else { - D_ERR(FNC"failed, out of boundary\n"); + D_ERR(__FUNCTION__ ": failed, out of boundary\n"); } } else if (bt_buf.count =3D=3D 0) - D_MEM(FNC"no data in buffer\n"); + D_MEM(__FUNCTION__ ": no data in buffer\n"); else { - D_ERR(FNC"invalid data segment!\n"); + D_ERR(__FUNCTION__ ": invalid data segment!\n"); #ifdef __KERNEL__ =20 D_ERR("pid : %d (tx:0x%x - send:0x%x=3D%d) send:%ld free:%ld\n", @@ -495,7 +482,7 @@ =20 /* Is also checked done in get_bt_buf */ if (bt_buf.send =3D=3D bt_buf.toss_tail) { - D_MEM(FNC"toss_tail, now send pos is 0\n"); + D_MEM(__FUNCTION__ ": toss_tail, now send pos is 0\n"); bt_buf.send =3D bt_buf.head; bt_buf.toss_tail =3D bt_buf.tail; =20 @@ -603,13 +590,11 @@ bt_tx_buf *tx; =20=20=20=20 for (i =3D 0; i < count; i++) { - if (cursize > buf_write_room()) return; =20=09=20=20=20=20=20 printk("storing %d bytes packets\n", cursize); while (buf_write_room() >=3D cursize) { -=09=20=20=20=20=20=20=20 if (!(tx =3D subscribe_bt_buf(cursize))) { return ; } --- hci.c 2001/03/21 23:23:25 1.132.2.3 +++ hci.c 2001/03/24 21:11:38 1.132.2.4 @@ -2189,7 +2189,7 @@ bytes2send =3D tx_buf->cur_len; } =20=09 - D_SND(__FUNCTION__", %d bytes \n", tx_buf->cur_len); + D_SND(__FUNCTION__", %d bytes \n", bytes2send); =20=09 /* while there is space in the hardware buffers and we have hci packets to send, we send them. After each sent packet --- sdp.c 2001/03/06 11:06:24 1.67 +++ sdp.c 2001/03/24 21:11:38 1.67.2.1 @@ -315,6 +315,11 @@ #endif /* LINUX_VERSION_CODE */ #endif /* __KERNEL__ */ =20 +//#ifdef __KERNEL__ +static bt_tx_buf *db_write_tx_buf; +static s32 db_write_recv; +//#endif + #ifndef __KERNEL__ static s32 sdp_sock; #endif @@ -406,6 +411,9 @@ sdp_disconnect_req(i); } }=20=20 + + unsubscribe_bt_buf(db_write_tx_buf); + db_write_recv =3D 0; } =20 #ifdef __KERNEL__ @@ -907,11 +915,7 @@ =20 len =3D MIN(count, database_query.count); =20 -#ifdef __KERNEL__ copy_to_user(buf, database_query.query, len); -#else - memcpy(buf, database_query.query, len); -#endif =20 if (database_query.count > len) { memmove(database_query.query, @@ -932,35 +936,60 @@ const char * buf, s32 count) #endif { + static data_struct db_hdl; sdp_tx_buf *sdp_buf; - bt_tx_buf *tx_buf; - data_struct *db_hdl =3D (data_struct*) buf; + s32 read1 =3D 0; + s32 read2 =3D 0; =20=09 D_PROC(__FUNCTION__ " Someone wrote %d bytes to sdp proc-file\n",count); =20 - D_XMIT(__FUNCTION__ " preparing to send %d bytes data to sdp_con[%d]\n", = count, db_hdl->sdp_con_id); - PRINTPKT("Data to be sent to client:", db_hdl->data, db_hdl->len); + if (!bt_initiated()) + return 0; =20=09 - tx_buf =3D subscribe_bt_buf(sizeof(sdp_tx_buf) + db_hdl->len); + if (!db_write_tx_buf) { + read1 =3D MIN(sizeof db_hdl - db_write_recv, count); + copy_from_user(&db_hdl + db_write_recv, buf, read1); =20 - if (!tx_buf) { + db_write_recv +=3D read1; + + if (db_write_recv < sizeof db_hdl) + return read1; + + db_write_tx_buf =3D subscribe_bt_buf(sizeof *sdp_buf + db_hdl.len); + + if (!db_write_tx_buf) { D_ERR(__FUNCTION__ " failed to get tx buffer\n"); - return -1; + db_write_recv -=3D read1; + return -ENOMEM; } =20 - tx_buf->cur_len =3D db_hdl->len; - sdp_buf =3D (sdp_tx_buf*) (tx_buf->data); + db_write_tx_buf->cur_len =3D db_hdl.len; =20 -#ifdef __KERNEL__ - copy_from_user(sdp_buf->frame, db_hdl->data, db_hdl->len); -#else - memcpy(sdp_buf->frame, db_hdl->data, db_hdl->len); -#endif + count -=3D read1; + buf +=3D read1; + db_write_recv =3D 0; + } =20 - l2cap_send_data(tx_buf, sdp_con_list[db_hdl->sdp_con_id].l2cap); + sdp_buf =3D (sdp_tx_buf*)db_write_tx_buf->data; =20=09 - return count; + if (db_write_recv < db_hdl.len) { + read2 =3D MIN(db_hdl.len - db_write_recv, count); + copy_from_user(sdp_buf->frame + db_write_recv, buf, read2); + db_write_recv +=3D read2; + + if (db_write_recv < db_hdl.len) + return read1 + read2; } + + D_XMIT(__FUNCTION__ " preparing to send %d bytes data to sdp_con[%d]\n", = db_hdl.len, db_hdl.sdp_con_id); + PRINTPKT("Data to be sent to client:", db_hdl.data, db_hdl.len); + + l2cap_send_data(db_write_tx_buf, sdp_con_list[db_hdl.sdp_con_id].l2cap); + db_write_tx_buf =3D NULL; + db_write_recv =3D 0; + + return read1 + read2; +} #else /* __KERNEL__ */ =20 s32 sdp_doquery(s32 fd, u8 *request, s32 len) @@ -968,11 +997,13 @@ s32 n; u8 tmpbuf[512]; data_struct *db_hdl; + s32 recv; =20 D_XMIT("sdp_doquery : sending request %d bytes\n", len); write(fd, request, len); =20=09 - n =3D read(fd, tmpbuf, 512); + if ((n =3D read(fd, tmpbuf, 512)) < 0) + return n; =20 D_REC(__FUNCTION__ ", Received %d bytes\n", n); =20=09 @@ -980,15 +1011,13 @@ =20=09 /* what if not all is written once */ =20 - if (n < (sizeof(data_struct) + db_hdl->len)) { - D_ERR("sdp_doquery : only got partial response n:%d, db_hdl->len:%d\n", = n, db_hdl->len); - print_data("The request is:", request, len); - return -1; - } + for (recv =3D n; recv < sizeof *db_hdl + db_hdl->len; recv +=3D n) + if ((n =3D read(fd, tmpbuf + recv, 512 - recv)) < 0) + return n; =20 sdp_send_data(&sdp_con_list[db_hdl->sdp_con_id], db_hdl->data, db_hdl->le= n);=20 =20=09 - return n; + return recv; } #endif =20 |