From patchwork Thu Sep 24 10:29:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Freyther X-Patchwork-Id: 522225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (tmp.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id B6582140281 for ; Thu, 24 Sep 2015 20:30:50 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id D4BEA777F; Thu, 24 Sep 2015 10:30:47 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from gandharva.secretlabs.de (unknown [IPv6:2a01:4f8:161:8201::2:4]) by lists.osmocom.org (Postfix) with ESMTP id 4E80176D6 for ; Thu, 24 Sep 2015 10:30:40 +0000 (UTC) Received: from localhost.localdomain (ip5b4185b8.dynamic.kabel-deutschland.de [91.65.133.184]) by gandharva.secretlabs.de (Postfix) with ESMTPSA id AFDBF5336F for ; Thu, 24 Sep 2015 10:30:39 +0000 (UTC) From: Holger Hans Peter Freyther To: openbsc@lists.osmocom.org Subject: [PATCH 3/3] amr: Kill more duplication and let the code work one of the modes Date: Thu, 24 Sep 2015 12:29:36 +0200 Message-Id: <1443090576-63058-3-git-send-email-holger@freyther.de> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1443090576-63058-1-git-send-email-holger@freyther.de> References: <1443090576-63058-1-git-send-email-holger@freyther.de> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Holger Hans Peter Freyther --- openbsc/src/libbsc/bsc_vty.c | 59 +++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index d940624..f8ef833 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -479,6 +479,21 @@ static void config_write_bts_model(struct vty *vty, struct gsm_bts *bts) config_write_trx_single(vty, trx); } +static void write_amr_modes(struct vty *vty, const char *prefix, + const char *name, struct amr_mode *modes, int num) +{ + int i; + + vty_out(vty, " %s threshold %s", prefix, name); + for (i = 0; i < num - 1; i++) + vty_out(vty, " %d", modes[i].threshold); + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, " %s hysteresis %s", prefix, name); + for (i = 0; i < num - 1; i++) + vty_out(vty, " %d", modes[i].hysteresis); + vty_out(vty, "%s", VTY_NEWLINE); +} + static void config_write_bts_amr(struct vty *vty, struct gsm_bts *bts, struct amr_multirate_conf *mr, int full) { @@ -503,26 +518,8 @@ static void config_write_bts_amr(struct vty *vty, struct gsm_bts *bts, if (num > 4) num = 4; if (num > 1) { - vty_out(vty, " %s threshold ms", prefix); - for (i = 0; i < num - 1; i++) { - vty_out(vty, " %d", mr->ms_mode[i].threshold); - } - vty_out(vty, "%s", VTY_NEWLINE); - vty_out(vty, " %s hysteresis ms", prefix); - for (i = 0; i < num - 1; i++) { - vty_out(vty, " %d", mr->ms_mode[i].hysteresis); - } - vty_out(vty, "%s", VTY_NEWLINE); - vty_out(vty, " %s threshold bts", prefix); - for (i = 0; i < num - 1; i++) { - vty_out(vty, " %d", mr->bts_mode[i].threshold); - } - vty_out(vty, "%s", VTY_NEWLINE); - vty_out(vty, " %s hysteresis bts", prefix); - for (i = 0; i < num - 1; i++) { - vty_out(vty, " %d", mr->bts_mode[i].hysteresis); - } - vty_out(vty, "%s", VTY_NEWLINE); + write_amr_modes(vty, prefix, "ms", mr->ms_mode, num); + write_amr_modes(vty, prefix, "bts", mr->bts_mode, num); } vty_out(vty, " %s start-mode ", prefix); if (mr_conf->icmi) { @@ -2953,30 +2950,24 @@ static void get_amr_th_from_arg(struct vty *vty, int argc, const char *argv[], i { struct gsm_bts *bts = vty->index; struct amr_multirate_conf *mr = (full) ? &bts->mr_full: &bts->mr_half; + struct amr_mode *modes; int i; - if (argv[0][0]=='m') { - for (i = 0; i < argc - 1; i++) - mr->ms_mode[i].threshold = atoi(argv[i + 1]); - } else { - for (i = 0; i < argc - 1; i++) - mr->bts_mode[i].threshold = atoi(argv[i + 1]); - } + modes = argv[0][0]=='m' ? mr->ms_mode : mr->bts_mode; + for (i = 0; i < argc - 1; i++) + modes[i].threshold = atoi(argv[i + 1]); } static void get_amr_hy_from_arg(struct vty *vty, int argc, const char *argv[], int full) { struct gsm_bts *bts = vty->index; struct amr_multirate_conf *mr = (full) ? &bts->mr_full: &bts->mr_half; + struct amr_mode *modes; int i; - if (argv[0][0]=='m') { - for (i = 0; i < argc - 1; i++) - mr->ms_mode[i].hysteresis = atoi(argv[i + 1]); - } else { - for (i = 0; i < argc - 1; i++) - mr->bts_mode[i].hysteresis = atoi(argv[i + 1]); - } + modes = argv[0][0]=='m' ? mr->ms_mode : mr->bts_mode; + for (i = 0; i < argc - 1; i++) + modes[i].hysteresis = atoi(argv[i + 1]); } static void get_amr_start_from_arg(struct vty *vty, const char *argv[], int full)