Skip to content

Commit

Permalink
Disentangle initialization from fault clearing.
Browse files Browse the repository at this point in the history
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 <[email protected]>
richardcochran committed Jan 8, 2017
1 parent 1f66948 commit 01ee947
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions port.c
Original file line number Diff line number Diff line change
@@ -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)
{
enum port_state next;
struct fault_interval i;
int fri_asap = 0;

if (clock_slave_only(p->clock)) {
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);

fault_interval(p, last_fault_type(p), &i);
if (clear_fault_asap(&i)) {
fri_asap = 1;
if (PS_FAULTY == next) {
struct fault_interval i;
fault_interval(p, last_fault_type(p), &i);
if (clear_fault_asap(&i)) {
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
* port immediately, we can skip right to listening

0 comments on commit 01ee947

Please sign in to comment.