PCI: Introduce pci_bus_{get|put}() to manage PCI bus reference count
authorJiang Liu <liuj97@gmail.com>
Sat, 25 May 2013 13:48:29 +0000 (21:48 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 27 May 2013 22:22:09 +0000 (16:22 -0600)
Introduce helper functions pci_bus_{get|put}() to manage PCI bus
reference count.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/bus.c
include/linux/pci.h

index 32e66a6f12d98084f77f493ed1d202084ad3329e..b1ff02ab4f131fbda7edd9971342b9ae91bf4149 100644 (file)
@@ -283,6 +283,21 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
 }
 EXPORT_SYMBOL_GPL(pci_walk_bus);
 
+struct pci_bus *pci_bus_get(struct pci_bus *bus)
+{
+       if (bus)
+               get_device(&bus->dev);
+       return bus;
+}
+EXPORT_SYMBOL(pci_bus_get);
+
+void pci_bus_put(struct pci_bus *bus)
+{
+       if (bus)
+               put_device(&bus->dev);
+}
+EXPORT_SYMBOL(pci_bus_put);
+
 EXPORT_SYMBOL(pci_bus_alloc_resource);
 EXPORT_SYMBOL_GPL(pci_bus_add_device);
 EXPORT_SYMBOL(pci_bus_add_devices);
index 3a24e4ff32481898f5009c2a162c9a7f33d0222e..7556c590ddfd42ec64bdb9fffabab6ca4ca02508 100644 (file)
@@ -1018,6 +1018,8 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *);
 void pci_release_selected_regions(struct pci_dev *, int);
 
 /* drivers/pci/bus.c */
+struct pci_bus *pci_bus_get(struct pci_bus *bus);
+void pci_bus_put(struct pci_bus *bus);
 void pci_add_resource(struct list_head *resources, struct resource *res);
 void pci_add_resource_offset(struct list_head *resources, struct resource *res,
                             resource_size_t offset);