kfree(zdev);
 }
 
-static void zpci_scan_devices(void)
-{
-       struct zpci_dev *zdev;
-
-       mutex_lock(&zpci_list_lock);
-       list_for_each_entry(zdev, &zpci_list, entry)
-               if (zdev->state == ZPCI_FN_STATE_CONFIGURED)
-                       zpci_scan_device(zdev);
-       mutex_unlock(&zpci_list_lock);
-}
-
 /*
  * Too late for any s390 specific setup, since interrupts must be set up
  * already which requires DMA setup too and the pci scan will access the
 {
        struct zpci_dev *zdev = get_zdev(pdev);
 
+       zdev->pdev = pdev;
        zpci_debug_init_device(zdev);
        zpci_fmb_enable_device(zdev);
        zpci_map_resources(zdev);
        return 0;
 }
 
-static int zpci_create_device_bus(struct zpci_dev *zdev)
+static int zpci_scan_bus(struct zpci_dev *zdev)
 {
        struct resource *res;
        LIST_HEAD(resources);
                pci_add_resource(&resources, res);
        }
 
-       zdev->bus = pci_create_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
-                                       zdev, &resources);
+       zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
+                                     zdev, &resources);
        if (!zdev->bus)
                return -EIO;
 
        if (rc)
                goto out;
 
-       rc = zpci_create_device_bus(zdev);
+       if (zdev->state == ZPCI_FN_STATE_CONFIGURED) {
+               rc = zpci_enable_device(zdev);
+               if (rc)
+                       goto out_free;
+
+               zdev->state = ZPCI_FN_STATE_ONLINE;
+       }
+       rc = zpci_scan_bus(zdev);
        if (rc)
-               goto out_bus;
+               goto out_disable;
 
        mutex_lock(&zpci_list_lock);
        list_add_tail(&zdev->entry, &zpci_list);
                hotplug_ops->create_slot(zdev);
        mutex_unlock(&zpci_list_lock);
 
-       if (zdev->state == ZPCI_FN_STATE_STANDBY)
-               return 0;
-
-       rc = zpci_enable_device(zdev);
-       if (rc)
-               goto out_start;
        return 0;
 
-out_start:
-       mutex_lock(&zpci_list_lock);
-       list_del(&zdev->entry);
-       if (hotplug_ops)
-               hotplug_ops->remove_slot(zdev);
-       mutex_unlock(&zpci_list_lock);
-out_bus:
+out_disable:
+       if (zdev->state == ZPCI_FN_STATE_ONLINE)
+               zpci_disable_device(zdev);
+out_free:
        zpci_free_domain(zdev);
 out:
        return rc;
 
        pci_bus_add_devices(zdev->bus);
 
-       /* now that pdev was added to the bus mark it as used */
-       zdev->state = ZPCI_FN_STATE_ONLINE;
        return 0;
-
 out:
        zpci_dma_exit_device(zdev);
        clp_disable_fh(zdev);
        if (rc)
                goto out_find;
 
-       zpci_scan_devices();
        return 0;
 
 out_find: