From patchwork Fri Feb 16 20:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13560655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6CCD3C48260 for ; Fri, 16 Feb 2024 20:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9JkzuYZtclLYx0f/RE7sbsczrYYW8MJ8B+Z08E/h+kM=; b=4KdhlsmoFSI7cU 7cbQ+cepv8cHAC3Fb+z1tu7mZky1RmZ7yQs1iKtgZE6P15mQ6wKgtJdFG1W7bFKJ38hacqhMnvPJK hB2LawHpLwOiHx0bffgMHajTQUk+UbjzXavOG/jnTrQZkqGxVYZnEoRpOGEPy3fJBDgM975KIgdQS aHtkil/BG2ddDNFN1Zx472ad+Ogzu3drCvMd2Aj4w6JEgunsbPMywunLVqGy4qJaAUUTvcnOsNqos xbYRFgfWBxxIrE1mgyFFPuQKBZepcSwbhJBzJ6WoZBuXv8hLe8t2SehM8M9XSLIPTpFrhTyFOn69Z IHHyIPomjzy4eUCVCcjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb4uY-00000003eJC-2Cle; Fri, 16 Feb 2024 20:34:18 +0000 Received: from mail-wm1-f49.google.com ([209.85.128.49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb4tr-00000003dpS-4BTR for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 20:33:39 +0000 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-411d3c75026so18914835e9.0 for ; Fri, 16 Feb 2024 12:33:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115610; x=1708720410; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cLRQo0XRS8LZDKEz8aQDPJI24t7vYnPhkxLETHKtHpE=; b=O47Jq/B3hOUOj9r09mL1+CuPo90BFAowdTRDgiFs+FqoD50Stlhk7AKkgnJSeEZXEB eX4+RDqjMCbwsbFT+Awr570lM+th/7cDUZCE5wjxbAV297If/diL6/4TKYYqnYaktaU+ 06kzrPUBLKsHy3JLGkDP0kN69PVoLL0yiJSmyeD3pHw5xGqQxxhCAHNqLt2rMa4r04G4 +xJ1u1IN8yNkYUCHSrlnl0X6+Px8TWBcEac9Dl0LmFGcrVeR6C/3gwKcAnjsVdaoq4Ya clK2XDoDZ8wG5TeycoEWNfLvKItkwBsF/xqMVaGNvQtWvUARhjCDSYA0bxgcv6pO+TCz aELA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115610; x=1708720410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cLRQo0XRS8LZDKEz8aQDPJI24t7vYnPhkxLETHKtHpE=; b=L7P6OJ+ZCsOmDZO4VtcrZQuOWRnaOrXCdb9aZ2Pr2FMPd+Hojp2U/lKWIOhwC1Ja9+ magB1lColtFwWnqN3ODKnvkDUaIMtxwW8QVqVZXdy7U6xVKseM4de2iGiETsVKi5nSY+ ob1slpOzo58nR1JVKf2hzNUHmysd9pUxBoPSSGAHktRjC7R32RztbhpfjXazI1iJ/Fwm YqT10GASbSqwPdPC3K6DgGi9ydbIeMPrXhuc8cQjMJ2xtuQSpFkFSCE2jWd3A1i6DsvG ApMiZx1jUE1t+ohAZlEjEJ05hYauaqe7X5DKxa2u7pJUuUnb9ribSvR2zYltMXM+KJS7 o8jQ== X-Forwarded-Encrypted: i=1; AJvYcCU08DvPxGIXsXQkepUvr8Oj2puEPk+5Hv1Z+DcJ+X0kPdSIEoAJtWE5jSzI7e8nm1fSPFFajyQ9QlbymBHroAhG5aYY6SkJr2BIdkuzvPs4yyozkH0= X-Gm-Message-State: AOJu0YxSSoAPpZUftRQA+NQcU8G0WxJnDz0vnJjIy7Yhso0sdWdSjBfT qXcHJd8lxFRwgfTMaGt7S+e705uNUPtToYJGBbBue9aFMKDw2VN/I5et3hZyk6Q= X-Google-Smtp-Source: AGHT+IEIxZ+2uB3UEcdhGVTyTJDaWzytlIE0jDJvcLHgbNngP62RD3/E1pF6wGg8FGrlRiGNZ99JNg== X-Received: by 2002:a05:600c:3c8a:b0:411:9508:e237 with SMTP id bg10-20020a05600c3c8a00b004119508e237mr4998629wmb.19.1708115610266; Fri, 16 Feb 2024 12:33:30 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:29 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 12/18] PCI/pwrctl: create platform devices for child OF nodes of the port node Date: Fri, 16 Feb 2024 21:32:09 +0100 Message-Id: <20240216203215.40870-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240216_123336_432177_E65CEB36 X-CRM114-Status: GOOD ( 16.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski In preparation for introducing PCI device power control - a set of library functions that will allow powering-up of PCI devices before they're detected on the PCI bus - we need to populate the devices defined on the device-tree. We are reusing the platform bus as it provides us with all the infrastructure we need to match the pwrctl drivers against the compatibles from OF nodes. These platform devices will be probed by the driver core and bound to the PCI pwrctl drivers we'll introduce later. Signed-off-by: Bartosz Golaszewski --- drivers/pci/bus.c | 9 ++++++++- drivers/pci/remove.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 826b5016a101..17ab41094c4e 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -342,8 +343,14 @@ void pci_bus_add_device(struct pci_dev *dev) */ pcibios_bus_add_device(dev); pci_fixup_device(pci_fixup_final, dev); - if (pci_is_bridge(dev)) + if (pci_is_bridge(dev)) { of_pci_make_dev_node(dev); + retval = of_platform_populate(dev->dev.of_node, NULL, NULL, + &dev->dev); + if (retval) + pci_err(dev, "failed to populate child OF nodes (%d)\n", + retval); + } pci_create_sysfs_dev_files(dev); pci_proc_attach_device(dev); pci_bridge_d3_update(dev); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index d749ea8250d6..fc9db2805888 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "pci.h" static void pci_free_resources(struct pci_dev *dev) @@ -22,6 +23,7 @@ static void pci_stop_dev(struct pci_dev *dev) device_release_driver(&dev->dev); pci_proc_detach_device(dev); pci_remove_sysfs_dev_files(dev); + of_platform_depopulate(&dev->dev); of_pci_remove_node(dev); pci_dev_assign_added(dev, false);