summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2023-02-28 18:33:21 +0800
committerDavid Gibson <david@gibson.dropbear.id.au>2023-03-01 16:08:28 +1100
commit9cceabea1ee09ae0864d365b7b3cc89a01b1287c (patch)
treef997044835a1b199fa05a0b654452b196a8dd5d6
parent0d56145938fe5299c7a4fe0342fe8ba80698d564 (diff)
downloaddevice-tree-compiler-9cceabea1ee09ae0864d365b7b3cc89a01b1287c.tar.gz
checks: correct I2C 10-bit address check
Currently if there is a valid 10-bit address the following warning is always displayed due to the 7-bit check failing due to reg > 0x7f "I2C address must be less than 7-bits, got "0x800000a6". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property" Fix this issue by checking if a 10-bit address is expected, and is valid in separate if statements. Fixes: 8259d59f ("checks: Improve i2c reg property checking") Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--checks.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/checks.c b/checks.c
index 21e7b62..16bc7f6 100644
--- a/checks.c
+++ b/checks.c
@@ -1079,10 +1079,11 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
/* Ignore I2C_OWN_SLAVE_ADDRESS */
reg &= ~I2C_OWN_SLAVE_ADDRESS;
- if ((reg & I2C_TEN_BIT_ADDRESS) && ((reg & ~I2C_TEN_BIT_ADDRESS) > 0x3ff))
- FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
+ if (reg & I2C_TEN_BIT_ADDRESS) {
+ if ((reg & ~I2C_TEN_BIT_ADDRESS) > 0x3ff)
+ FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
reg);
- else if (reg > 0x7f)
+ } else if (reg > 0x7f)
FAIL_PROP(c, dti, node, prop, "I2C address must be less than 7-bits, got \"0x%x\". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property",
reg);
}