This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/16582 ) Change subject: card_emu: Factor out card_handle_reset() from card_emu_init() ...................................................................... card_emu: Factor out card_handle_reset() from card_emu_init() Let's move all initialization of state that may change at runtime to a separate function: card_handle_reset(). This has the advantage that the related function may also be called at later/other instances, not just during initialization of card_emu. Change-Id: I0954d192d001a3af5592010cc84a3a22aaf4b030 Related: OS#4251 --- M firmware/libcommon/source/card_emu.c 1 file changed, 30 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/82/16582/1 diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index f95f5d1..3f2cb7b 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -1,6 +1,6 @@ /* ISO7816-3 state machine for the card side * - * (C) 2010-2017 by Harald Welte <laforge at gnumonks.org> + * (C) 2010-2019 by Harald Welte <laforge at gnumonks.org> * (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon at sysmocom.de> * * This program is free software; you can redistribute it and/or modify @@ -233,6 +233,33 @@ } stats; }; +/* reset all the 'dynamic' state of the card handle to the initial/default values */ +static void card_handle_reset(struct card_handle *ch) +{ + struct msgb *msg; + + ch->fi = 1; + ch->di = 1; + ch->wi = ISO7816_3_DEFAULT_WI; + ch->waiting_time = ISO7816_3_INIT_WTIME; + ch->atr.idx = 0; + ch->pts.state = PTS_S_WAIT_REQ_PTSS; + ch->tpdu.state = TPDU_S_WAIT_CLA; + + /* release any buffers we may still own */ + if (ch->uart_tx_msg) { + usb_buf_free(ch->uart_tx_msg); + ch->uart_tx_msg = NULL; + } + if (ch->uart_rx_msg) { + usb_buf_free(ch->uart_rx_msg); + ch->uart_rx_msg = NULL; + } + while ((msg = msgb_dequeue(&ch->uart_tx_queue))) { + usb_buf_free(msg); + } +} + struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch) { return &ch->uart_tx_queue; @@ -1177,22 +1204,15 @@ ch->in_reset = in_reset; ch->clocked = clocked; - ch->fi = 0; - ch->di = 1; - ch->wi = ISO7816_3_DEFAULT_WI; - ch->tc_chan = tc_chan; ch->uart_chan = uart_chan; - ch->waiting_time = ISO7816_3_INIT_WTIME; - ch->atr.idx = 0; ch->atr.len = sizeof(default_atr); memcpy(ch->atr.atr, default_atr, ch->atr.len); - ch->pts.state = PTS_S_WAIT_REQ_PTSS; - ch->tpdu.state = TPDU_S_WAIT_CLA; - tc_etu_init(ch->tc_chan, ch); + card_handle_reset(ch); + return ch; } -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/16582 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: I0954d192d001a3af5592010cc84a3a22aaf4b030 Gerrit-Change-Number: 16582 Gerrit-PatchSet: 1 Gerrit-Owner: laforge <laforge at osmocom.org> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191214/63e0a32c/attachment.htm>