Index: uspace/drv/bus/pci/pciintel/pci.c
===================================================================
--- uspace/drv/bus/pci/pciintel/pci.c	(revision 889cdb1c2046af9d31d314fa691773fa2e4f9119)
+++ uspace/drv/bus/pci/pciintel/pci.c	(revision 184f2f8afd2b5e58162ccd6350f9778305850043)
@@ -1,5 +1,5 @@
 /*
  * Copyright (c) 2010 Lenka Trochtova
- * Copyright (c) 2011 Jiri Svoboda
+ * Copyright (c) 2018 Jiri Svoboda
  * All rights reserved.
  *
@@ -596,6 +596,9 @@
  * @param bus		Host-to-PCI bridge
  * @param bus_num	Bus number
+ *
+ * @return EOK on success, ENOENT if no PCI devices found, ENOMEM if out of
+ *         memory, EIO on other I/O error
  */
-void pci_bus_scan(pci_bus_t *bus, int bus_num)
+errno_t pci_bus_scan(pci_bus_t *bus, int bus_num)
 {
 	pci_fun_t *fun;
@@ -606,4 +609,7 @@
 	bool multi;
 	uint8_t header_type;
+	bool device_found;
+
+	device_found = false;
 
 	for (dnum = 0; dnum < 32; dnum++) {
@@ -625,4 +631,6 @@
 			}
 
+			device_found = true;
+
 			header_type = pci_conf_read_8(fun, PCI_HEADER_TYPE);
 			if (fnum == 0) {
@@ -637,5 +645,5 @@
 				ddf_msg(LVL_ERROR, "Out of memory.");
 				pci_fun_delete(fun);
-				return;
+				return ENOMEM;
 			}
 
@@ -645,5 +653,5 @@
 				ddf_msg(LVL_ERROR, "Failed setting function name.");
 				pci_fun_delete(fun);
-				return;
+				return EIO;
 			}
 
@@ -661,10 +669,4 @@
 
 			pci_fun_create_match_ids(fun);
-
-			if (ddf_fun_bind(fun->fnode) != EOK) {
-				pci_clean_resource_list(fun);
-				pci_fun_delete(fun);
-				continue;
-			}
 
 			if (header_type == PCI_HEADER_TYPE_BRIDGE ||
@@ -675,9 +677,26 @@
 				    "bridge, secondary bus number = %d.",
 				    bus_num);
-				if (child_bus > bus_num)
-					pci_bus_scan(bus, child_bus);
+				if (child_bus > bus_num) {
+					rc = pci_bus_scan(bus, child_bus);
+					if (rc != EOK) {
+						pci_fun_delete(fun);
+						return rc;
+					}
+				}
+			}
+
+			if (ddf_fun_bind(fun->fnode) != EOK) {
+				pci_clean_resource_list(fun);
+				pci_fun_delete(fun);
+				continue;
 			}
 		}
 	}
+
+	/* Fail bus scan if no devices are found. */
+	if (!device_found)
+		return ENOENT;
+
+	return EOK;
 }
 
@@ -783,4 +802,12 @@
 	}
 
+	/* Enumerate functions. */
+	ddf_msg(LVL_DEBUG, "Enumerating the bus");
+	rc = pci_bus_scan(bus, 0);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Bus enumeration failed.");
+		goto fail;
+	}
+
 	rc = ddf_fun_bind(ctl);
 	if (rc != EOK) {
@@ -788,8 +815,4 @@
 		goto fail;
 	}
-
-	/* Enumerate functions. */
-	ddf_msg(LVL_DEBUG, "Scanning the bus");
-	pci_bus_scan(bus, 0);
 
 	hw_res_clean_resource_list(&hw_resources);
Index: uspace/drv/bus/pci/pciintel/pci.h
===================================================================
--- uspace/drv/bus/pci/pciintel/pci.h	(revision 889cdb1c2046af9d31d314fa691773fa2e4f9119)
+++ uspace/drv/bus/pci/pciintel/pci.h	(revision 184f2f8afd2b5e58162ccd6350f9778305850043)
@@ -90,5 +90,5 @@
 extern char *pci_fun_create_name(pci_fun_t *);
 
-extern void pci_bus_scan(pci_bus_t *, int);
+extern errno_t pci_bus_scan(pci_bus_t *, int);
 
 extern bool pci_alloc_resource_list(pci_fun_t *);
