diff mbox series

[RFC,4/5] i3c: show error messages in of_i3c_master_add_i3c_boardinfo

Message ID 20230621162005.473049-5-ben.dooks@codethink.co.uk (mailing list archive)
State Rejected
Headers show
Series updates for i3c error printing | expand

Commit Message

Ben Dooks June 21, 2023, 4:20 p.m. UTC
If of_i3c_master_add_i3c_boardinfo() fails, then there's no much to say
what the issue was (most of the error returns are -EINVAL), so add some
printing of the errors using dev_err() showing the node that failed and
what the issue was.

This should help with finding which device-tree node was causing the
issue and also mirrors the i2c case where it shows the node and the
error.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/i3c/master.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index bc42669f5c6d..2a9ebb1d9d57 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2050,32 +2050,42 @@  of_i3c_master_add_i3c_boardinfo(struct i3c_master_controller *master,
 		return -ENOMEM;
 
 	if (reg[0]) {
-		if (reg[0] > I3C_MAX_ADDR)
+		if (reg[0] > I3C_MAX_ADDR) {
+			dev_err(dev, "%pOF: address too big\n", node);
 			return -EINVAL;
+		}
 
 		addrstatus = i3c_bus_get_addr_slot_status(&master->bus,
 							  reg[0]);
-		if (addrstatus != I3C_ADDR_SLOT_FREE)
+		if (addrstatus != I3C_ADDR_SLOT_FREE) {
+			dev_err(dev, "%pOF: slot in use\n", node);
 			return -EINVAL;
+		}
 	}
 
 	boardinfo->static_addr = reg[0];
 
 	if (!of_property_read_u32(node, "assigned-address", &init_dyn_addr)) {
-		if (init_dyn_addr > I3C_MAX_ADDR)
+		if (init_dyn_addr > I3C_MAX_ADDR) {
+			dev_err(dev, "%pOF: cannot assign address\n", node);
 			return -EINVAL;
+		}
 
 		addrstatus = i3c_bus_get_addr_slot_status(&master->bus,
 							  init_dyn_addr);
-		if (addrstatus != I3C_ADDR_SLOT_FREE)
+		if (addrstatus != I3C_ADDR_SLOT_FREE) {
+			dev_err(dev, "%pOF: slot in use\n", node);
 			return -EINVAL;
+		}
 	}
 
 	boardinfo->pid = ((u64)reg[1] << 32) | reg[2];
 
 	if ((boardinfo->pid & GENMASK_ULL(63, 48)) ||
-	    I3C_PID_RND_LOWER_32BITS(boardinfo->pid))
+	    I3C_PID_RND_LOWER_32BITS(boardinfo->pid)) {
+		dev_err(dev, "%pOF: bad PID\n", node);
 		return -EINVAL;
+	}
 
 	boardinfo->init_dyn_addr = init_dyn_addr;
 	boardinfo->of_node = of_node_get(node);