Properly fix dbus_read()
Read once, and then get the value that was read in a nop scan. If it didn't work, increase the time and try again. Change-Id: Ic0aaa44f5a858526c4b65d546ab2e7267fd17ef5
This commit is contained in:
parent
bf22cae558
commit
89481491a7
|
@ -455,23 +455,21 @@ static uint64_t dbus_read(struct target *target, uint16_t address)
|
||||||
dbus_status_t status;
|
dbus_status_t status;
|
||||||
uint16_t address_in;
|
uint16_t address_in;
|
||||||
|
|
||||||
// First scan sends the desired address/operation. This is
|
for (unsigned i = 0; i < 256; i++) {
|
||||||
// slightly inefficient as, if the previous read was to the same
|
dbus_scan(target, NULL, NULL, DBUS_OP_READ, address, 0);
|
||||||
// address, one could have simply used the data directly. However,
|
status = dbus_scan(target, &address_in, &value, DBUS_OP_NOP, address, 0);
|
||||||
// that data may may have been captured significantly earlier,
|
|
||||||
// and could be considered stale at the start of this operation.
|
|
||||||
dbus_scan(target, &address_in, &value, DBUS_OP_READ, address, 0);
|
|
||||||
|
|
||||||
unsigned i = 0;
|
|
||||||
do {
|
|
||||||
status = dbus_scan(target, &address_in, &value, DBUS_OP_READ, address, 0);
|
|
||||||
if (status == DBUS_STATUS_BUSY)
|
if (status == DBUS_STATUS_BUSY)
|
||||||
increase_dbus_busy_delay(target);
|
increase_dbus_busy_delay(target);
|
||||||
} while (((status == DBUS_STATUS_BUSY)) &&
|
else if (address_in != address)
|
||||||
i++ < 256);
|
LOG_ERROR("Tried to read from 0x%x, but actually read from 0x%x",
|
||||||
|
address, address_in);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (status != DBUS_STATUS_SUCCESS)
|
if (status != DBUS_STATUS_SUCCESS)
|
||||||
LOG_ERROR("failed read from 0x%x; value=0x%" PRIx64 ", status=%d\n", address, value, status);
|
LOG_ERROR("failed read from 0x%x; value=0x%" PRIx64 ", status=%d",
|
||||||
|
address, value, status);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -486,7 +484,7 @@ static void dbus_write(struct target *target, uint16_t address, uint64_t value)
|
||||||
increase_dbus_busy_delay(target);
|
increase_dbus_busy_delay(target);
|
||||||
}
|
}
|
||||||
if (status != DBUS_STATUS_SUCCESS)
|
if (status != DBUS_STATUS_SUCCESS)
|
||||||
LOG_ERROR("failed to write 0x%" PRIx64 " to 0x%x; status=%d\n", value, address, status);
|
LOG_ERROR("failed to write 0x%" PRIx64 " to 0x%x; status=%d", value, address, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** scans "class" ***/
|
/*** scans "class" ***/
|
||||||
|
|
Loading…
Reference in New Issue