Change in osmo-bts[master]: osmo-bts-trx: reduce code nasting in trx_if_send_burst()

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/.

fixeria gerrit-no-reply at lists.osmocom.org
Thu Apr 22 15:25:34 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/23867 )


Change subject: osmo-bts-trx: reduce code nasting in trx_if_send_burst()
......................................................................

osmo-bts-trx: reduce code nasting in trx_if_send_burst()

If the PHY is not powered on and we are not supposed to send any
bursts to it, then trx_if_send_burst() should just return early.

Change-Id: I578bd5a731ad88ebff283c75bb7eb268d9e7e787
Related: SYS#4895, OS#4941, OS#4006
---
M src/osmo-bts-trx/trx_if.c
1 file changed, 15 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/67/23867/1

diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 9ea16ca..f3c805d 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -1001,6 +1001,13 @@
 	uint8_t pdu_ver = l1h->config.trxd_pdu_ver_use;
 	uint8_t *ptr = &trx_data_buf[0];
 
+	/* Make sure that the PHY is powered on */
+	if (!trx_if_powered(l1h)) {
+		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
+			"Ignoring Tx data, transceiver is powered off\n");
+		return -ENODEV;
+	}
+
 	if ((br->burst_len != GSM_BURST_LEN) && (br->burst_len != EGPRS_BURST_LEN)) {
 		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Tx burst length %zu invalid\n",
 			br->burst_len);
@@ -1029,18 +1036,14 @@
 	/* copy ubits {0,1} */
 	memcpy(ptr + 6, br->burst, br->burst_len);
 
-	/* we must be sure that TRX is on */
-	if (trx_if_powered(l1h)) {
-		snd_len = send(l1h->trx_ofd_data.fd, trx_data_buf, br->burst_len + 6, 0);
-		if (snd_len <= 0) {
-			strerror_r(errno, (char *) trx_data_buf, sizeof(trx_data_buf));
-			LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
-				"send() failed on TRXD with rc=%zd (%s)\n",
-				snd_len, trx_data_buf);
-			return -2;
-		}
-	} else
-		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR, "Ignoring TX data, transceiver powered off.\n");
+	snd_len = send(l1h->trx_ofd_data.fd, trx_data_buf, br->burst_len + 6, 0);
+	if (snd_len <= 0) {
+		strerror_r(errno, (char *) trx_data_buf, sizeof(trx_data_buf));
+		LOGPPHI(l1h->phy_inst, DTRX, LOGL_ERROR,
+			"send() failed on TRXD with rc=%zd (%s)\n",
+			snd_len, trx_data_buf);
+		return -2;
+	}
 
 	return 0;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/23867
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I578bd5a731ad88ebff283c75bb7eb268d9e7e787
Gerrit-Change-Number: 23867
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210422/68ee97c1/attachment.htm>


More information about the gerrit-log mailing list