From patchwork Mon Mar 25 13:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13602148 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12F0C14E2E8 for ; Mon, 25 Mar 2024 13:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711372638; cv=none; b=A2qJ1RbYVkJCKSlwtpgUVmrQFNQtHECKQfV6XJZIOFYL+3E3yNQfzi8F0qGBFTSRNMmFk9K1O+ux/fvLWqys0oz6DkyUeZvGKnE0ujQxtfxG4AWYlUUxrF0p4xpfjwz7mFrqkUy6BH6t5PzD2KVf49DFpdFIAG4AhjKj1qTi7Q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711372638; c=relaxed/simple; bh=ItVOWrm+zmPgwU0jiuXsWbAoFc6imFhaKj9fNGvBoW8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hmc33OY3CqjjkjxAYOfMbLg21B9h9HzqfvaOhqgFj0WxFgW8D6nb2s/u4XaTKqGFn7AGjdpG7aZPCvJGKvEztn6xO0bMHcWztdUtt2+w0c/W2ZNj7jD8MqcJTwEKFtN45UlpwrRET6H+9AmBcHBQscPE2dZKWjqr3GuBF6uNCTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=bWcR5fp0; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="bWcR5fp0" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-341b9f6fb2eso1925361f8f.2 for ; Mon, 25 Mar 2024 06:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1711372633; x=1711977433; darn=vger.kernel.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=bWcR5fp0NQgNFHcaVtEWPyXRuGcrCYFsF3e5IzYI5bbaNUXdykaznXyU8VBsquqnUK sijtnJawadYMyWeDdf7RMcWkLDL/hUjhpPISDA0H48hWgQG+IOUJMkchQbmvfqFWHuCu 1TgAZ3L4Gh7aYbA01yubsxwvggwLySBp50+L1b5JQkvLc3DHWycVGKROH1GqT0SI12V8 klpS+S5e+I83W3kF7RlbHLxT3SkkoUN3ou5mL23SlAKbJljPMj1EnGu2t9XRtq5MzWcl LhgXHLlb7i5Efj8DFmaw2SIQTDHCKWYoQzzItkJmY45bvzeXkAZaFen94vbAp7A7D4/P zAJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711372633; x=1711977433; 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=mTFGYgY1BhnhtQl0KLAKOSr2lbn6gEs2AFiBm+ecs17UGZ1Nk1uopQo7AC1dMCmXB/ oBVw66oyYUbZ9gG9usMq9X56lEHQyHQWmSpsiPKWoJU2Aeeg+aXx0B2Uxd8bXuhZHZ33 kG6FkTup9bCk8ZeFyohzx3FbjDx2YjokKGSrLFiW+XiDaAG5IYqzt80xBFQ26dLsfiua UqpyjzqGcwIjX018qyb7LYXdxBDxz4je4KAFxOtfu90x0MDlHr2UmgKYpqpeCXrEg5Af NSiHOQQjRxJLLYhAlh/RjtfzAkUKNWT/SVrBQ1O8RgaefEgAkqnT9pJV2z1m32sAoUzC ikMg== X-Gm-Message-State: AOJu0YzpRhhY9DsLLAmhIX5fhrvgtfjKv/iYb1kyAZFISheMqRkjVCQq bm66xM7NSeSStAArzo00JGU7wRgNL9ZQT5IDFo+maOhy5FeuCdjPKXdFz/mBbUE= X-Google-Smtp-Source: AGHT+IFnBB4ou+MtybFYeGBZFDzE9OJRQ1/N/lDwetqTu850+c2PtigCOW6y2/ygvJYaO6TvQpRrZA== X-Received: by 2002:a5d:62c3:0:b0:33e:5fbf:ec4a with SMTP id o3-20020a5d62c3000000b0033e5fbfec4amr5030221wrv.64.1711372633464; Mon, 25 Mar 2024 06:17:13 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:75a:e000:861d:8b72:a859:4ce9]) by smtp.gmail.com with ESMTPSA id p11-20020a056000018b00b0033e75e5f280sm9485245wrx.113.2024.03.25.06.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:17:13 -0700 (PDT) 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 v6 11/16] PCI/pwrctl: create platform devices for child OF nodes of the port node Date: Mon, 25 Mar 2024 14:16:19 +0100 Message-Id: <20240325131624.26023-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240325131624.26023-1-brgl@bgdev.pl> References: <20240325131624.26023-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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);