hps: dev.cc: Do not cout 8 bit types
Change the vlog code to use stringprintf. Do not send 8 bit types to log
functions as they are printed as characters not digits. Print the
registers as hex values.
BUG=b:196129231
TEST=hps --v=2 cmd launch
Change-Id: I6828b6aa5d310be3a4e86ae7208bd75b50b155af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/3255086
Tested-by: Evan Benn <[email protected]>
Commit-Queue: Evan Benn <[email protected]>
Reviewed-by: Stuart Langley <[email protected]>
diff --git a/hps/dev.cc b/hps/dev.cc
index f7536cd..1283ab8 100644
--- a/hps/dev.cc
+++ b/hps/dev.cc
@@ -9,6 +9,7 @@
#include "hps/dev.h"
#include "base/logging.h"
+#include <base/strings/stringprintf.h>
#include "hps/hps_reg.h"
#include "hps/utils.h"
@@ -16,19 +17,19 @@
bool DevInterface::Read(uint8_t cmd, uint8_t* data, size_t len) {
if (this->ReadDevice(cmd, data, len)) {
- VLOG(2) << "Read: " << cmd << " " << len << " OK";
+ VLOG(2) << base::StringPrintf("Read: cmd: 0x%x len: %zd OK", cmd, len);
return true;
}
- VLOG(2) << "Read: " << cmd << " " << len << " FAILED";
+ VLOG(2) << base::StringPrintf("Read: cmd: 0x%x len: %zd FAILED", cmd, len);
return false;
}
bool DevInterface::Write(uint8_t cmd, const uint8_t* data, size_t len) {
if (this->WriteDevice(cmd, data, len)) {
- VLOG(2) << "Write: " << cmd << " " << len << " OK";
+ VLOG(2) << base::StringPrintf("Write: cmd: 0x%x len: %zd OK", cmd, len);
return true;
}
- VLOG(2) << "Write: " << cmd << " " << len << " FAILED";
+ VLOG(2) << base::StringPrintf("Write: cmd: 0x%x len: %zd FAILED", cmd, len);
return false;
}
@@ -44,7 +45,8 @@
for (int i = 0; i < 2; i++) {
if (this->ReadDevice(I2cReg(r), res, sizeof(res))) {
int ret = (static_cast<int>(res[0]) << 8) | static_cast<int>(res[1]);
- VLOG(2) << "ReadReg: " << HpsRegToString(r) << " " << ret << " OK";
+ VLOG(2) << base::StringPrintf("ReadReg: %s : 0x%.4x OK",
+ HpsRegToString(r), ret);
return ret;
}
}
@@ -63,10 +65,12 @@
buf[1] = data & 0xFF;
if (this->WriteDevice(I2cReg(r), buf, sizeof(buf))) {
- VLOG(2) << "WriteReg: " << HpsRegToString(r) << " " << data << " OK";
+ VLOG(2) << base::StringPrintf("WriteReg: %s : 0x%.4x OK", HpsRegToString(r),
+ data);
return true;
} else {
- VLOG(2) << "WriteReg: " << HpsRegToString(r) << " " << data << " FAILED";
+ VLOG(2) << base::StringPrintf("WriteReg: %s : 0x%.4x FAILED",
+ HpsRegToString(r), data);
return false;
}
}