Commit 7a80b4b1 authored by Alessandro Rubini's avatar Alessandro Rubini

state-master: unify master and pre-master

This saves 50 bytes in wrpc-sw (and more in x86 builds)
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 8c1dfbcd
...@@ -402,7 +402,7 @@ extern struct pp_state_table_item pp_state_table[]; /* 0-terminated */ ...@@ -402,7 +402,7 @@ extern struct pp_state_table_item pp_state_table[]; /* 0-terminated */
/* Standard state-machine functions */ /* Standard state-machine functions */
extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening, extern pp_action pp_initializing, pp_faulty, pp_disabled, pp_listening,
pp_pre_master, pp_master, pp_passive, pp_uncalibrated, pp_master, pp_passive, pp_uncalibrated,
pp_slave, pp_pclock;; pp_slave, pp_pclock;;
/* The engine */ /* The engine */
......
...@@ -18,7 +18,7 @@ struct pp_state_table_item pp_state_table[] __attribute__((weak)) = { ...@@ -18,7 +18,7 @@ struct pp_state_table_item pp_state_table[] __attribute__((weak)) = {
{ PPS_FAULTY, "faulty", pp_faulty,}, { PPS_FAULTY, "faulty", pp_faulty,},
{ PPS_DISABLED, "disabled", pp_disabled,}, { PPS_DISABLED, "disabled", pp_disabled,},
{ PPS_LISTENING, "listening", pp_listening,}, { PPS_LISTENING, "listening", pp_listening,},
{ PPS_PRE_MASTER, "pre-master", pp_pre_master,}, { PPS_PRE_MASTER, "pre-master", pp_master,},
{ PPS_MASTER, "master", pp_master,}, { PPS_MASTER, "master", pp_master,},
{ PPS_PASSIVE, "passive", pp_passive,}, { PPS_PASSIVE, "passive", pp_passive,},
{ PPS_UNCALIBRATED, "uncalibrated", pp_uncalibrated,}, { PPS_UNCALIBRATED, "uncalibrated", pp_uncalibrated,},
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
/* /*
* MASTER and PRE_MASTER have many things in common. This function implements * MASTER and PRE_MASTER have many things in common. This function implements
* both states. It is invoked by pp_master and pp_pre_master with pre * both states. We set "pre" internally to 0 or 1.
* respectively equal to 0 and 1.
*/ */
static int _pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen, int pre) int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen)
{ {
int msgtype; int msgtype;
int pre = (ppi->state == PPS_MASTER);
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
if (pre && pp_timeout(ppi, PP_TO_QUALIFICATION)) { if (pre && pp_timeout(ppi, PP_TO_QUALIFICATION)) {
...@@ -121,12 +121,3 @@ out_fault: ...@@ -121,12 +121,3 @@ out_fault:
return e; return e;
} }
int pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen)
{
return _pp_master(ppi, pkt, plen, 0);
}
int pp_pre_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
return _pp_master(ppi, pkt, plen, 1);
}
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