summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParshuram Thombare <pthombar@cadence.com>2020-05-21 11:32:22 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-29 09:57:45 +0100
commit8d44d75812cf8908c30d9f104bde8c8b84206816 (patch)
tree33678b6dd6d9ceed2085af74c84d0b444fb3104c
parente7f826cd20a684b75c8d035fe1fe2def731ee3e5 (diff)
downloadlinux-8d44d75812cf8908c30d9f104bde8c8b84206816.tar.gz
linux-8d44d75812cf8908c30d9f104bde8c8b84206816.tar.bz2
linux-8d44d75812cf8908c30d9f104bde8c8b84206816.zip
i3c: master add i3c_master_attach_boardinfo to preserve boardinfo
[ Upstream commit 9da36a7ec42135428e1d41621e3703429bda3b2e ] Boardinfo was lost if I3C object for devices with boardinfo available are not created or not added to the I3C device list because of some failure e.g. SETDASA failed, retrieve info failed etc This patch adds i3c_master_attach_boardinfo which scan boardinfo list in the master object and 'attach' it to the I3C device object. Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Signed-off-by: Parshuram Thombare <pthombar@cadence.com> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Link: https://lore.kernel.org/linux-i3c/1590053542-389-1-git-send-email-pthombar@cadence.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/i3c/master.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 5c051dba32a5..6cc71c90f85e 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -1760,6 +1760,21 @@ static void i3c_master_bus_cleanup(struct i3c_master_controller *master)
i3c_master_detach_free_devs(master);
}
+static void i3c_master_attach_boardinfo(struct i3c_dev_desc *i3cdev)
+{
+ struct i3c_master_controller *master = i3cdev->common.master;
+ struct i3c_dev_boardinfo *i3cboardinfo;
+
+ list_for_each_entry(i3cboardinfo, &master->boardinfo.i3c, node) {
+ if (i3cdev->info.pid != i3cboardinfo->pid)
+ continue;
+
+ i3cdev->boardinfo = i3cboardinfo;
+ i3cdev->info.static_addr = i3cboardinfo->static_addr;
+ return;
+ }
+}
+
static struct i3c_dev_desc *
i3c_master_search_i3c_dev_duplicate(struct i3c_dev_desc *refdev)
{
@@ -1815,10 +1830,10 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,
if (ret)
goto err_detach_dev;
+ i3c_master_attach_boardinfo(newdev);
+
olddev = i3c_master_search_i3c_dev_duplicate(newdev);
if (olddev) {
- newdev->boardinfo = olddev->boardinfo;
- newdev->info.static_addr = olddev->info.static_addr;
newdev->dev = olddev->dev;
if (newdev->dev)
newdev->dev->desc = newdev;