Commit 329aa6e6 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

n_gsm: introduce enum gsm_mux_state

gsm_mux->state is clearly an enumeration. So introduce one and use it
-- compiler now checks if valid values are assigned to the field.

Note that a compiler warns about unhandled cases in switch. Add default
cases with a pr_debug (which is not printed by default).

The values of the states are preserved thanks to the nature of enum.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200219084949.28074-4-jslaby@suse.czSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e1785996
...@@ -173,6 +173,20 @@ struct gsm_control { ...@@ -173,6 +173,20 @@ struct gsm_control {
int error; /* Error if any */ int error; /* Error if any */
}; };
enum gsm_mux_state {
GSM_SEARCH,
GSM_START,
GSM_ADDRESS,
GSM_CONTROL,
GSM_LEN,
GSM_DATA,
GSM_FCS,
GSM_OVERRUN,
GSM_LEN0,
GSM_LEN1,
GSM_SSOF,
};
/* /*
* Each GSM mux we have is represented by this structure. If we are * Each GSM mux we have is represented by this structure. If we are
* operating as an ldisc then we use this structure as our ldisc * operating as an ldisc then we use this structure as our ldisc
...@@ -197,18 +211,7 @@ struct gsm_mux { ...@@ -197,18 +211,7 @@ struct gsm_mux {
/* Framing Layer */ /* Framing Layer */
unsigned char *buf; unsigned char *buf;
int state; enum gsm_mux_state state;
#define GSM_SEARCH 0
#define GSM_START 1
#define GSM_ADDRESS 2
#define GSM_CONTROL 3
#define GSM_LEN 4
#define GSM_DATA 5
#define GSM_FCS 6
#define GSM_OVERRUN 7
#define GSM_LEN0 8
#define GSM_LEN1 9
#define GSM_SSOF 10
unsigned int len; unsigned int len;
unsigned int address; unsigned int address;
unsigned int count; unsigned int count;
...@@ -1934,6 +1937,9 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c) ...@@ -1934,6 +1937,9 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
break; break;
} }
break; break;
default:
pr_debug("%s: unhandled state: %d\n", __func__, gsm->state);
break;
} }
} }
...@@ -2008,6 +2014,9 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c) ...@@ -2008,6 +2014,9 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
break; break;
case GSM_OVERRUN: /* Over-long - eg a dropped SOF */ case GSM_OVERRUN: /* Over-long - eg a dropped SOF */
break; break;
default:
pr_debug("%s: unhandled state: %d\n", __func__, gsm->state);
break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment