Change in osmo-bsc[master]: bts: Drop duplicated function to get trx by number

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

pespin gerrit-no-reply at lists.osmocom.org
Thu Jul 16 12:24:04 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/19297 )


Change subject: bts: Drop duplicated function to get trx by number
......................................................................

bts: Drop duplicated function to get trx by number

In the big mess of gsm_data we reached a point where we have multiple
functions doing the same thing, most probably because it's hard finding
stuff in there. Let's drop one of them (the one which less callers) and
move it to bts.*, where it belongs.

Change-Id: I9071a0ab250844619280fbe2be63ed99f2c87eb1
---
M include/osmocom/bsc/bts.h
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/abis_nm.c
M src/osmo-bsc/abis_om2000.c
M src/osmo-bsc/abis_om2000_vty.c
M src/osmo-bsc/bsc_ctrl_lookup.c
M src/osmo-bsc/bts.c
M src/osmo-bsc/gsm_data.c
8 files changed, 14 insertions(+), 25 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/97/19297/1

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index a18d8ae..0ada79a 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -596,7 +596,7 @@
 
 int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
 
-struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
+struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
 
 int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode);
 
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index a9ce023..e9105b3 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -964,7 +964,6 @@
 				   int match_idx);
 
 struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
-struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
 
 extern const struct value_string gsm_chreq_descs[];
 extern const struct value_string gsm_pchant_names[];
diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c
index 4ce27f3..19eed8c 100644
--- a/src/osmo-bsc/abis_nm.c
+++ b/src/osmo-bsc/abis_nm.c
@@ -800,7 +800,7 @@
 {
 	struct abis_om_fom_hdr *foh = msgb_l3(oml_msg);
 	struct e1inp_sign_link *sign_link = oml_msg->dst;
-	struct gsm_bts_trx *trx = gsm_bts_trx_by_nr(sign_link->trx->bts, foh->obj_inst.trx_nr);
+	struct gsm_bts_trx *trx = gsm_bts_trx_num(sign_link->trx->bts, foh->obj_inst.trx_nr);
 	uint8_t ts_nr = foh->obj_inst.ts_nr;
 	if (!trx) {
 		LOGP(DNM, LOGL_ERROR, "%s Channel OPSTART ACK for sign_link without trx\n",
@@ -2791,7 +2791,7 @@
 
 	/* The message might be received over the main OML link, so we cannot
 	 * just use sign_link->trx. Resolve it by number from the FOM header. */
-	trx = gsm_bts_trx_by_nr(sign_link->trx->bts, foh->obj_inst.trx_nr);
+	trx = gsm_bts_trx_num(sign_link->trx->bts, foh->obj_inst.trx_nr);
 
 	DEBUGPFOH(DNM, foh, "Rx IPACCESS(0x%02x): %s\n", foh->msg_type,
 		  osmo_hexdump(foh->data, oh->length - sizeof(*foh)));
diff --git a/src/osmo-bsc/abis_om2000.c b/src/osmo-bsc/abis_om2000.c
index 1e4ef97..5c8b378 100644
--- a/src/osmo-bsc/abis_om2000.c
+++ b/src/osmo-bsc/abis_om2000.c
@@ -1039,7 +1039,7 @@
 	case OM2K_MO_CLS_TX:
 	case OM2K_MO_CLS_RX:
 		/* Route through per-TRX OML Link to the appropriate TRX */
-		trx = gsm_bts_trx_by_nr(bts, o2h->mo.inst);
+		trx = gsm_bts_trx_num(bts, o2h->mo.inst);
 		if (!trx) {
 			LOGP(DNM, LOGL_ERROR, "MO=%s Tx Dropping msg to "
 				"non-existing TRX\n", om2k_mo_name(&o2h->mo));
@@ -1049,7 +1049,7 @@
 		break;
 	case OM2K_MO_CLS_TS:
 		/* Route through per-TRX OML Link to the appropriate TRX */
-		trx = gsm_bts_trx_by_nr(bts, o2h->mo.assoc_so);
+		trx = gsm_bts_trx_num(bts, o2h->mo.assoc_so);
 		if (!trx) {
 			LOGP(DNM, LOGL_ERROR, "MO=%s Tx Dropping msg to "
 				"non-existing TRX\n", om2k_mo_name(&o2h->mo));
diff --git a/src/osmo-bsc/abis_om2000_vty.c b/src/osmo-bsc/abis_om2000_vty.c
index b00c7dd..26e8488 100644
--- a/src/osmo-bsc/abis_om2000_vty.c
+++ b/src/osmo-bsc/abis_om2000_vty.c
@@ -561,7 +561,7 @@
 		abis_om2k_tx_con_conf_req(bts);
 		break;
 	case OM2K_MO_CLS_TS:
-		trx = gsm_bts_trx_by_nr(bts, oms->mo.assoc_so);
+		trx = gsm_bts_trx_num(bts, oms->mo.assoc_so);
 		if (!trx) {
 			vty_out(vty, "%% BTS %u has no TRX %u%s", bts->nr,
 				oms->mo.assoc_so, VTY_NEWLINE);
@@ -578,7 +578,7 @@
 	case OM2K_MO_CLS_RX:
 	case OM2K_MO_CLS_TX:
 	case OM2K_MO_CLS_TRXC:
-		trx = gsm_bts_trx_by_nr(bts, oms->mo.inst);
+		trx = gsm_bts_trx_num(bts, oms->mo.inst);
 		if (!trx) {
 			vty_out(vty, "%% BTS %u has no TRX %u%s", bts->nr,
 				oms->mo.inst, VTY_NEWLINE);
diff --git a/src/osmo-bsc/bsc_ctrl_lookup.c b/src/osmo-bsc/bsc_ctrl_lookup.c
index 38d1ba4..4328d76 100644
--- a/src/osmo-bsc/bsc_ctrl_lookup.c
+++ b/src/osmo-bsc/bsc_ctrl_lookup.c
@@ -29,6 +29,7 @@
 #include <osmocom/bsc/debug.h>
 #include <osmocom/bsc/gsm_data.h>
 #include <osmocom/bsc/bsc_msc_data.h>
+#include <osmocom/bsc/bts.h>
 
 extern vector ctrl_node_vec;
 
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 9aae1d5..4b191b5 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -558,14 +558,18 @@
 	return 1;
 }
 
-struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr)
+struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num)
 {
 	struct gsm_bts_trx *trx;
 
+	if (num >= bts->num_trx)
+		return NULL;
+
 	llist_for_each_entry(trx, &bts->trx_list, list) {
-		if (trx->nr == nr)
+		if (trx->nr == num)
 			return trx;
 	}
+
 	return NULL;
 }
 
diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c
index 0dafa35..49121d6 100644
--- a/src/osmo-bsc/gsm_data.c
+++ b/src/osmo-bsc/gsm_data.c
@@ -349,21 +349,6 @@
 	return trx;
 }
 
-struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num)
-{
-	struct gsm_bts_trx *trx;
-
-	if (num >= bts->num_trx)
-		return NULL;
-
-	llist_for_each_entry(trx, &bts->trx_list, list) {
-		if (trx->nr == num)
-			return trx;
-	}
-
-	return NULL;
-}
-
 static char ts2str[255];
 
 char *gsm_bts_name(const struct gsm_bts *bts)

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I9071a0ab250844619280fbe2be63ed99f2c87eb1
Gerrit-Change-Number: 19297
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200716/37b5dec1/attachment.htm>


More information about the gerrit-log mailing list