hdata/i2c: Work around broken I2C array version

Submitted by Oliver O'Halloran on Aug. 2, 2017, 12:58 p.m.

Details

Message ID 20170802125846.2661-1-oohall@gmail.com
State Accepted
Headers show

Commit Message

Oliver O'Halloran Aug. 2, 2017, 12:58 p.m.
Work around a bug in the I2C devices array that shows the
array version as being v2 when only the v1 data is populated.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hdata/i2c.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Stewart Smith Aug. 15, 2017, 12:55 a.m.
Oliver O'Halloran <oohall@gmail.com> writes:
> Work around a bug in the I2C devices array that shows the
> array version as being v2 when only the v1 data is populated.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>

Thanks, merged to master as of 0818df625e3539a6aaad025ee6f1d1a441dee4a5

I made one change, and enforced the "parsing as v1" for v2 only, just in
case this caused some future issue..

Arguably we should make HB do a V3 for filling out the info they said
would be in V2 but isn't :/

Patch hide | download patch | download mbox

diff --git a/hdata/i2c.c b/hdata/i2c.c
index 1c26e2ea9df0..8dcbf4b2d628 100644
--- a/hdata/i2c.c
+++ b/hdata/i2c.c
@@ -193,10 +193,9 @@  int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 		version = be32_to_cpu(ahdr->version);
 	}
 
-	if (version != 1) {
-		prerror("I2C: HDAT version %d not supported! THIS IS A BUG\n",
+	if (version > 1) {
+		prerror("I2C: v%d found, but not supported. Parsing as v1\n",
 			version);
-		return -1;
 	}
 
 	count = HDIF_get_iarray_size(hdr, idata_index);
@@ -237,6 +236,9 @@  int parse_i2c_devs(const struct HDIF_common_hdr *hdr, int idata_index,
 		}
 
 		node = dt_new_addr(bus, name, i2c_addr);
+		if (!node)
+			continue;
+
 		dt_add_property_cells(node, "reg", i2c_addr);
 		dt_add_property_cells(node, "link-id",
 			be32_to_cpu(dev->i2c_link));