Fixed ecrt_domain_process() broken in 71d38ff288b3. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Wed, 05 Dec 2012 11:32:45 +0100
branchstable-1.5
changeset 2470 4f97d61a8671
parent 2469 634ba3b1eb95
child 2471 fc64a4b1ec1a
Fixed ecrt_domain_process() broken in 71d38ff288b3.
master/domain.c
--- a/master/domain.c	Wed Dec 05 11:28:29 2012 +0100
+++ b/master/domain.c	Wed Dec 05 11:32:45 2012 +0100
@@ -451,26 +451,34 @@
 
 void ecrt_domain_process(ec_domain_t *domain)
 {
-    uint16_t wc_sum[EC_MAX_NUM_DEVICES] = {}, redundant_wc, wc_total;
+    uint16_t wc_sum[EC_MAX_NUM_DEVICES] = {}, wc_total;
+    ec_datagram_pair_t *pair;
+#if EC_MAX_NUM_DEVICES > 1
+    uint16_t datagram_pair_wc, redundant_wc;
+    unsigned int datagram_offset;
+    ec_fmmu_config_t *fmmu = list_first_entry(&domain->fmmu_configs,
+            ec_fmmu_config_t, list);
+    unsigned int redundancy;
+#endif
     unsigned int dev_idx, wc_change;
-    unsigned int redundancy;
 
 #if DEBUG_REDUNDANCY
     EC_MASTER_DBG(domain->master, 1, "domain %u process\n", domain->index);
 #endif
 
+    list_for_each_entry(pair, &domain->datagram_pairs, list) {
 #if EC_MAX_NUM_DEVICES > 1
-    if (ec_master_num_devices(domain->master) > 1) {
-        ec_datagram_pair_t *pair;
-        ec_fmmu_config_t *fmmu =
-            list_first_entry(&domain->fmmu_configs, ec_fmmu_config_t, list);
-
-        list_for_each_entry(pair, &domain->datagram_pairs, list) {
+        datagram_pair_wc = ec_datagram_pair_process(pair, wc_sum);
+#else
+        ec_datagram_pair_process(pair, wc_sum);
+#endif
+
+#if EC_MAX_NUM_DEVICES > 1
+        if (ec_master_num_devices(domain->master) > 1) {
             ec_datagram_t *main_datagram = &pair->datagrams[EC_DEVICE_MAIN];
             uint32_t logical_datagram_address =
                 EC_READ_U32(main_datagram->address);
             size_t datagram_size = main_datagram->data_size;
-            uint16_t datagram_pair_wc;
 
 #if DEBUG_REDUNDANCY
             EC_MASTER_DBG(domain->master, 1, "dgram %s log=%u\n",
@@ -479,7 +487,6 @@
 
             /* Redundancy: Go through FMMU configs to detect data changes. */
             list_for_each_entry_from(fmmu, &domain->fmmu_configs, list) {
-                unsigned int datagram_offset;
                 ec_datagram_t *backup_datagram =
                     &pair->datagrams[EC_DEVICE_BACKUP];
 
@@ -510,7 +517,6 @@
                             fmmu->data_size);
                 }
 #endif
-                datagram_pair_wc = ec_datagram_pair_process(pair, wc_sum);
 
                 if (data_changed(pair->send_buffer, main_datagram,
                             datagram_offset, fmmu->data_size)) {
@@ -545,9 +551,10 @@
                 }
             }
         }
-    }
 #endif // EC_MAX_NUM_DEVICES > 1
-
+    }
+
+#if EC_MAX_NUM_DEVICES > 1
     redundant_wc = 0;
     for (dev_idx = EC_DEVICE_BACKUP;
             dev_idx < ec_master_num_devices(domain->master); dev_idx++) {
@@ -567,6 +574,9 @@
         }
         domain->redundancy_active = redundancy;
     }
+#else
+    domain->redundancy_active = 0;
+#endif
 
     wc_change = 0;
     wc_total = 0;
@@ -596,6 +606,7 @@
                     domain->working_counter_changes,
                     wc_total, domain->expected_working_counter);
         }
+#if EC_MAX_NUM_DEVICES > 1
         if (ec_master_num_devices(domain->master) > 1) {
             printk(" (");
             for (dev_idx = EC_DEVICE_MAIN;
@@ -608,6 +619,7 @@
             }
             printk(")");
         }
+#endif
         printk(".\n");
 
         domain->working_counter_changes = 0;