Add new lchan_select_set_type() API helper
It's an easy helper, but it helps in standarizing and finding similar places in code. Morevoer, it will be used in follow-up commit where we first use lchan_avail_by_type and finally we select it in a later stage. Change-Id: I025a40962a5e5d40543b297a0760e47618fb525c
This commit is contained in:
parent
181b5f3b9a
commit
2956b52c5b
|
@ -6,3 +6,4 @@ enum gsm_chan_t chan_mode_to_chan_type(enum gsm48_chan_mode chan_mode, enum chan
|
|||
struct gsm_lchan *lchan_select_by_chan_mode(struct gsm_bts *bts,
|
||||
enum gsm48_chan_mode chan_mode, enum channel_rate chan_rate);
|
||||
struct gsm_lchan *lchan_avail_by_type(struct gsm_bts *bts, enum gsm_chan_t type, bool log);
|
||||
void lchan_select_set_type(struct gsm_lchan *lchan, enum gsm_chan_t type);
|
||||
|
|
|
@ -6299,7 +6299,7 @@ static int lchan_act_single(struct vty *vty, struct gsm_lchan *lchan, const char
|
|||
}
|
||||
|
||||
/* configure the lchan */
|
||||
lchan->type = lchan_t;
|
||||
lchan_select_set_type(lchan, lchan_t);
|
||||
if (!strcmp(codec_str, "hr") || !strcmp(codec_str, "fr")) {
|
||||
info = (struct lchan_activate_info) {
|
||||
.activ_for = ACTIVATE_FOR_VTY,
|
||||
|
@ -6792,9 +6792,9 @@ DEFUN(lchan_reassign, lchan_reassign_cmd,
|
|||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
/* lchan_select_*() sets the lchan->type, we need to do the same here, so that activation will work out. */
|
||||
to_lchan->type = chan_mode_to_chan_type(from_lchan->current_ch_mode_rate.chan_mode,
|
||||
from_lchan->current_ch_mode_rate.chan_rate);
|
||||
/* Set lchan type, so that activation will work out. */
|
||||
lchan_select_set_type(to_lchan, chan_mode_to_chan_type(from_lchan->current_ch_mode_rate.chan_mode,
|
||||
from_lchan->current_ch_mode_rate.chan_rate));
|
||||
|
||||
LOG_LCHAN(from_lchan, LOGL_NOTICE, "VTY requests re-assignment of this lchan to %s%s\n",
|
||||
gsm_lchan_name(to_lchan), to_lchan->vamos.is_secondary ? " (to VAMOS mode)" : "");
|
||||
|
|
|
@ -296,16 +296,26 @@ struct gsm_lchan *lchan_select_by_type(struct gsm_bts *bts, enum gsm_chan_t type
|
|||
{
|
||||
struct gsm_lchan *lchan = NULL;
|
||||
|
||||
lchan = lchan_avail_by_type(bts, type, true);
|
||||
|
||||
LOG_BTS(bts, DRLL, LOGL_DEBUG, "lchan_select_by_type(%s)\n", gsm_lchant_name(type));
|
||||
|
||||
if (lchan) {
|
||||
lchan->type = type;
|
||||
LOG_LCHAN(lchan, LOGL_INFO, "Selected\n");
|
||||
} else
|
||||
lchan = lchan_avail_by_type(bts, type, true);
|
||||
|
||||
if (!lchan) {
|
||||
LOG_BTS(bts, DRLL, LOGL_NOTICE, "Failed to select %s channel\n",
|
||||
gsm_lchant_name(type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lchan_select_set_type(lchan, type);
|
||||
return lchan;
|
||||
}
|
||||
|
||||
/* Set available lchan to given type. Usually used on lchan obtained with
|
||||
* lchan_avail_by_type. The next logical step is lchan_activate() on it, which
|
||||
* would possibly cause dynamic timeslot pchan switching, taken care of by the
|
||||
* lchan and timeslot FSMs. */
|
||||
void lchan_select_set_type(struct gsm_lchan *lchan, enum gsm_chan_t type)
|
||||
{
|
||||
lchan->type = type;
|
||||
LOG_LCHAN(lchan, LOGL_INFO, "Selected\n");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue