All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] checks: mask flags bit when check i2c addr
@ 2020-03-26  5:43 Rayagonda Kokatanur
  0 siblings, 0 replies; only message in thread
From: Rayagonda Kokatanur @ 2020-03-26  5:43 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, devicetree, linux-kernel,
	bcm-kernel-feedback-list
  Cc: Rayagonda Kokatanur

Generally i2c addr should not be greater than 10-bit.
The highest bytes are used for other purpose, for ex 2 bits
are used for I2C_TEN_BIT_ADDRESS and I2C_OWN_SLAVE_ADDRESS.
Hence mask upper bytes if check slave addr valid.

Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
---
 checks.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/checks.c b/checks.c
index 8acbc05..5c7f2b1 100644
--- a/checks.c
+++ b/checks.c
@@ -1051,6 +1051,12 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
 
 	for (len = prop->val.len; len > 0; len -= 4) {
 		reg = fdt32_to_cpu(*(cells++));
+		/*
+		 * The highest bytes are used for other purpose, for ex 2 bits
+		 * are used for I2C_TEN_BIT_ADDRESS and I2C_OWN_SLAVE_ADDRESS.
+		 * Hence mask upper bytes if check slave addr valid.
+		 */
+		reg &= ~0xFF000000;
 		if (reg > 0x3ff)
 			FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
 				  reg);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-26  5:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26  5:43 [PATCH v1 1/1] checks: mask flags bit when check i2c addr Rayagonda Kokatanur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.