diff options
author | Chris Manton <cmanton@google.com> | 2014-05-06 10:35:42 -0700 |
---|---|---|
committer | Andre Eisenbach <eisenbach@google.com> | 2015-03-16 16:51:29 -0700 |
commit | fe7216ca12f91baae733e7c93063db73121af308 (patch) | |
tree | 03a66f188e1fd2e8daa48d5be04220b80422d7bf /stack/rfcomm | |
parent | 284440f0c9f9fe15b162e37ef2bf6af439407447 (diff) | |
download | android_system_bt-fe7216ca12f91baae733e7c93063db73121af308.tar.gz android_system_bt-fe7216ca12f91baae733e7c93063db73121af308.tar.bz2 android_system_bt-fe7216ca12f91baae733e7c93063db73121af308.zip |
Enforce GKI API buffer usage
Also add another API GKI_queue_length(BUFFER_Q *)
Diffstat (limited to 'stack/rfcomm')
-rw-r--r-- | stack/rfcomm/port_api.c | 14 | ||||
-rw-r--r-- | stack/rfcomm/port_rfc.c | 2 | ||||
-rw-r--r-- | stack/rfcomm/port_utils.c | 8 | ||||
-rw-r--r-- | stack/rfcomm/rfc_port_fsm.c | 2 |
4 files changed, 13 insertions, 13 deletions
diff --git a/stack/rfcomm/port_api.c b/stack/rfcomm/port_api.c index 364308838..83c94da02 100644 --- a/stack/rfcomm/port_api.c +++ b/stack/rfcomm/port_api.c @@ -1132,7 +1132,7 @@ int PORT_Purge (UINT16 handle, UINT8 purge_flags) { PORT_SCHEDULE_LOCK; /* to prevent missing credit */ - count = p_port->rx.queue.count; + count = GKI_queue_length(&p_port->rx.queue); while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue)) != NULL) GKI_freebuf (p_buf); @@ -1368,7 +1368,7 @@ static int port_write (tPORT *p_port, BT_HDR *p_buf) (PORT_CTRL_REQ_SENT | PORT_CTRL_IND_RECEIVED))) { if ((p_port->tx.queue_size > PORT_TX_CRITICAL_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_CRITICAL_WM)) + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_CRITICAL_WM)) { RFCOMM_TRACE_WARNING ("PORT_Write: Queue size: %d", p_port->tx.queue_size); @@ -1526,7 +1526,7 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len) /* data fits into the end of the queue */ PORT_SCHEDULE_LOCK; - if (((p_buf = (BT_HDR *)p_port->tx.queue.p_last) != NULL) + if (((p_buf = (BT_HDR *)GKI_getlast(&p_port->tx.queue)) != NULL) && (((int)p_buf->len + available) <= (int)p_port->peer_mtu) && (((int)p_buf->len + available) <= (int)length)) { @@ -1560,12 +1560,12 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len) { /* if we're over buffer high water mark, we're done */ if ((p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM)) + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM)) { port_flow_control_user(p_port); event |= PORT_EV_FC; debug("tx queue is full,tx.queue_size:%d,tx.queue.count:%d,available:%d", - p_port->tx.queue_size, p_port->tx.queue.count, available); + p_port->tx.queue_size, GKI_queue_length(&p_port->tx.queue), available); break; } @@ -1677,7 +1677,7 @@ int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len) /* data fits into the end of the queue */ PORT_SCHEDULE_LOCK; - if (((p_buf = (BT_HDR *)p_port->tx.queue.p_last) != NULL) + if (((p_buf = (BT_HDR *)GKI_getlast(&p_port->tx.queue)) != NULL) && ((p_buf->len + max_len) <= p_port->peer_mtu) && ((p_buf->len + max_len) <= length)) { @@ -1698,7 +1698,7 @@ int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len) { /* if we're over buffer high water mark, we're done */ if ((p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM)) + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM)) break; /* continue with rfcomm data write */ diff --git a/stack/rfcomm/port_rfc.c b/stack/rfcomm/port_rfc.c index 5704c017c..3fa301380 100644 --- a/stack/rfcomm/port_rfc.c +++ b/stack/rfcomm/port_rfc.c @@ -865,7 +865,7 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf) /* Check if rx queue exceeds the limit */ if ((p_port->rx.queue_size + p_buf->len > PORT_RX_CRITICAL_WM) - || (p_port->rx.queue.count + 1 > p_port->rx_buf_critical)) + || (GKI_queue_length(&p_port->rx.queue) + 1 > p_port->rx_buf_critical)) { RFCOMM_TRACE_EVENT ("PORT_DataInd. Buffer over run. Dropping the buffer"); GKI_freebuf (p_buf); diff --git a/stack/rfcomm/port_utils.c b/stack/rfcomm/port_utils.c index 642ddb88f..7d29336dd 100644 --- a/stack/rfcomm/port_utils.c +++ b/stack/rfcomm/port_utils.c @@ -420,7 +420,7 @@ UINT32 port_flow_control_user (tPORT *p_port) || !p_port->rfc.p_mcb || !p_port->rfc.p_mcb->peer_ready || (p_port->tx.queue_size > PORT_TX_HIGH_WM) - || (p_port->tx.queue.count > PORT_TX_BUF_HIGH_WM); + || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM); if (p_port->tx.user_fc == fc) return (0); @@ -536,7 +536,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) p_port->rx.peer_fc = TRUE; } /* if queue count reached credit rx max, set peer fc */ - else if (p_port->rx.queue.count >= p_port->credit_rx_max) + else if (GKI_queue_length(&p_port->rx.queue) >= p_port->credit_rx_max) { p_port->rx.peer_fc = TRUE; } @@ -552,7 +552,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) /* check if it can be resumed now */ if (p_port->rx.peer_fc && (p_port->rx.queue_size < PORT_RX_LOW_WM) - && (p_port->rx.queue.count < PORT_RX_BUF_LOW_WM)) + && (GKI_queue_length(&p_port->rx.queue) < PORT_RX_BUF_LOW_WM)) { p_port->rx.peer_fc = FALSE; @@ -573,7 +573,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count) /* Check the size of the rx queue. If it exceeds certain */ /* level and flow control has not been sent to the peer do it now */ else if ( ((p_port->rx.queue_size > PORT_RX_HIGH_WM) - || (p_port->rx.queue.count > PORT_RX_BUF_HIGH_WM)) + || (GKI_queue_length(&p_port->rx.queue) > PORT_RX_BUF_HIGH_WM)) && !p_port->rx.peer_fc) { RFCOMM_TRACE_EVENT ("PORT_DataInd Data reached HW. Sending FC set."); diff --git a/stack/rfcomm/rfc_port_fsm.c b/stack/rfcomm/rfc_port_fsm.c index a998b6ec9..c0d7fbc35 100644 --- a/stack/rfcomm/rfc_port_fsm.c +++ b/stack/rfcomm/rfc_port_fsm.c @@ -431,7 +431,7 @@ void rfc_port_sm_opened (tPORT *p_port, UINT16 event, void *p_data) case RFC_EVENT_DISC: p_port->rfc.state = RFC_STATE_CLOSED; rfc_send_ua (p_port->rfc.p_mcb, p_port->dlci); - if(p_port->rx.queue.count) + if(!GKI_queue_is_empty(&p_port->rx.queue)) { /* give a chance to upper stack to close port properly */ RFCOMM_TRACE_DEBUG("port queue is not empty"); |