xref: /linux/arch/s390/pci/pci_bus.h (revision fb7399cf2d0b33825b8039f95c45395c7deba25c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright IBM Corp. 2020
4  *
5  * Author(s):
6  *   Pierre Morel <pmorel@linux.ibm.com>
7  *
8  */
9 #ifndef __S390_PCI_BUS_H
10 #define __S390_PCI_BUS_H
11 
12 #include <linux/pci.h>
13 
14 int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops);
15 void zpci_bus_device_unregister(struct zpci_dev *zdev);
16 
17 int zpci_bus_scan_bus(struct zpci_bus *zbus);
18 void zpci_bus_scan_busses(void);
19 
20 int zpci_bus_scan_device(struct zpci_dev *zdev);
21 void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error);
22 
23 void zpci_release_device(struct kref *kref);
24 
25 void zpci_zdev_put(struct zpci_dev *zdev);
26 
27 static inline void zpci_zdev_get(struct zpci_dev *zdev)
28 {
29 	kref_get(&zdev->kref);
30 }
31 
32 int zpci_alloc_domain(int domain);
33 void zpci_free_domain(int domain);
34 int zpci_setup_bus_resources(struct zpci_dev *zdev);
35 
36 static inline struct zpci_dev *zdev_from_bus(struct pci_bus *bus,
37 					     unsigned int devfn)
38 {
39 	struct zpci_bus *zbus = bus->sysdata;
40 
41 	return (devfn >= ZPCI_FUNCTIONS_PER_BUS) ? NULL : zbus->function[devfn];
42 }
43 
44 #endif /* __S390_PCI_BUS_H */
45