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]>
---
 port.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/port.c b/port.c
index 02dbabb..ebe7342 100644
--- a/port.c
+++ b/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)
 {
        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
-- 
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to