diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 21:00:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 21:00:37 +0000 |
commit | 94ac2ab3fff96814d7460a27a0e9d004abbd4128 (patch) | |
tree | 9a4eb8cc234b540b0f4b93363109cdd37a20540b /drivers/tty/n_gsm.c | |
parent | Adding debian version 6.8.12-1. (diff) | |
download | linux-94ac2ab3fff96814d7460a27a0e9d004abbd4128.tar.xz linux-94ac2ab3fff96814d7460a27a0e9d004abbd4128.zip |
Merging upstream version 6.9.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/tty/n_gsm.c')
-rw-r--r-- | drivers/tty/n_gsm.c | 140 |
1 files changed, 43 insertions, 97 deletions
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index afbf7837b5..4036566feb 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -245,18 +245,16 @@ enum gsm_encoding { enum gsm_mux_state { GSM_SEARCH, - GSM0_ADDRESS, - GSM0_CONTROL, - GSM0_LEN0, - GSM0_LEN1, - GSM0_DATA, - GSM0_FCS, - GSM0_SSOF, - GSM1_START, - GSM1_ADDRESS, - GSM1_CONTROL, - GSM1_DATA, - GSM1_OVERRUN, + GSM_START, + GSM_ADDRESS, + GSM_CONTROL, + GSM_LEN, + GSM_DATA, + GSM_FCS, + GSM_OVERRUN, + GSM_LEN0, + GSM_LEN1, + GSM_SSOF, }; /* @@ -2849,30 +2847,6 @@ invalid: return; } -/** - * gsm0_receive_state_check_and_fix - check and correct receive state - * @gsm: gsm data for this ldisc instance - * - * Ensures that the current receive state is valid for basic option mode. - */ - -static void gsm0_receive_state_check_and_fix(struct gsm_mux *gsm) -{ - switch (gsm->state) { - case GSM_SEARCH: - case GSM0_ADDRESS: - case GSM0_CONTROL: - case GSM0_LEN0: - case GSM0_LEN1: - case GSM0_DATA: - case GSM0_FCS: - case GSM0_SSOF: - break; - default: - gsm->state = GSM_SEARCH; - break; - } -} /** * gsm0_receive - perform processing for non-transparency @@ -2886,27 +2860,26 @@ static void gsm0_receive(struct gsm_mux *gsm, u8 c) { unsigned int len; - gsm0_receive_state_check_and_fix(gsm); switch (gsm->state) { case GSM_SEARCH: /* SOF marker */ if (c == GSM0_SOF) { - gsm->state = GSM0_ADDRESS; + gsm->state = GSM_ADDRESS; gsm->address = 0; gsm->len = 0; gsm->fcs = INIT_FCS; } break; - case GSM0_ADDRESS: /* Address EA */ + case GSM_ADDRESS: /* Address EA */ gsm->fcs = gsm_fcs_add(gsm->fcs, c); if (gsm_read_ea(&gsm->address, c)) - gsm->state = GSM0_CONTROL; + gsm->state = GSM_CONTROL; break; - case GSM0_CONTROL: /* Control Byte */ + case GSM_CONTROL: /* Control Byte */ gsm->fcs = gsm_fcs_add(gsm->fcs, c); gsm->control = c; - gsm->state = GSM0_LEN0; + gsm->state = GSM_LEN0; break; - case GSM0_LEN0: /* Length EA */ + case GSM_LEN0: /* Length EA */ gsm->fcs = gsm_fcs_add(gsm->fcs, c); if (gsm_read_ea(&gsm->len, c)) { if (gsm->len > gsm->mru) { @@ -2916,14 +2889,14 @@ static void gsm0_receive(struct gsm_mux *gsm, u8 c) } gsm->count = 0; if (!gsm->len) - gsm->state = GSM0_FCS; + gsm->state = GSM_FCS; else - gsm->state = GSM0_DATA; + gsm->state = GSM_DATA; break; } - gsm->state = GSM0_LEN1; + gsm->state = GSM_LEN1; break; - case GSM0_LEN1: + case GSM_LEN1: gsm->fcs = gsm_fcs_add(gsm->fcs, c); len = c; gsm->len |= len << 7; @@ -2934,29 +2907,26 @@ static void gsm0_receive(struct gsm_mux *gsm, u8 c) } gsm->count = 0; if (!gsm->len) - gsm->state = GSM0_FCS; + gsm->state = GSM_FCS; else - gsm->state = GSM0_DATA; + gsm->state = GSM_DATA; break; - case GSM0_DATA: /* Data */ + case GSM_DATA: /* Data */ gsm->buf[gsm->count++] = c; - if (gsm->count >= MAX_MRU) { - gsm->bad_size++; - gsm->state = GSM_SEARCH; - } else if (gsm->count >= gsm->len) { + if (gsm->count == gsm->len) { /* Calculate final FCS for UI frames over all data */ if ((gsm->control & ~PF) != UIH) { gsm->fcs = gsm_fcs_add_block(gsm->fcs, gsm->buf, gsm->count); } - gsm->state = GSM0_FCS; + gsm->state = GSM_FCS; } break; - case GSM0_FCS: /* FCS follows the packet */ + case GSM_FCS: /* FCS follows the packet */ gsm->fcs = gsm_fcs_add(gsm->fcs, c); - gsm->state = GSM0_SSOF; + gsm->state = GSM_SSOF; break; - case GSM0_SSOF: + case GSM_SSOF: gsm->state = GSM_SEARCH; if (c == GSM0_SOF) gsm_queue(gsm); @@ -2970,29 +2940,6 @@ static void gsm0_receive(struct gsm_mux *gsm, u8 c) } /** - * gsm1_receive_state_check_and_fix - check and correct receive state - * @gsm: gsm data for this ldisc instance - * - * Ensures that the current receive state is valid for advanced option mode. - */ - -static void gsm1_receive_state_check_and_fix(struct gsm_mux *gsm) -{ - switch (gsm->state) { - case GSM_SEARCH: - case GSM1_START: - case GSM1_ADDRESS: - case GSM1_CONTROL: - case GSM1_DATA: - case GSM1_OVERRUN: - break; - default: - gsm->state = GSM_SEARCH; - break; - } -} - -/** * gsm1_receive - perform processing for non-transparency * @gsm: gsm data for this ldisc instance * @c: character @@ -3002,7 +2949,6 @@ static void gsm1_receive_state_check_and_fix(struct gsm_mux *gsm) static void gsm1_receive(struct gsm_mux *gsm, u8 c) { - gsm1_receive_state_check_and_fix(gsm); /* handle XON/XOFF */ if ((c & ISO_IEC_646_MASK) == XON) { gsm->constipated = true; @@ -3015,11 +2961,11 @@ static void gsm1_receive(struct gsm_mux *gsm, u8 c) } if (c == GSM1_SOF) { /* EOF is only valid in frame if we have got to the data state */ - if (gsm->state == GSM1_DATA) { + if (gsm->state == GSM_DATA) { if (gsm->count < 1) { /* Missing FSC */ gsm->malformed++; - gsm->state = GSM1_START; + gsm->state = GSM_START; return; } /* Remove the FCS from data */ @@ -3035,14 +2981,14 @@ static void gsm1_receive(struct gsm_mux *gsm, u8 c) gsm->fcs = gsm_fcs_add(gsm->fcs, gsm->buf[gsm->count]); gsm->len = gsm->count; gsm_queue(gsm); - gsm->state = GSM1_START; + gsm->state = GSM_START; return; } /* Any partial frame was a runt so go back to start */ - if (gsm->state != GSM1_START) { + if (gsm->state != GSM_START) { if (gsm->state != GSM_SEARCH) gsm->malformed++; - gsm->state = GSM1_START; + gsm->state = GSM_START; } /* A SOF in GSM_START means we are still reading idling or framing bytes */ @@ -3063,30 +3009,30 @@ static void gsm1_receive(struct gsm_mux *gsm, u8 c) gsm->escape = false; } switch (gsm->state) { - case GSM1_START: /* First byte after SOF */ + case GSM_START: /* First byte after SOF */ gsm->address = 0; - gsm->state = GSM1_ADDRESS; + gsm->state = GSM_ADDRESS; gsm->fcs = INIT_FCS; fallthrough; - case GSM1_ADDRESS: /* Address continuation */ + case GSM_ADDRESS: /* Address continuation */ gsm->fcs = gsm_fcs_add(gsm->fcs, c); if (gsm_read_ea(&gsm->address, c)) - gsm->state = GSM1_CONTROL; + gsm->state = GSM_CONTROL; break; - case GSM1_CONTROL: /* Control Byte */ + case GSM_CONTROL: /* Control Byte */ gsm->fcs = gsm_fcs_add(gsm->fcs, c); gsm->control = c; gsm->count = 0; - gsm->state = GSM1_DATA; + gsm->state = GSM_DATA; break; - case GSM1_DATA: /* Data */ - if (gsm->count > gsm->mru || gsm->count > MAX_MRU) { /* Allow one for the FCS */ - gsm->state = GSM1_OVERRUN; + case GSM_DATA: /* Data */ + if (gsm->count > gsm->mru) { /* Allow one for the FCS */ + gsm->state = GSM_OVERRUN; gsm->bad_size++; } else gsm->buf[gsm->count++] = c; break; - case GSM1_OVERRUN: /* Over-long - eg a dropped SOF */ + case GSM_OVERRUN: /* Over-long - eg a dropped SOF */ break; default: pr_debug("%s: unhandled state: %d\n", __func__, gsm->state); |