From 57b3eb6213b4fbfb62dd0077f55827d9891e4d17 Mon Sep 17 00:00:00 2001 From: Ryan McClelland Date: Mon, 9 Dec 2024 18:43:51 -0800 Subject: [PATCH] drivers: i3c: cdns: fix rr slot lookup when dyn is 0 When attaching a device, it should look up if the dynamic addr is already attached only, and not by the static addr. Signed-off-by: Ryan McClelland --- drivers/i3c/i3c_cdns.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/i3c/i3c_cdns.c b/drivers/i3c/i3c_cdns.c index df1b37eef43e..e6d18ed058c5 100644 --- a/drivers/i3c/i3c_cdns.c +++ b/drivers/i3c/i3c_cdns.c @@ -2001,7 +2001,7 @@ static int cdns_i3c_master_get_rr_slot(const struct device *dev, uint8_t dyn_add rr_idx = i - 1; if (activedevs & BIT(rr_idx)) { rr = sys_read32(config->base + DEV_ID_RR0(rr_idx)); - if ((rr & DEV_ID_RR0_IS_I3C) && DEV_ID_RR0_GET_DEV_ADDR(rr) == dyn_addr) { + if ((rr & DEV_ID_RR0_IS_I3C) && (DEV_ID_RR0_GET_DEV_ADDR(rr) == dyn_addr)) { return rr_idx; } } @@ -2025,8 +2025,7 @@ static int cdns_i3c_attach_device(const struct device *dev, struct i3c_device_de const struct cdns_i3c_config *config = dev->config; struct cdns_i3c_data *data = dev->data; - int slot = cdns_i3c_master_get_rr_slot(dev, desc->dynamic_addr ? desc->dynamic_addr - : desc->static_addr); + int slot = cdns_i3c_master_get_rr_slot(dev, desc->dynamic_addr); if (slot < 0) { LOG_ERR("%s: no space for i3c device: %s", dev->name, desc->dev->name);