Do-Schleifen ersetzt.
--- a/master/canopen.c Mon Mar 20 12:54:17 2006 +0000
+++ b/master/canopen.c Mon Mar 20 13:36:10 2006 +0000
@@ -194,8 +194,10 @@
start = get_cycles();
timeout = cpu_khz; // 1ms
- do
+ while (1)
{
+ udelay(10);
+
ec_command_init_nprd(&command, slave->station_address, 0x808, 8);
if (unlikely(ec_master_simple_io(master, &command))) {
EC_ERR("Mailbox checking failed on slave %i!\n",
@@ -208,12 +210,12 @@
if (EC_READ_U8(command.data + 5) & 8) { // Written bit is high
break;
}
- }
- while (likely((end - start) < timeout));
-
- if (unlikely((end - start) >= timeout)) {
- EC_ERR("Mailbox check on slave %i timed out.\n", slave->ring_position);
- return -1;
+
+ if (unlikely((end - start) >= timeout)) {
+ EC_ERR("Mailbox check on slave %i timed out.\n",
+ slave->ring_position);
+ return -1;
+ }
}
ec_command_init_nprd(&command, slave->station_address, 0x18F6, 0xF6);
--- a/master/master.c Mon Mar 20 12:54:17 2006 +0000
+++ b/master/master.c Mon Mar 20 13:36:10 2006 +0000
@@ -369,13 +369,15 @@
unsigned int response_tries_left;
response_tries_left = 10;
- do
+
+ while (1)
{
ec_master_queue_command(master, command);
ecrt_master_sync_io(master);
if (command->state == EC_CMD_RECEIVED) {
- break;
+ if (likely(command->working_counter))
+ return 0;
}
else if (command->state == EC_CMD_TIMEOUT) {
EC_ERR("Simple-IO TIMEOUT!\n");
@@ -388,15 +390,12 @@
// Keine direkte Antwort. Dem Slave Zeit lassen...
udelay(10);
- }
- while (unlikely(!command->working_counter && --response_tries_left));
-
- if (unlikely(!response_tries_left)) {
- EC_ERR("No response in simple-IO!\n");
- return -1;
- }
-
- return 0;
+
+ if (unlikely(--response_tries_left)) {
+ EC_ERR("No response in simple-IO!\n");
+ return -1;
+ }
+ }
}
/*****************************************************************************/
@@ -860,7 +859,8 @@
t_start = get_cycles(); // Sendezeit nehmen
t_timeout = master->timeout * cpu_khz / 1000;
- do {
+ while (1)
+ {
ec_device_call_isr(master->device);
t_end = get_cycles(); // Aktuelle Zeit nehmen
@@ -873,7 +873,9 @@
else if (command->state == EC_CMD_SENT)
commands_sent++;
}
- } while (commands_sent);
+
+ if (!commands_sent) break;
+ }
// Zeit abgelaufen. Alle verbleibenden Kommandos entfernen.
list_for_each_entry_safe(command, next, &master->commands, list) {
@@ -983,10 +985,10 @@
t_timeout = master->timeout * cpu_khz / 1000;
// Aktiv warten!
- do {
+ while (1) {
t_end = get_cycles();
- }
- while (t_end - t_start < t_timeout);
+ if (t_end - t_start >= t_timeout) break;
+ }
}
/*****************************************************************************/
--- a/master/slave.c Mon Mar 20 12:54:17 2006 +0000
+++ b/master/slave.c Mon Mar 20 13:36:10 2006 +0000
@@ -152,8 +152,10 @@
start = get_cycles();
timeout = cpu_khz; // 1ms
- do
+ while (1)
{
+ udelay(10);
+
ec_command_init_nprd(&command, slave->station_address, 0x502, 10);
if (unlikely(ec_master_simple_io(slave->master, &command))) {
EC_ERR("Getting SII-read status failed on slave %i!\n",
@@ -165,17 +167,14 @@
if (likely((EC_READ_U8(command.data + 1) & 0x81) == 0)) {
memcpy(target, command.data + 6, 4);
- break;
- }
- }
- while (likely((end - start) < timeout));
-
- if (unlikely((end - start) >= timeout)) {
- EC_ERR("SSI-read. Slave %i timed out!\n", slave->ring_position);
- return -1;
- }
-
- return 0;
+ return 0;
+ }
+
+ if (unlikely((end - start) >= timeout)) {
+ EC_ERR("SSI-read. Slave %i timed out!\n", slave->ring_position);
+ return -1;
+ }
+ }
}
/*****************************************************************************/
@@ -208,8 +207,10 @@
start = get_cycles();
timeout = cpu_khz; // 1ms
- do
+ while (1)
{
+ udelay(100); // Dem Slave etwas Zeit lassen...
+
ec_command_init_nprd(&command, slave->station_address, 0x0130, 2);
if (unlikely(ec_master_simple_io(slave->master, &command))) {
EC_WARN("State %02X acknowledge checking failed on slave %i!\n",
@@ -231,13 +232,12 @@
slave->ring_position);
return;
}
- }
- while (likely((end - start) < timeout));
-
- if (unlikely((end - start) >= timeout)) {
- EC_WARN("Could not check state acknowledgement %02X of slave %i -"
- " Timeout while checking!\n", state, slave->ring_position);
- return;
+
+ if (unlikely((end - start) >= timeout)) {
+ EC_WARN("Could not check state acknowledgement %02X of slave %i -"
+ " Timeout while checking!\n", state, slave->ring_position);
+ return;
+ }
}
}
@@ -271,7 +271,7 @@
start = get_cycles();
timeout = cpu_khz; // 1ms
- do
+ while (1)
{
udelay(100); // Dem Slave etwas Zeit lassen...
@@ -294,18 +294,15 @@
if (likely(EC_READ_U8(command.data) == (state & 0x0F))) {
// State change successful
- break;
- }
- }
- while (likely((end - start) < timeout));
-
- if (unlikely((end - start) >= timeout)) {
- EC_ERR("Could not check state %02X of slave %i - Timeout!\n", state,
- slave->ring_position);
- return -1;
- }
-
- return 0;
+ return 0;
+ }
+
+ if (unlikely((end - start) >= timeout)) {
+ EC_ERR("Could not check state %02X of slave %i - Timeout!\n",
+ state, slave->ring_position);
+ return -1;
+ }
+ }
}
/*****************************************************************************/