Commit c4e544a9 authored by Alessandro Rubini's avatar Alessandro Rubini

diag: moved diag_fsm into fsm.c

Since diagnostics about the fsm is only used in fsm.c, move it there
so we have less global context and we are all happier.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 1bbeb3a0
......@@ -8,24 +8,6 @@
* This has diagnostics. It calls pp_printf (which one, we don't know)
*/
void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence, int plen)
{
if (sequence == STATE_ENTER) {
/* enter with or without a packet len */
pp_timed_printf(ppi, "fsm: ENTER %s, packet len %i\n",
name, plen);
return;
}
if (sequence == STATE_LOOP) {
pp_timed_printf(ppi, "fsm: %s: reenter in %i ms\n", name,
ppi->next_delay);
return;
}
/* leave has one \n more, so different states are separate */
pp_timed_printf(ppi, "fsm: LEAVE %s (next: %3i in %i ms)\n\n",
name, ppi->next_state, ppi->next_delay);
}
void pp_diag_error(struct pp_instance *ppi, int err)
{
pp_printf("ERR for %p: %i\n", ppi, err);
......
......@@ -6,6 +6,34 @@
unsigned long pp_global_flags; /* This is the only "global" file in ppsi */
/*
* Diagnostics about state machine, enter, leave, remain
*/
enum {
STATE_ENTER,
STATE_LOOP,
STATE_LEAVE
};
static void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence,
int plen)
{
if (sequence == STATE_ENTER) {
/* enter with or without a packet len */
pp_timed_printf(ppi, "fsm: ENTER %s, packet len %i\n",
name, plen);
return;
}
if (sequence == STATE_LOOP) {
pp_timed_printf(ppi, "fsm: %s: reenter in %i ms\n", name,
ppi->next_delay);
return;
}
/* leave has one \n more, so different states are separate */
pp_timed_printf(ppi, "fsm: LEAVE %s (next: %3i in %i ms)\n\n",
name, ppi->next_state, ppi->next_delay);
}
/*
* This is the state machine code. i.e. the extension-independent
* function that runs the machine. Errors are managed and reported
......
......@@ -12,13 +12,6 @@
* strerror(errno) together with the explanation. Avoid diag_printf if
* possible, for size reasons, but here it is anyways.
*/
enum {
STATE_ENTER,
STATE_LOOP,
STATE_LEAVE
};
extern void pp_diag_fsm(struct pp_instance *ppi, char *name, int seq, int plen);
extern void pp_diag_error(struct pp_instance *ppi, int err);
extern void pp_diag_error_str2(struct pp_instance *ppi, char *s1, char *s2);
extern void pp_diag_printf(struct pp_instance *ppi, char *fmt, ...);
......
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