From patchwork Tue Sep 3 10:35:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitor Soares X-Patchwork-Id: 11138763 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 278B476 for ; Tue, 10 Sep 2019 06:39:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F362D20872 for ; Tue, 10 Sep 2019 06:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NcdKnu7P"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="Nw2gFNkD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F362D20872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rxBHPIkkAQJfoUg+Q3Dwtju+3fosurpa//hkacpvhsI=; b=NcdKnu7Pu16ZbP6YPTEUMcsDnF GmUMcSipmxVUTqKR5iLQ5jP1zfMuSs7IRlCI+dlOcxTyjNCEvyAZmHXiVcuEuRht8VqAU2gxM51wl +ek1y8O78TpMDJfhudEcCOSJOCdVtLLM2lC4jOfkPiM3kQKI/uMkQINmdDpupF6gleNJTlDGDHvbY eyDHeZxcdf+UlzhjV/KjWgGJhsT7JSFYjJBE8PvmVQG+ykYMLu4dqBNs/tU29KKjaEGhkdZOca1hA Y/ee8E4vhHP4HwQmiH1Rlxq32cAEgerkOXyoL9v5HxL0ybuyccdC++gM9KUt6txdny+EZ+iH3NSR3 RPGFBYmA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i7Zoe-0006tM-FW; Tue, 10 Sep 2019 06:39:52 +0000 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102] helo=smtprelay-out1.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i56AL-00089l-5j for linux-i3c@lists.infradead.org; Tue, 03 Sep 2019 10:36:04 +0000 Received: from mailhost.synopsys.com (mdc-mailhost2.synopsys.com [10.225.0.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 7111CC0C4A; Tue, 3 Sep 2019 10:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1567506958; bh=hzEcIxH9OkYzQ2wF2QX+ihkL5mVW4n1QxZ4evCVUErM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=Nw2gFNkDwaEHAvmWI6x6vWdrQ+2sCSutk1yItj7eStLFz29/9Aic6KJrZmXntJ1tS dP3psLh3BYBZZEBjrxf4cYyDhPh7IJVP26+yVDfRZpnF84y99v+xq+s5svc3tHIg5d 6lVvgWuL2plWUz0CtnqXlAMw7Hh5lEC8t81i41PSUBh3vobRVvkri8D1ftjdBzGJUZ B4259R+uU+Rce3JpnM8YD99d9OorlOjGwYsUENqlG92tENtxU5rEyoP+cWYPobyZ6O BkJDKq67/4lPPH+D6U7f/AqfPQUvXp1JpIC4Q6aJ0VNd5upXvux1kJeQTx+S8GLQuC w1Gr53HDwUwmA== Received: from de02.synopsys.com (germany.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id CD0EEA0069; Tue, 3 Sep 2019 10:35:56 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id B455F3C0D7; Tue, 3 Sep 2019 12:35:56 +0200 (CEST) From: Vitor Soares To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-i3c@lists.infradead.org Subject: [PATCH v2 2/5] i3c: master: make sure ->boardinfo is initialized in add_i3c_dev_locked() Date: Tue, 3 Sep 2019 12:35:51 +0200 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190903_033601_429513_8F205319 X-CRM114-Status: GOOD ( 13.34 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Mailman-Approved-At: Mon, 09 Sep 2019 23:39:51 -0700 X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Joao.Pinto@synopsys.com, bbrezillon@kernel.org, stable@vger.kernel.org, Vitor Soares , pgaj@cadence.com, robh+dt@kernel.org MIME-Version: 1.0 Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org The newdev->boardinfo assignment was missing in i3c_master_add_i3c_dev_locked() and hence the ->of_node info isn't propagated to i3c_dev_desc. Fix this by trying to initialize device i3c_dev_boardinfo if available. Cc: Fixes: 3a379bbcea0a ("i3c: Add core I3C infrastructure") Signed-off-by: Vitor Soares --- Changes in v2: - Change commit message - Change i3c_master_search_i3c_boardinfo(newdev) to i3c_master_init_i3c_dev_boardinfo(newdev) - Add fixes, stable tags drivers/i3c/master.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 586e34f..9fb99bc 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1798,6 +1798,22 @@ i3c_master_search_i3c_dev_duplicate(struct i3c_dev_desc *refdev) return NULL; } +static void i3c_master_init_i3c_dev_boardinfo(struct i3c_dev_desc *dev) +{ + struct i3c_master_controller *master = i3c_dev_get_master(dev); + struct i3c_dev_boardinfo *boardinfo; + + if (dev->boardinfo) + return; + + list_for_each_entry(boardinfo, &master->boardinfo.i3c, node) { + if (dev->info.pid == boardinfo->pid) { + dev->boardinfo = boardinfo; + return; + } + } +} + /** * i3c_master_add_i3c_dev_locked() - add an I3C slave to the bus * @master: master used to send frames on the bus @@ -1818,8 +1834,9 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, u8 addr) { struct i3c_device_info info = { .dyn_addr = addr }; - struct i3c_dev_desc *newdev, *olddev; u8 old_dyn_addr = addr, expected_dyn_addr; + enum i3c_addr_slot_status addrstatus; + struct i3c_dev_desc *newdev, *olddev; struct i3c_ibi_setup ibireq = { }; bool enable_ibi = false; int ret; @@ -1878,6 +1895,8 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, if (ret) goto err_detach_dev; + i3c_master_init_i3c_dev_boardinfo(newdev); + /* * Depending on our previous state, the expected dynamic address might * differ: @@ -1895,7 +1914,11 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master, else expected_dyn_addr = newdev->info.dyn_addr; - if (newdev->info.dyn_addr != expected_dyn_addr) { + addrstatus = i3c_bus_get_addr_slot_status(&master->bus, + expected_dyn_addr); + + if (newdev->info.dyn_addr != expected_dyn_addr && + addrstatus == I3C_ADDR_SLOT_FREE) { /* * Try to apply the expected dynamic address. If it fails, keep * the address assigned by the master.