diff mbox series

[1/3] hw/p8-i2c: Don't print warnings when dumping registers

Message ID 20191203054619.20068-1-oohall@gmail.com
State Accepted
Headers show
Series [1/3] hw/p8-i2c: Don't print warnings when dumping registers | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (d75e82dbfbb9443efeb3f9a5921ac23605aab469)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Oliver O'Halloran Dec. 3, 2019, 5:46 a.m. UTC
There's not much point complaining if we can't collect debug data. Log a
obviously-wrong value and continue. Also convert to using
i2cm_read_reg() rather than xscom_read() directly while we're here.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hw/p8-i2c.c | 52 ++++++++++------------------------------------------
 1 file changed, 10 insertions(+), 42 deletions(-)

Comments

Oliver O'Halloran Dec. 16, 2019, 3:54 a.m. UTC | #1
On Tue, Dec 3, 2019 at 4:46 PM Oliver O'Halloran <oohall@gmail.com> wrote:
>
> There's not much point complaining if we can't collect debug data. Log a
> obviously-wrong value and continue. Also convert to using
> i2cm_read_reg() rather than xscom_read() directly while we're here.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Series merged as 8b3012e1aa670af09ddd2d378978b3862314c36d
diff mbox series

Patch

diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index 1b2806208613..990dfca7a154 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -237,7 +237,6 @@  static void p8_i2c_print_debug_info(struct p8_i2c_master_port *port,
 {
 	struct p8_i2c_master *master = port->master;
 	uint64_t cmd, mode, stat, estat, intm, intc;
-	int rc;
 
 	/* Print master and request structure bits */
 	log_simple_error(&e_info(OPAL_RC_I2C_TRANSFER),
@@ -255,48 +254,17 @@  static void p8_i2c_print_debug_info(struct p8_i2c_master_port *port,
 			 " start_time=%016llx end_time=%016llx (duration=%016llx)\n",
 			 master->start_time, end_time, end_time - master->start_time);
 
-	/* Dump the current state of i2c registers */
-	rc = xscom_read(master->chip_id, master->xscom_base + I2C_CMD_REG,
-			&cmd);
-	if (rc) {
-		prlog(PR_DEBUG, "I2C: Failed to read CMD_REG\n");
-		cmd = 0ull;
-	}
-
-	rc = xscom_read(master->chip_id, master->xscom_base + I2C_MODE_REG,
-			&mode);
-	if (rc) {
-		prlog(PR_DEBUG, "I2C: Failed to read MODE_REG\n");
-		mode = 0ull;
-	}
-
-	rc = xscom_read(master->chip_id, master->xscom_base + I2C_STAT_REG,
-			&stat);
-	if (rc) {
-		prlog(PR_DEBUG, "I2C: Failed to read STAT_REG\n");
-		stat = 0ull;
-	}
+	/* initialise to some fake value in case of read errors */
+	cmd = mode = stat = estat = intm = intc = 0xDEAD;
 
-	rc = xscom_read(master->chip_id, master->xscom_base + I2C_EXTD_STAT_REG,
-			&estat);
-	if (rc) {
-		prlog(PR_DEBUG, "I2C: Failed to read EXTD_STAT_REG\n");
-		estat = 0ull;
-	}
-
-	rc = xscom_read(master->chip_id, master->xscom_base + I2C_INTR_MASK_REG,
-			&intm);
-	if (rc) {
-		prlog(PR_DEBUG, "I2C: Failed to read INTR_MASK_REG\n");
-		intm = 0ull;
-	}
-
-	rc = xscom_read(master->chip_id, master->xscom_base + I2C_INTR_COND_REG,
-			&intc);
-	if (rc) {
-		prlog(PR_DEBUG, "I2C: Failed to read INTR_COND_REG\n");
-		intc = 0ull;
-	}
+	/* Dump the current state of i2c registers */
+	i2cm_read_reg(master, I2C_CMD_REG, &cmd);
+	i2cm_read_reg(master, I2C_MODE_REG, &mode);
+	i2cm_read_reg(master, I2C_MODE_REG, &mode);
+	i2cm_read_reg(master, I2C_STAT_REG, &stat);
+	i2cm_read_reg(master, I2C_EXTD_STAT_REG, &estat);
+	i2cm_read_reg(master, I2C_INTR_MASK_REG, &intm);
+	i2cm_read_reg(master, I2C_INTR_COND_REG, &intc);
 
 	log_simple_error(&e_info(OPAL_RC_I2C_TRANSFER), "I2C: Register dump--\n"
 			 "    cmd:0x%016llx\tmode:0x%016llx\tstat:0x%016llx\n"