From patchwork Mon Dec 9 13:03:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 13899640 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1164D1E9B38; Mon, 9 Dec 2024 13:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733749440; cv=none; b=bFqrKxFVMcVU0HNAe3rr9GmwTn+M58Z8YYP8ig2GI3YhowEzP1LW4NUackDBHQ77dcrg5biItUYmWXnDVZKZADEKJwkLopcYvR6gygcUaY/YsteukTFVc5jqgtpy9K/7F7CirpYEVh60oDc8ha18As+bRdI7LL/g5Z9KnojLH20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733749440; c=relaxed/simple; bh=PloGdo8yWaAB0mEU1AiYQL4TycpKuip5XLuZ2Uy87RU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LG7vZ0wF5bV1kkSTLKOjgCxWTxjlGjjxtEdRqjvy6iMWxoffQG7s6GA7pN87HZp2thwrBNO4yO5HnE7rnilaznmsI05S2aFH0sjY0OxUZJ+93OJM3tTMoMoLzzZ+R5U6hhbz7W0KjA5UG5bD/Jul6jfblRnn37yO98hX4HR3XfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=eSDkOPjD; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eSDkOPjD" Received: by mail.gandi.net (Postfix) with ESMTPA id 0C8E620007; Mon, 9 Dec 2024 13:03:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1733749435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GU1Q5uwrUxslDSQGz6WRaqjWVuhawVTEJ7MmY7c/q20=; b=eSDkOPjDW+OuUXFyxZwul4ngHtBCec+zKGXIq05ozEXmOzSM3FPX4jf45eReOIRJUkF7/p NZuEs7ztSfJTc/HP9ztAZcqe74ckGfC3DXMl0ULD8rNHLz5sJ0MhoIF2DyNDbrX/OTR610 LHrPXxucHPa+q40WcwkL+MCg/Fz+KwCYUipaQJMQLw021I5G/kFL2Y/eiZQgaT+NjTBJuQ SZD59eo8GkfE5cGda3o7TZOX/b92lhp0FqReuEba6BWCB+qqPVh5PrkwpxhTLpvNV5zGyx BciXD4DXJeO0Ac2PSRZj0m9428Ufo6FlrAkP03XozT3W+yFuXEXx8fGT+Uzckw== From: Herve Codina To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Bjorn Helgaas , Lizhi Hou Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , Herve Codina Subject: [PATCH v5 3/5] PCI: of_property: Add support for NULL pdev in of_pci_set_address() Date: Mon, 9 Dec 2024 14:03:35 +0100 Message-ID: <20241209130339.81354-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241209130339.81354-1-herve.codina@bootlin.com> References: <20241209130339.81354-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com The pdev (pointer to a struct pci_dev) parameter of of_pci_set_address() cannot be NULL. In order to reuse of_pci_set_address() when creating the PCI root bus node, this function needs to support a NULL pdev parameter. Indeed, in the case of the PCI root bus node creation, no pdev are available and of_pci_set_address() will be used with the bridge windows. Allow to call of_pci_set_address() with a NULL pdev. Signed-off-by: Herve Codina --- drivers/pci/of_property.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index 886c236e5de6..8aff9ca1f222 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -54,9 +54,13 @@ enum of_pci_prop_compatible { static void of_pci_set_address(struct pci_dev *pdev, u32 *prop, u64 addr, u32 reg_num, u32 flags, bool reloc) { - prop[0] = FIELD_PREP(OF_PCI_ADDR_FIELD_BUS, pdev->bus->number) | - FIELD_PREP(OF_PCI_ADDR_FIELD_DEV, PCI_SLOT(pdev->devfn)) | - FIELD_PREP(OF_PCI_ADDR_FIELD_FUNC, PCI_FUNC(pdev->devfn)); + if (pdev) + prop[0] = FIELD_PREP(OF_PCI_ADDR_FIELD_BUS, pdev->bus->number) | + FIELD_PREP(OF_PCI_ADDR_FIELD_DEV, PCI_SLOT(pdev->devfn)) | + FIELD_PREP(OF_PCI_ADDR_FIELD_FUNC, PCI_FUNC(pdev->devfn)); + else + prop[0] = 0; + prop[0] |= flags | reg_num; if (!reloc) { prop[0] |= OF_PCI_ADDR_FIELD_NONRELOC;