hdata/i2c: log unknown i2c devices

Message ID 1507784636-31883-1-git-send-email-cclaudio@linux.vnet.ibm.com
State Accepted
Headers show
Series
  • hdata/i2c: log unknown i2c devices
Related show

Commit Message

Claudio Carvalho Oct. 12, 2017, 5:03 a.m.
An i2c device is unknown if either the i2c device list is outdated or
the device is marked as unknown (0xFF) in the hdat.

This log both cases.

Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com>
Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 hdata/i2c.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Comments

Stewart Smith Oct. 16, 2017, 8:13 a.m. | #1
Claudio Carvalho <cclaudio@linux.vnet.ibm.com> writes:
> An i2c device is unknown if either the i2c device list is outdated or
> the device is marked as unknown (0xFF) in the hdat.
>
> This log both cases.
>
> Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com>
> Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
> ---
>  hdata/i2c.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)

Merged to master as of b307a54d9672d779c31a82dd045587300a0eeedc

Patch

diff --git a/hdata/i2c.c b/hdata/i2c.c
index 2e14212..9fb8513 100644
--- a/hdata/i2c.c
+++ b/hdata/i2c.c
@@ -165,6 +165,7 @@  int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 	uint32_t i2c_addr;
 	uint32_t version;
 	uint32_t size;
+	uint32_t purpose;
 	int i, count;
 
 	/*
@@ -226,11 +227,9 @@  int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 		 */
 		i2c_addr = dev->i2c_addr >> 1;
 
-		prlog(PR_TRACE, "HDAT I2C: found e%dp%d - %x\n",
-			dev->i2cm_engine, dev->i2cm_port, i2c_addr);
-
+		purpose = be32_to_cpu(dev->purpose);
 		type = map_type(dev->type);
-		label = map_label(be32_to_cpu(dev->purpose));
+		label = map_label(purpose);
 		if (type) {
 			compat = type->compat;
 			name = type->name;
@@ -239,6 +238,20 @@  int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 			compat = NULL;
 		}
 
+		/*
+		 * An i2c device is unknown if either the i2c device list is
+		 * outdated or the device is marked as unknown (0xFF) in the
+		 * hdat. Log both cases to see what/where/why.
+		 */
+		if (!type || dev->type == 0xFF)
+			prlog(PR_WARNING, "HDAT I2C: found e%dp%d - %s@%x (%#x:%s)\n",
+			      dev->i2cm_engine, dev->i2cm_port, name, i2c_addr,
+			      purpose, label);
+		else
+			prlog(PR_TRACE, "HDAT I2C: found e%dp%d - %s@%x (%#x:%s)\n",
+			      dev->i2cm_engine, dev->i2cm_port, name, i2c_addr,
+			      purpose, label);
+
 		node = dt_new_addr(bus, name, i2c_addr);
 		if (!node)
 			continue;