Clear slave list on link down.
authorFlorian Pose <fp@igh-essen.com>
Fri, 17 Apr 2009 12:41:57 +0000
changeset 1400 3c4923051e43
parent 1399 f79d4bb5b23a
child 1401 96baef8a3162
Clear slave list on link down.
NEWS
TODO
master/fsm_master.c
master/fsm_master.h
--- a/NEWS	Fri Apr 17 12:03:12 2009 +0000
+++ b/NEWS	Fri Apr 17 12:41:57 2009 +0000
@@ -32,6 +32,7 @@
 * Added 64-bit data access macros to application header.
 * Added debug level for all masters as a module parameter. Thanks to Erwin
   Burgstaller.
+* Clear slave list on link down.
 
 Changes in 1.4.0:
 
--- a/TODO	Fri Apr 17 12:03:12 2009 +0000
+++ b/TODO	Fri Apr 17 12:41:57 2009 +0000
@@ -19,7 +19,6 @@
 * Re-work EoE code.
 * Replace locking callbacks.
 * Implement EoE callbacks for library.
-* Clear slave list on link down.
 * Rescan command.
 * Override sync manager size?
 * Remove ecrt_domain_state()?
--- a/master/fsm_master.c	Fri Apr 17 12:03:12 2009 +0000
+++ b/master/fsm_master.c	Fri Apr 17 12:41:57 2009 +0000
@@ -73,6 +73,7 @@
     fsm->datagram = datagram;
     fsm->state = ec_fsm_master_state_start;
     fsm->idle = 0;
+    fsm->link_state = 0;
     fsm->slaves_responding = 0;
     fsm->topology_change_pending = 0;
     fsm->slave_states = EC_SLAVE_STATE_UNKNOWN;
@@ -194,6 +195,16 @@
         EC_INFO("%u slave(s) responding.\n", fsm->slaves_responding);
     }
 
+    if (fsm->link_state && !master->main_device.link_state) { // link went down
+        // clear slave list
+#ifdef EC_EOE
+        ec_master_eoe_stop(master);
+        ec_master_clear_eoe_handlers(master);
+#endif
+        ec_master_clear_slaves(master);
+    }
+    fsm->link_state = master->main_device.link_state;
+
     if (datagram->state != EC_DATAGRAM_RECEIVED) { // link is down
         ec_fsm_master_restart(fsm);
         return;
--- a/master/fsm_master.h	Fri Apr 17 12:03:12 2009 +0000
+++ b/master/fsm_master.h	Fri Apr 17 12:41:57 2009 +0000
@@ -107,6 +107,7 @@
     void (*state)(ec_fsm_master_t *); /**< master state function */
     int idle; /**< state machine is in idle phase */
     unsigned long scan_jiffies; /**< beginning of slave scanning */
+    uint8_t link_state; /**< Last main device link state. */
     unsigned int slaves_responding; /**< number of responding slaves */
     unsigned int topology_change_pending; /**< bus topology changed */
     ec_slave_state_t slave_states; /**< states of responding slaves */