<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/simtrace2/+/16602">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">card_emu: Avoid recursive calls to card_set_state()<br><br>A function that is called to set the state should not in itself<br>contain logic to issue further state changes.<br><br>Let's shift the related block out to the end of card_emu_io_statechg(),<br>which is the only source of card_set_state() calls for the<br>WAIT_{POWER,CLK,RST} states anyway.<br><br>As an added benefit, the block of statements is now also executed if<br>there's no state change - something that was prevented by the<br>"if old == new" state guard at the top of card_set_state().  I believe<br>this may help us to cover more (non-standard) card activation sequences.<br><br>Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6<br>---<br>M firmware/libcommon/source/card_emu.c<br>1 file changed, 9 insertions(+), 7 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/02/16602/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c</span><br><span>index f53b3df..66932af 100644</span><br><span>--- a/firmware/libcommon/source/card_emu.c</span><br><span>+++ b/firmware/libcommon/source/card_emu.c</span><br><span>@@ -429,13 +429,6 @@</span><br><span>  case ISO_S_WAIT_RST:</span><br><span>                 /* disable Rx and Tx of UART */</span><br><span>              card_emu_uart_enable(ch->uart_chan, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-              /* check end activation state (only necessary if the reader to not respect the activation sequence) */</span><br><span style="color: hsl(0, 100%, 40%);">-          if (ch->vcc_active && ch->clocked && !ch->in_reset) {</span><br><span style="color: hsl(0, 100%, 40%);">-                  /* enable the TC/ETU counter once reset has been released */</span><br><span style="color: hsl(0, 100%, 40%);">-                    tc_etu_enable(ch->tc_chan);</span><br><span style="color: hsl(0, 100%, 40%);">-                  /* prepare to send the ATR */</span><br><span style="color: hsl(0, 100%, 40%);">-                   card_set_state(ch, ISO_S_WAIT_ATR);</span><br><span style="color: hsl(0, 100%, 40%);">-             }</span><br><span>            break;</span><br><span>       case ISO_S_WAIT_ATR:</span><br><span>                 /* Reset to initial Fi / Di ratio */</span><br><span>@@ -1114,6 +1107,15 @@</span><br><span>                ch->in_reset = active;</span><br><span>            break;</span><br><span>       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* check end activation state (only necessary if the reader to</span><br><span style="color: hsl(120, 100%, 40%);">+         * not respect the activation sequence) */</span><br><span style="color: hsl(120, 100%, 40%);">+    if (ch->vcc_active && ch->clocked && !ch->in_reset) {</span><br><span style="color: hsl(120, 100%, 40%);">+                /* enable the TC/ETU counter once reset has been released */</span><br><span style="color: hsl(120, 100%, 40%);">+          tc_etu_enable(ch->tc_chan);</span><br><span style="color: hsl(120, 100%, 40%);">+                /* prepare to send the ATR */</span><br><span style="color: hsl(120, 100%, 40%);">+         card_set_state(ch, ISO_S_WAIT_ATR);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span> }</span><br><span> </span><br><span> /* User sets a new ATR to be returned during next card reset */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/simtrace2/+/16602">change 16602</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/simtrace2/+/16602"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: simtrace2 </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6 </div>
<div style="display:none"> Gerrit-Change-Number: 16602 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>