From 1140216a885ff175053f1c00cd3dc0fedd84c35c Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Tue, 2 Nov 2021 15:52:11 +0100 Subject: osmo_bsc_main: separate checks from bootstrap_bts The function bootstrap_bts does a few checks before it does the actual initialization. To make the code more modular, lets split the function into two functions, check_bts and bootstrap_bts. Also be sure that we print the BTS number when the check failes. Change-Id: Id2b26f147d2f35e156e2da8ee58d2bbbb93de4ac Related: SYS#5369 --- src/osmo-bsc/osmo_bsc_main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c index a39c1092e..11db2605d 100644 --- a/src/osmo-bsc/osmo_bsc_main.c +++ b/src/osmo-bsc/osmo_bsc_main.c @@ -436,10 +436,9 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, return 0; } -static int bootstrap_bts(struct gsm_bts *bts) +static int check_bts(struct gsm_bts *bts) { struct gsm_bts_trx *trx; - unsigned int n = 0; if (!bts->model) return -EFAULT; @@ -484,6 +483,13 @@ static int bootstrap_bts(struct gsm_bts *bts) } } + return 0; +} + +static void bootstrap_bts(struct gsm_bts *bts) +{ + unsigned int n = 0; + /* Control Channel Description is set from vty/config */ /* Determine the value of CCCH_CONF. Is TS0/C0 combined? */ @@ -510,8 +516,6 @@ static int bootstrap_bts(struct gsm_bts *bts) /* Initialize the BTS state */ gsm_bts_sm_mo_reset(bts->site_mgr); - - return 0; } static int bsc_network_configure(const char *config_file) @@ -535,11 +539,12 @@ static int bsc_network_configure(const char *config_file) osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL); llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) { - rc = bootstrap_bts(bts); + rc = check_bts(bts); if (rc < 0) { - LOGP(DNM, LOGL_FATAL, "Error bootstrapping BTS\n"); + LOGP(DNM, LOGL_FATAL, "(bts=%u) cannot bootstrap BTS, invalid BTS configuration\n", bts->nr); return rc; } + bootstrap_bts(bts); rc = e1_reconfig_bts(bts); if (rc < 0) { LOGP(DNM, LOGL_FATAL, "Error enabling E1 input driver\n"); -- cgit v1.2.3