Disentangle initialization from fault clearing.
Although leaving the INITIALIZING state and clearing the FAULTY state ASAP both result in a port entering the LISTENING state, still there is no benefit from conflating the two. In the FAULTY case, the current code actually skips the INITIALIZING state altogether. This patch separates the two cases resulting in two benefits. First, the check for ASAP fault status is only made when a fault is actually present, unlike the present unconditional check. Second, this change will allow us to cleanly support alternative state machines later on. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
1f66948d38
commit
01ee947457
10
port.c
10
port.c
|
@ -2145,8 +2145,6 @@ static void port_p2p_transition(struct port *p, enum port_state next)
|
||||||
int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
|
int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
|
||||||
{
|
{
|
||||||
enum port_state next;
|
enum port_state next;
|
||||||
struct fault_interval i;
|
|
||||||
int fri_asap = 0;
|
|
||||||
|
|
||||||
if (clock_slave_only(p->clock)) {
|
if (clock_slave_only(p->clock)) {
|
||||||
if (event == EV_RS_MASTER || event == EV_RS_GRAND_MASTER) {
|
if (event == EV_RS_MASTER || event == EV_RS_GRAND_MASTER) {
|
||||||
|
@ -2155,11 +2153,15 @@ int port_dispatch(struct port *p, enum fsm_event event, int mdiff)
|
||||||
}
|
}
|
||||||
next = p->state_machine(p->state, event, mdiff);
|
next = p->state_machine(p->state, event, mdiff);
|
||||||
|
|
||||||
|
if (PS_FAULTY == next) {
|
||||||
|
struct fault_interval i;
|
||||||
fault_interval(p, last_fault_type(p), &i);
|
fault_interval(p, last_fault_type(p), &i);
|
||||||
if (clear_fault_asap(&i)) {
|
if (clear_fault_asap(&i)) {
|
||||||
fri_asap = 1;
|
pr_notice("port %hu: clearing fault immediately", portnum(p));
|
||||||
|
next = PS_INITIALIZING;
|
||||||
}
|
}
|
||||||
if (PS_INITIALIZING == next || (PS_FAULTY == next && fri_asap)) {
|
}
|
||||||
|
if (PS_INITIALIZING == next) {
|
||||||
/*
|
/*
|
||||||
* This is a special case. Since we initialize the
|
* This is a special case. Since we initialize the
|
||||||
* port immediately, we can skip right to listening
|
* port immediately, we can skip right to listening
|
||||||
|
|
Loading…
Reference in New Issue