<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bts/+/23867">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo-bts-trx: reduce code nasting in trx_if_send_burst()<br><br>If the PHY is not powered on and we are not supposed to send any<br>bursts to it, then trx_if_send_burst() should just return early.<br><br>Change-Id: I578bd5a731ad88ebff283c75bb7eb268d9e7e787<br>Related: SYS#4895, OS#4941, OS#4006<br>---<br>M src/osmo-bts-trx/trx_if.c<br>1 file changed, 15 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/67/23867/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c</span><br><span>index 9ea16ca..f3c805d 100644</span><br><span>--- a/src/osmo-bts-trx/trx_if.c</span><br><span>+++ b/src/osmo-bts-trx/trx_if.c</span><br><span>@@ -1001,6 +1001,13 @@</span><br><span>        uint8_t pdu_ver = l1h->config.trxd_pdu_ver_use;</span><br><span>   uint8_t *ptr = &trx_data_buf[0];</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+      /* Make sure that the PHY is powered on */</span><br><span style="color: hsl(120, 100%, 40%);">+    if (!trx_if_powered(l1h)) {</span><br><span style="color: hsl(120, 100%, 40%);">+           LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                   "Ignoring Tx data, transceiver is powered off\n");</span><br><span style="color: hsl(120, 100%, 40%);">+          return -ENODEV;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  if ((br->burst_len != GSM_BURST_LEN) && (br->burst_len != EGPRS_BURST_LEN)) {</span><br><span>          LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Tx burst length %zu invalid\n",</span><br><span>                       br->burst_len);</span><br><span>@@ -1029,18 +1036,14 @@</span><br><span>         /* copy ubits {0,1} */</span><br><span>       memcpy(ptr + 6, br->burst, br->burst_len);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    /* we must be sure that TRX is on */</span><br><span style="color: hsl(0, 100%, 40%);">-    if (trx_if_powered(l1h)) {</span><br><span style="color: hsl(0, 100%, 40%);">-              snd_len = send(l1h->trx_ofd_data.fd, trx_data_buf, br->burst_len + 6, 0);</span><br><span style="color: hsl(0, 100%, 40%);">-         if (snd_len <= 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-                  strerror_r(errno, (char *) trx_data_buf, sizeof(trx_data_buf));</span><br><span style="color: hsl(0, 100%, 40%);">-                 LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,</span><br><span style="color: hsl(0, 100%, 40%);">-                             "send() failed on TRXD with rc=%zd (%s)\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                           snd_len, trx_data_buf);</span><br><span style="color: hsl(0, 100%, 40%);">-                 return -2;</span><br><span style="color: hsl(0, 100%, 40%);">-              }</span><br><span style="color: hsl(0, 100%, 40%);">-       } else</span><br><span style="color: hsl(0, 100%, 40%);">-          LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Ignoring TX data, transceiver powered off.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+        snd_len = send(l1h->trx_ofd_data.fd, trx_data_buf, br->burst_len + 6, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+       if (snd_len <= 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                strerror_r(errno, (char *) trx_data_buf, sizeof(trx_data_buf));</span><br><span style="color: hsl(120, 100%, 40%);">+               LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+                   "send() failed on TRXD with rc=%zd (%s)\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                 snd_len, trx_data_buf);</span><br><span style="color: hsl(120, 100%, 40%);">+               return -2;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span> </span><br><span>        return 0;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bts/+/23867">change 23867</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/osmo-bts/+/23867"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I578bd5a731ad88ebff283c75bb7eb268d9e7e787 </div>
<div style="display:none"> Gerrit-Change-Number: 23867 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>