mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 05:38:33 +03:00
card_emu: Only allocate a new buffer if needed in send_tpdu_header()
This commit is contained in:
@@ -580,14 +580,21 @@ static void send_tpdu_header(struct card_handle *ch)
|
||||
ch->tpdu.hdr[4]);
|
||||
|
||||
/* if we already/still have a context, send it off */
|
||||
if (ch->uart_rx_ctx && ch->uart_rx_ctx->idx) {
|
||||
flush_rx_buffer(ch);
|
||||
if (ch->uart_rx_ctx) {
|
||||
TRACE_DEBUG("have old buffer\r\n");
|
||||
if (ch->uart_rx_ctx->idx) {
|
||||
TRACE_DEBUG("flushing old buffer\r\n");
|
||||
flush_rx_buffer(ch);
|
||||
}
|
||||
} else {
|
||||
TRACE_DEBUG("allocating new buffer\r\n");
|
||||
/* ensure we have a new buffer */
|
||||
ch->uart_rx_ctx = req_ctx_find_get(0, RCTX_S_FREE, RCTX_S_UART_RX_BUSY);
|
||||
if (!ch->uart_rx_ctx) {
|
||||
TRACE_ERROR("%s: ENOMEM\r\n", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* ensure we have a new buffer */
|
||||
ch->uart_rx_ctx = req_ctx_find_get(0, RCTX_S_FREE, RCTX_S_UART_RX_BUSY);
|
||||
if (!ch->uart_rx_ctx)
|
||||
return;
|
||||
rctx = ch->uart_rx_ctx;
|
||||
rd = (struct cardemu_usb_msg_rx_data *) rctx->data;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user