Lines Matching refs:zbus
41 static int zpci_bus_scan(struct zpci_bus *zbus, int domain, struct pci_ops *ops) in zpci_bus_scan() argument
49 zbus->domain_nr = rc; in zpci_bus_scan()
51 bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, ops, zbus, &zbus->resources); in zpci_bus_scan()
53 zpci_free_domain(zbus->domain_nr); in zpci_bus_scan()
57 zbus->bus = bus; in zpci_bus_scan()
64 struct zpci_bus *zbus = container_of(kref, struct zpci_bus, kref); in zpci_bus_release() local
66 if (zbus->bus) { in zpci_bus_release()
68 pci_stop_root_bus(zbus->bus); in zpci_bus_release()
70 zpci_free_domain(zbus->domain_nr); in zpci_bus_release()
71 pci_free_resource_list(&zbus->resources); in zpci_bus_release()
73 pci_remove_root_bus(zbus->bus); in zpci_bus_release()
78 list_del(&zbus->bus_next); in zpci_bus_release()
80 kfree(zbus); in zpci_bus_release()
83 static void zpci_bus_put(struct zpci_bus *zbus) in zpci_bus_put() argument
85 kref_put(&zbus->kref, zpci_bus_release); in zpci_bus_put()
90 struct zpci_bus *zbus; in zpci_bus_get() local
93 list_for_each_entry(zbus, &zbus_list, bus_next) { in zpci_bus_get()
94 if (pchid == zbus->pchid) { in zpci_bus_get()
95 kref_get(&zbus->kref); in zpci_bus_get()
99 zbus = NULL; in zpci_bus_get()
102 return zbus; in zpci_bus_get()
107 struct zpci_bus *zbus; in zpci_bus_alloc() local
109 zbus = kzalloc(sizeof(*zbus), GFP_KERNEL); in zpci_bus_alloc()
110 if (!zbus) in zpci_bus_alloc()
113 zbus->pchid = pchid; in zpci_bus_alloc()
114 INIT_LIST_HEAD(&zbus->bus_next); in zpci_bus_alloc()
116 list_add_tail(&zbus->bus_next, &zbus_list); in zpci_bus_alloc()
119 kref_init(&zbus->kref); in zpci_bus_alloc()
120 INIT_LIST_HEAD(&zbus->resources); in zpci_bus_alloc()
122 zbus->bus_resource.start = 0; in zpci_bus_alloc()
123 zbus->bus_resource.end = ZPCI_BUS_NR; in zpci_bus_alloc()
124 zbus->bus_resource.flags = IORESOURCE_BUS; in zpci_bus_alloc()
125 pci_add_resource(&zbus->resources, &zbus->bus_resource); in zpci_bus_alloc()
127 return zbus; in zpci_bus_alloc()
139 zpci_iov_setup_virtfn(zdev->zbus, pdev, zdev->vfn); in pcibios_bus_add_device()
144 static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev) in zpci_bus_add_device() argument
152 bus = zbus->bus; in zpci_bus_add_device()
168 resource_list_for_each_entry_safe(window, n, &zbus->resources) { in zpci_bus_add_device()
180 static void zpci_bus_add_devices(struct zpci_bus *zbus) in zpci_bus_add_devices() argument
185 if (zbus->function[i]) in zpci_bus_add_devices()
186 zpci_bus_add_device(zbus, zbus->function[i]); in zpci_bus_add_devices()
189 pci_bus_add_devices(zbus->bus); in zpci_bus_add_devices()
195 struct zpci_bus *zbus = NULL; in zpci_bus_device_register() local
209 zbus = zpci_bus_get(zdev->pchid); in zpci_bus_device_register()
211 if (!zbus) { in zpci_bus_device_register()
212 zbus = zpci_bus_alloc(zdev->pchid); in zpci_bus_device_register()
213 if (!zbus) in zpci_bus_device_register()
217 zdev->zbus = zbus; in zpci_bus_device_register()
218 if (zbus->function[zdev->devfn]) { in zpci_bus_device_register()
222 zbus->function[zdev->devfn] = zdev; in zpci_bus_device_register()
224 zpci_setup_bus_resources(zdev, &zbus->resources); in zpci_bus_device_register()
226 if (zbus->bus) { in zpci_bus_device_register()
227 if (!zbus->multifunction) { in zpci_bus_device_register()
235 rc = zpci_bus_add_device(zbus, zdev); in zpci_bus_device_register()
239 if (zbus->multifunction && !zdev->rid_available) { in zpci_bus_device_register()
243 rc = zpci_bus_scan(zbus, (u16)zdev->uid, ops); in zpci_bus_device_register()
246 zpci_bus_add_devices(zbus); in zpci_bus_device_register()
251 zbus->multifunction = zdev->rid_available; in zpci_bus_device_register()
252 zbus->max_bus_speed = zdev->max_bus_speed; in zpci_bus_device_register()
254 zbus->multifunction = 1; in zpci_bus_device_register()
261 zbus->function[zdev->devfn] = NULL; in zpci_bus_device_register()
264 zpci_bus_put(zbus); in zpci_bus_device_register()
270 struct zpci_bus *zbus = zdev->zbus; in zpci_bus_device_unregister() local
273 zbus->function[zdev->devfn] = NULL; in zpci_bus_device_unregister()
274 zpci_bus_put(zbus); in zpci_bus_device_unregister()