[RESEND RFC PATCH 2/3] pci: generic-domains: Add helpers to alloc/free dynamic bus numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add helpers to allocate/free useable PCI domain numbers at runtime.
This will be later used by sample devsec code.

Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
---
 drivers/pci/pci.c   | 16 ++++++++++++++--
 include/linux/pci.h |  3 +++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 869d204a70a3..729bc57e025b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6685,6 +6685,18 @@ static void pci_no_domains(void)
 static DEFINE_IDA(pci_domain_nr_static_ida);
 static DEFINE_IDA(pci_domain_nr_dynamic_ida);
 
+int pci_alloc_dynamic_domain(void)
+{
+	return ida_alloc(&pci_domain_nr_dynamic_ida, GFP_KERNEL);
+}
+EXPORT_SYMBOL_GPL(pci_alloc_dynamic_domain);
+
+void pci_free_dynamic_domain(int domain)
+{
+	ida_free(&pci_domain_nr_dynamic_ida, domain);
+}
+EXPORT_SYMBOL_GPL(pci_free_dynamic_domain);
+
 static void of_pci_reserve_static_domain_nr(void)
 {
 	struct device_node *np;
@@ -6733,7 +6745,7 @@ static int of_pci_bus_find_domain_nr(struct device *parent)
 	 * dynamic allocations to prevent assigning them to other DT nodes
 	 * without static domain.
 	 */
-	return ida_alloc(&pci_domain_nr_dynamic_ida, GFP_KERNEL);
+	return pci_alloc_dynamic_domain();
 }
 
 static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
@@ -6745,7 +6757,7 @@ static void of_pci_bus_release_domain_nr(struct device *parent, int domain_nr)
 	if (of_get_pci_domain_nr(parent->of_node) == domain_nr)
 		ida_free(&pci_domain_nr_static_ida, domain_nr);
 	else
-		ida_free(&pci_domain_nr_dynamic_ida, domain_nr);
+		pci_free_dynamic_domain(domain_nr);
 }
 
 int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c2f18f31f7a7..c040c1d49632 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1934,6 +1934,9 @@ static inline int acpi_pci_bus_find_domain_nr(struct pci_bus *bus)
 #endif
 int pci_bus_find_domain_nr(struct pci_bus *bus, struct device *parent);
 void pci_bus_release_domain_nr(struct device *parent, int domain_nr);
+int pci_alloc_dynamic_domain(void);
+void pci_free_dynamic_domain(int domain);
+
 #endif
 
 /* Some architectures require additional setup to direct VGA traffic */
-- 
2.43.0





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux