From 3b1c0a1397e4b1f23f4ee35e48eee8e291dd035e Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Fri, 12 May 2006 12:40:45 +0000
Subject: [PATCH] No master locking, if no EoE devices are "up".

---
 master/ethernet.c | 12 ++++++++++++
 master/ethernet.h |  3 ++-
 master/master.c   |  7 ++++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/master/ethernet.c b/master/ethernet.c
index ae87f417..61ffd2d5 100644
--- a/master/ethernet.c
+++ b/master/ethernet.c
@@ -262,6 +262,18 @@ void ec_eoe_run(ec_eoe_t *eoe /**< EoE object */)
 
 /*****************************************************************************/
 
+/**
+   Returns the state of the device.
+   \return 1 if the device is "up", 0 if it is "down"
+*/
+
+unsigned int ec_eoe_active(const ec_eoe_t *eoe /**< EoE object */)
+{
+    return eoe->opened;
+}
+
+/*****************************************************************************/
+
 /**
    Prints EoE object information.
 */
diff --git a/master/ethernet.h b/master/ethernet.h
index 9521954f..cbc341a0 100644
--- a/master/ethernet.h
+++ b/master/ethernet.h
@@ -66,7 +66,7 @@ struct ec_eoe
     void (*state)(ec_eoe_t *); /**< state function for the state machine */
     struct net_device *dev; /**< net_device for virtual ethernet device */
     struct net_device_stats stats; /**< device statistics */
-    uint8_t opened; /**< net_device is opened */
+    unsigned int opened; /**< net_device is opened */
     struct sk_buff *rx_skb; /**< current rx socket buffer */
     off_t rx_skb_offset; /**< current write pointer in the socket buffer */
     size_t rx_skb_size; /**< size of the allocated socket buffer memory */
@@ -86,6 +86,7 @@ struct ec_eoe
 int ec_eoe_init(ec_eoe_t *, ec_slave_t *);
 void ec_eoe_clear(ec_eoe_t *);
 void ec_eoe_run(ec_eoe_t *);
+unsigned int ec_eoe_active(const ec_eoe_t *);
 void ec_eoe_print(const ec_eoe_t *);
 
 /*****************************************************************************/
diff --git a/master/master.c b/master/master.c
index c8dd9c8c..d7dd72aa 100644
--- a/master/master.c
+++ b/master/master.c
@@ -874,9 +874,14 @@ void ec_master_run_eoe(void *data /**< master pointer */)
 {
     ec_master_t *master = (ec_master_t *) data;
     ec_eoe_t *eoe;
+    unsigned int active = 0;
+
+    list_for_each_entry(eoe, &master->eoe_slaves, list) {
+        if (ec_eoe_active(eoe)) active++;
+    }
 
     // request_cb must return 0, if the lock has been aquired!
-    if (!master->request_cb(master->cb_data))
+    if (active && !master->request_cb(master->cb_data))
     {
         ecrt_master_async_receive(master);
         list_for_each_entry(eoe, &master->eoe_slaves, list) {
-- 
GitLab