Skip to content

Commit 4a495b9

Browse files
freemangordongregkh
authored andcommitted
tty: n_gsm: Fix control dlci ADM mode processing
Currently, code retries n2 times to open control dlci in ABM mode before switching to ADM mode, but only if DM has been received. This contradicts to the comment that dlci is switched to control mode unconditionally if DLCI_OPENING retries time out. Also, it does not make sense to continue trying once DM has received. Change the logic to switch to ADM mode upon DM received. That way control channel state will change to DLCI_OPEN way faster. Fix the misleading comment while at it. Signed-off-by: Ivaylo Dimitrov <[email protected]> Signed-off-by: Tony Lindgren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e2e4025 commit 4a495b9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/tty/n_gsm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ static int gsm_dlci_negotiate(struct gsm_dlci *dlci)
22242224
*
22252225
* Some control dlci can stay in ADM mode with other dlci working just
22262226
* fine. In that case we can just keep the control dlci open after the
2227-
* DLCI_OPENING retries time out.
2227+
* DLCI_OPENING receives DM.
22282228
*/
22292229

22302230
static void gsm_dlci_t1(struct timer_list *t)
@@ -2243,19 +2243,19 @@ static void gsm_dlci_t1(struct timer_list *t)
22432243
}
22442244
break;
22452245
case DLCI_OPENING:
2246-
if (dlci->retries) {
2246+
if (!dlci->addr && gsm->control == (DM | PF)) {
2247+
if (debug & DBG_ERRORS)
2248+
pr_info("DLCI 0 opening in ADM mode.\n");
2249+
dlci->mode = DLCI_MODE_ADM;
2250+
gsm_dlci_open(dlci);
2251+
} else if (dlci->retries) {
22472252
if (!dlci->addr || !gsm->dlci[0] ||
22482253
gsm->dlci[0]->state != DLCI_OPENING) {
22492254
dlci->retries--;
22502255
gsm_command(dlci->gsm, dlci->addr, SABM|PF);
22512256
}
22522257

22532258
mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
2254-
} else if (!dlci->addr && gsm->control == (DM | PF)) {
2255-
if (debug & DBG_ERRORS)
2256-
pr_info("DLCI 0 opening in ADM mode.\n");
2257-
dlci->mode = DLCI_MODE_ADM;
2258-
gsm_dlci_open(dlci);
22592259
} else {
22602260
gsm->open_error++;
22612261
gsm_dlci_begin_close(dlci); /* prevent half open link */

0 commit comments

Comments
 (0)