aboutsummaryrefslogtreecommitdiff
path: root/rmi4update/rmi4update.cpp
diff options
context:
space:
mode:
authorAndrew Duggan <aduggan@synaptics.com>2014-05-06 16:06:19 -0700
committerAndrew Duggan <aduggan@synaptics.com>2014-05-06 16:09:35 -0700
commit621379159b3f9e095fdf8076330a33b55809a517 (patch)
tree77e8121c052d0e88afe64c9d196fe7357db240f4 /rmi4update/rmi4update.cpp
parentfc17a65f3c9c3db99ab5c962bf55d109e485f9b5 (diff)
downloadrmi4utils-621379159b3f9e095fdf8076330a33b55809a517.tar.gz
Keep going if attention times out, but print a message so that attn reports can be fixed otherwise it will be really slow. But, this will only happen if something is broken in the driver.
Diffstat (limited to 'rmi4update/rmi4update.cpp')
-rw-r--r--rmi4update/rmi4update.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/rmi4update/rmi4update.cpp b/rmi4update/rmi4update.cpp
index f46a09a..afcdf97 100644
--- a/rmi4update/rmi4update.cpp
+++ b/rmi4update/rmi4update.cpp
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include "rmi4update.h"
@@ -301,7 +302,7 @@ int RMI4Update::EnterFlashProgramming()
if (!m_programEnabled)
return UPDATE_FAIL_PROGRAMMING_NOT_ENABLED;
- fprintf(stdout, "HOORAY! Programming is enabled!\n");
+ fprintf(stdout, "Programming is enabled.\n");
rc = FindUpdateFunctions();
if (rc != UPDATE_SUCCESS)
return rc;
@@ -382,28 +383,34 @@ int RMI4Update::WaitForIdle(int timeout_ms)
tv.tv_usec = (timeout_ms % 1000) * 1000;
rc = m_device.WaitForAttention(&tv);
- if (rc > 0) {
- rc = ReadF34Controls();
- if (rc != UPDATE_SUCCESS)
- return rc;
+ if (rc == -ETIMEDOUT)
+ /*
+ * If for some reason we are not getting attention reports for HID devices
+ * then we can still continue after the timeout and read F34 status
+ * but if we have to wait for the timeout to ellapse everytime then this
+ * will be slow. If this message shows up a lot then something is wrong
+ * with receiving attention reports and that should be fixed.
+ */
+ fprintf(stderr, "Timed out waiting for attn report\n");
+
+ rc = ReadF34Controls();
+ if (rc != UPDATE_SUCCESS)
+ return rc;
- if (!m_f34Status && !m_f34Command) {
- if (!m_programEnabled) {
- fprintf(stderr, "Bootloader is idle but program_enabled bit isn't set.\n");
- return UPDATE_FAIL_PROGRAMMING_NOT_ENABLED;
- } else {
- return UPDATE_SUCCESS;
- }
+ if (!m_f34Status && !m_f34Command) {
+ if (!m_programEnabled) {
+ fprintf(stderr, "Bootloader is idle but program_enabled bit isn't set.\n");
+ return UPDATE_FAIL_PROGRAMMING_NOT_ENABLED;
+ } else {
+ return UPDATE_SUCCESS;
}
+ }
- fprintf(stderr, "ERROR: Waiting for idle status.\n");
- fprintf(stderr, "Command: %#04x\n", m_f34Command);
- fprintf(stderr, "Status: %#04x\n", m_f34Status);
- fprintf(stderr, "Enabled: %d\n", m_programEnabled);
- fprintf(stderr, "Idle: %d\n", !m_f34Command && !m_f34Status);
+ fprintf(stderr, "ERROR: Waiting for idle status.\n");
+ fprintf(stderr, "Command: %#04x\n", m_f34Command);
+ fprintf(stderr, "Status: %#04x\n", m_f34Status);
+ fprintf(stderr, "Enabled: %d\n", m_programEnabled);
+ fprintf(stderr, "Idle: %d\n", !m_f34Command && !m_f34Status);
- return UPDATE_FAIL_NOT_IN_IDLE_STATE;
- }
-
- return UPDATE_FAIL_TIMEOUT;
+ return UPDATE_FAIL_NOT_IN_IDLE_STATE;
} \ No newline at end of file