From 1510462043f0474a14ffc8016878dea6e179eb99 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sat, 3 Mar 2018 21:24:17 +0100
Subject: [PATCH] WIP revert global priority hack for ACPI

---
 sys/bus/gpio/gpio_intel/gpio_intel.c |   3 +-
 sys/bus/smbus/ichiic/ig4_acpi.c      |   3 +-
 sys/dev/acpica/acpi.c                |  78 +---------------
 sys/dev/acpica/acpi_acad.c           |   1 -
 sys/dev/acpica/acpi_button.c         |   1 -
 sys/dev/acpica/acpi_cmbat.c          |   1 -
 sys/dev/acpica/acpi_cpu.c            |   3 +-
 sys/dev/acpica/acpi_cpu_cstate.c     |   1 -
 sys/dev/acpica/acpi_cpu_pstate.c     |   3 +-
 sys/dev/acpica/acpi_ec.c             |   1 -
 sys/dev/acpica/acpi_hpet.c           |   1 -
 sys/dev/acpica/acpi_isab.c           |   1 -
 sys/dev/acpica/acpi_lid.c            |   1 -
 sys/dev/acpica/acpi_pci_link.c       |   1 -
 sys/dev/acpica/acpi_resource.c       |   1 -
 sys/dev/acpica/acpi_smbat.c          |   1 -
 sys/dev/acpica/acpi_thermal.c        |   1 -
 sys/dev/acpica/acpi_timer.c          |   1 -
 sys/dev/acpica/acpivar.h             |   3 -
 sys/dev/disk/sdhci/sdhci_acpi.c      |   1 -
 sys/kern/subr_bus.c                  | 170 +----------------------------------
 sys/sys/bus.h                        |   3 -
 sys/sys/kobj.h                       |  11 +--
 23 files changed, 12 insertions(+), 279 deletions(-)

diff --git a/sys/bus/gpio/gpio_intel/gpio_intel.c b/sys/bus/gpio/gpio_intel/gpio_intel.c
index 05840e106e..db42a64679 100644
--- a/sys/bus/gpio/gpio_intel/gpio_intel.c
+++ b/sys/bus/gpio/gpio_intel/gpio_intel.c
@@ -428,8 +428,7 @@ static device_method_t gpio_intel_methods[] = {
 static driver_t gpio_intel_driver = {
         "gpio_intel",
         gpio_intel_methods,
-        sizeof(struct gpio_intel_softc),
-	.gpri = KOBJ_GPRI_ACPI+2
+        sizeof(struct gpio_intel_softc)
 };
 
 static devclass_t gpio_intel_devclass;
diff --git a/sys/bus/smbus/ichiic/ig4_acpi.c b/sys/bus/smbus/ichiic/ig4_acpi.c
index 8a71c3b450..36730da271 100644
--- a/sys/bus/smbus/ichiic/ig4_acpi.c
+++ b/sys/bus/smbus/ichiic/ig4_acpi.c
@@ -196,8 +196,7 @@ static device_method_t ig4iic_acpi_methods[] = {
 static driver_t ig4iic_acpi_driver = {
         "ig4iic",
         ig4iic_acpi_methods,
-        sizeof(struct ig4iic_softc),
-	.gpri = KOBJ_GPRI_ACPI+1
+        sizeof(struct ig4iic_softc)
 };
 
 static devclass_t ig4iic_acpi_devclass;
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index c8f5f71d53..ff42107fe7 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -140,9 +140,6 @@ static int	acpi_isa_pnp_probe(device_t bus, device_t child,
 		    struct isa_pnp_id *ids);
 static void	acpi_probe_children(device_t bus);
 static void	acpi_probe_order(ACPI_HANDLE handle, int *order);
-static void	acpi_disable_not_present(device_t child);
-static void	acpi_reprobe_children(device_t bus, device_t *children,
-		    int cnt);
 static ACPI_STATUS acpi_probe_child(ACPI_HANDLE handle, UINT32 level,
 		    void *context, void **status);
 static ACPI_STATUS acpi_EnterSleepState(struct acpi_softc *sc, int state);
@@ -217,7 +214,6 @@ static driver_t acpi_driver = {
     "acpi",
     acpi_methods,
     sizeof(struct acpi_softc),
-    .gpri = KOBJ_GPRI_ACPI+2
 };
 
 static devclass_t acpi_devclass;
@@ -881,9 +877,8 @@ acpi_driver_added(device_t dev, driver_t *driver)
 	child = devlist[i];
 	if (device_get_state(child) == DS_NOTPRESENT) {
 	    /* pci_set_powerstate(child, PCI_POWERSTATE_D0); */
-	    if (device_probe_and_attach(child) != 0) {
+	    if (device_probe_and_attach(child) != 0)
 		; /* pci_set_powerstate(child, PCI_POWERSTATE_D3); */
-	    }
 	}
     }
     kfree(devlist, M_TEMP);
@@ -952,9 +947,6 @@ acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
     case ACPI_IVAR_FLAGS:
 	*(int *)result = ad->ad_flags;
 	break;
-    case ACPI_IVAR_RECHECK:
-	*(int *)result = ad->ad_recheck;
-	break;
     case ISA_IVAR_VENDORID:
     case ISA_IVAR_SERIAL:
     case ISA_IVAR_COMPATID:
@@ -993,9 +985,6 @@ acpi_write_ivar(device_t dev, device_t child, int index, uintptr_t value)
     case ACPI_IVAR_FLAGS:
 	ad->ad_flags = (int)value;
 	break;
-    case ACPI_IVAR_RECHECK:
-	ad->ad_recheck = (int)value;
-	break;
     default:
 	panic("bad ivar write request (%d)", index);
 	return (ENOENT);
@@ -1653,8 +1642,6 @@ acpi_enable_pcie(void)
 static void
 acpi_probe_children(device_t bus)
 {
-    device_t *children;
-    int cnt;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
@@ -1670,8 +1657,6 @@ acpi_probe_children(device_t bus)
     ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "namespace scan\n"));
     AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 100,
 	acpi_probe_child, NULL, bus, NULL);
-    /* This gets us all the children that we added from the ACPI namespace. */
-    device_get_children(bus, &children, &cnt);
 
     /* Pre-allocate resources for our rman from any sysresource devices. */
     acpi_sysres_alloc(bus);
@@ -1681,25 +1666,13 @@ acpi_probe_children(device_t bus)
 
     /* Probe/attach all children, created staticly and from the namespace. */
     ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "first bus_generic_attach\n"));
-    bus_generic_attach_gpri(bus, KOBJ_GPRI_ACPI+2);
-    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "second bus_generic_attach\n"));
-    bus_generic_attach_gpri(bus, KOBJ_GPRI_ACPI+1);
-    /* Re-check device presence for previously disabled devices. */
-    acpi_reprobe_children(bus, children, cnt);
-    kfree(children, M_TEMP);
-    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "third bus_generic_attach\n"));
-    bus_generic_attach_gpri(bus, KOBJ_GPRI_ACPI);
-    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "fourth bus_generic_attach\n"));
-    bus_generic_attach_gpri(bus, KOBJ_GPRI_ACPI);
+    bus_generic_attach(bus);
 
     /*
      * Some of these children may have attached others as part of their attach
      * process (eg. the root PCI bus driver), so rescan.
      */
-    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "fifth bus_generic_attach\n"));
-    bus_generic_attach(bus);
-
-    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "sixth bus_generic_attach\n"));
+    ACPI_DEBUG_PRINT((ACPI_DB_OBJECTS, "second bus_generic_attach\n"));
     bus_generic_attach(bus);
 
     /* Attach wake sysctls. */
@@ -1734,49 +1707,6 @@ acpi_probe_order(ACPI_HANDLE handle, int *order)
 	*order = 100000;
 }
 
-/*
- * Flag a device as disabled, because it isn't present according to the
- * _STA method. We set the recheck instance-variable, to make sure that we
- * recheck the device presence at a later point.
- */
-static void
-acpi_disable_not_present(device_t child)
-{
-	device_disable(child);
-	acpi_set_recheck(child, 1);
-}
-
-/*
- * This rechecks the device presence for all the devices which were disabled
- * using acpi_disable_not_present().
- */
-static void
-acpi_reprobe_children(device_t bus, device_t *children, int cnt)
-{
-	int i;
-
-	for (i = 0; i < cnt; i++) {
-		device_t dev = children[i];
-
-		if (device_is_enabled(dev))
-			continue;
-
-		if (acpi_get_recheck(dev)) {
-			if (acpi_DeviceIsPresent(dev)) {
-				acpi_set_recheck(dev, 0);
-				device_enable(dev);
-				/*
-				 * Currently we parse the resources for every
-				 * device at the first time, when we see
-				 * that it is present.
-				 */
-				acpi_parse_resources(dev, acpi_get_handle(dev),
-				    &acpi_res_parse_set, NULL);
-			}
-		}
-	}
-}
-
 /*
  * Evaluate a child device and determine whether we might attach a device to
  * it.
@@ -1861,7 +1791,7 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status)
 		if (ACPI_SUCCESS(AcpiGetHandle(handle, "_DCK", &h)))
 		    break;
 
-		acpi_disable_not_present(child);
+		device_disable(child);
 		break;
 	    }
 
diff --git a/sys/dev/acpica/acpi_acad.c b/sys/dev/acpica/acpi_acad.c
index c59a93bb8e..1bfb3636b5 100644
--- a/sys/dev/acpica/acpi_acad.c
+++ b/sys/dev/acpica/acpi_acad.c
@@ -85,7 +85,6 @@ static driver_t acpi_acad_driver = {
     "acpi_acad",
     acpi_acad_methods,
     sizeof(struct acpi_acad_softc),
-    .gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t acpi_acad_devclass;
diff --git a/sys/dev/acpica/acpi_button.c b/sys/dev/acpica/acpi_button.c
index 3f46a9b5dd..69bf6c3cab 100644
--- a/sys/dev/acpica/acpi_button.c
+++ b/sys/dev/acpica/acpi_button.c
@@ -86,7 +86,6 @@ static driver_t acpi_button_driver = {
     "acpi_button",
     acpi_button_methods,
     sizeof(struct acpi_button_softc),
-    .gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t acpi_button_devclass;
diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c
index 1f636430be..d7a6dfc670 100644
--- a/sys/dev/acpica/acpi_cmbat.c
+++ b/sys/dev/acpica/acpi_cmbat.c
@@ -99,7 +99,6 @@ static driver_t acpi_cmbat_driver = {
     "battery",
     acpi_cmbat_methods,
     sizeof(struct acpi_cmbat_softc),
-    .gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t acpi_cmbat_devclass;
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index aa4136d4d2..c81e0bc978 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -94,8 +94,7 @@ static device_method_t acpi_cpu_methods[] = {
 static driver_t acpi_cpu_driver = {
     "cpu",
     acpi_cpu_methods,
-    sizeof(struct acpi_cpu_softc),
-    .gpri = KOBJ_GPRI_ACPI+2
+    sizeof(struct acpi_cpu_softc)
 };
 
 static devclass_t acpi_cpu_devclass;
diff --git a/sys/dev/acpica/acpi_cpu_cstate.c b/sys/dev/acpica/acpi_cpu_cstate.c
index 01efd97ad8..c7fedbd4f3 100644
--- a/sys/dev/acpica/acpi_cpu_cstate.c
+++ b/sys/dev/acpica/acpi_cpu_cstate.c
@@ -198,7 +198,6 @@ static driver_t acpi_cst_driver = {
     "cpu_cst",
     acpi_cst_methods,
     sizeof(struct acpi_cst_softc),
-    .gpri = KOBJ_GPRI_ACPI+2
 };
 
 static devclass_t acpi_cst_devclass;
diff --git a/sys/dev/acpica/acpi_cpu_pstate.c b/sys/dev/acpica/acpi_cpu_pstate.c
index 12b2e0e7c6..b72a5b02cb 100644
--- a/sys/dev/acpica/acpi_cpu_pstate.c
+++ b/sys/dev/acpica/acpi_cpu_pstate.c
@@ -224,8 +224,7 @@ static device_method_t acpi_pst_methods[] = {
 static driver_t acpi_pst_driver = {
 	"cpu_pst",
 	acpi_pst_methods,
-	sizeof(struct acpi_pst_softc),
-	.gpri = KOBJ_GPRI_ACPI+2
+	sizeof(struct acpi_pst_softc)
 };
 
 static devclass_t acpi_pst_devclass;
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c
index d586376507..d386eb82d9 100644
--- a/sys/dev/acpica/acpi_ec.c
+++ b/sys/dev/acpica/acpi_ec.c
@@ -291,7 +291,6 @@ static driver_t acpi_ec_driver = {
     "acpi_ec",
     acpi_ec_methods,
     sizeof(struct acpi_ec_softc),
-    .gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t acpi_ec_devclass;
diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c
index 388ae8298e..613dbfe294 100644
--- a/sys/dev/acpica/acpi_hpet.c
+++ b/sys/dev/acpica/acpi_hpet.c
@@ -98,7 +98,6 @@ static driver_t acpi_hpet_driver = {
 	"acpi_hpet",
 	acpi_hpet_methods,
 	sizeof(struct acpi_hpet_softc),
-	.gpri = KOBJ_GPRI_ACPI+2
 };
 
 static devclass_t acpi_hpet_devclass;
diff --git a/sys/dev/acpica/acpi_isab.c b/sys/dev/acpica/acpi_isab.c
index e69cc0bc90..748e1a7c54 100644
--- a/sys/dev/acpica/acpi_isab.c
+++ b/sys/dev/acpica/acpi_isab.c
@@ -83,7 +83,6 @@ static driver_t acpi_isab_driver = {
 	"isab",
 	acpi_isab_methods,
 	sizeof(struct acpi_isab_softc),
-	.gpri = KOBJ_GPRI_ACPI+2
 };
 
 DRIVER_MODULE(acpi_isab, acpi, acpi_isab_driver, isab_devclass, NULL, NULL);
diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c
index 1125ba2d82..fb5f2aeb20 100644
--- a/sys/dev/acpica/acpi_lid.c
+++ b/sys/dev/acpica/acpi_lid.c
@@ -77,7 +77,6 @@ static driver_t acpi_lid_driver = {
     "acpi_lid",
     acpi_lid_methods,
     sizeof(struct acpi_lid_softc),
-    .gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t acpi_lid_devclass;
diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c
index ad637fdfa5..80ddceb0ae 100644
--- a/sys/dev/acpica/acpi_pci_link.c
+++ b/sys/dev/acpica/acpi_pci_link.c
@@ -1113,7 +1113,6 @@ static driver_t acpi_pci_link_driver = {
 	"pci_link",
 	acpi_pci_link_methods,
 	sizeof(struct acpi_pci_link_softc),
-	.gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t pci_link_devclass;
diff --git a/sys/dev/acpica/acpi_resource.c b/sys/dev/acpica/acpi_resource.c
index e689932448..c5cf8add9f 100644
--- a/sys/dev/acpica/acpi_resource.c
+++ b/sys/dev/acpica/acpi_resource.c
@@ -661,7 +661,6 @@ static driver_t acpi_sysres_driver = {
     "acpi_sysresource",
     acpi_sysres_methods,
     0,
-    .gpri = KOBJ_GPRI_ACPI+2
 };
 
 static devclass_t acpi_sysres_devclass;
diff --git a/sys/dev/acpica/acpi_smbat.c b/sys/dev/acpica/acpi_smbat.c
index 37672d205d..545e218e9f 100644
--- a/sys/dev/acpica/acpi_smbat.c
+++ b/sys/dev/acpica/acpi_smbat.c
@@ -94,7 +94,6 @@ static driver_t	acpi_smbat_driver = {
 	"battery",
 	acpi_smbat_methods,
 	sizeof(struct acpi_smbat_softc),
-	.gpri = KOBJ_GPRI_ACPI
 };
 
 static devclass_t acpi_smbat_devclass;
diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/acpi_thermal.c
index 12a91aa436..81accd4d16 100644
--- a/sys/dev/acpica/acpi_thermal.c
+++ b/sys/dev/acpica/acpi_thermal.c
@@ -167,7 +167,6 @@ static driver_t acpi_tz_driver = {
     "acpi_tz",
     acpi_tz_methods,
     sizeof(struct acpi_tz_softc),
-    .gpri = KOBJ_GPRI_ACPI
 };
 
 static char *acpi_tz_tmp_name = "_TMP";
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index 3198672090..83da56f97f 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -93,7 +93,6 @@ static driver_t acpi_timer_driver = {
     "acpi_timer",
     acpi_timer_methods,
     0,
-    .gpri = KOBJ_GPRI_ACPI+2
 };
 
 static devclass_t acpi_timer_devclass;
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index a9b8393da2..b683eb34df 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -95,7 +95,6 @@ struct acpi_device {
     uintptr_t			ad_magic;
     void			*ad_private;
     int				ad_flags;
-    int				ad_recheck;	/* Should re-check presence. */
 
     /* Resources */
     struct resource_list	ad_rl;
@@ -247,7 +246,6 @@ extern int	acpi_quirks;
 #define ACPI_IVAR_MAGIC		0x101
 #define ACPI_IVAR_PRIVATE	0x102
 #define ACPI_IVAR_FLAGS		0x103
-#define ACPI_IVAR_RECHECK	0x104
 
 /*
  * Accessor functions for our ivars.  Default value for BUS_READ_IVAR is
@@ -274,7 +272,6 @@ __ACPI_BUS_ACCESSOR(acpi, handle, ACPI, HANDLE, ACPI_HANDLE)
 __ACPI_BUS_ACCESSOR(acpi, magic, ACPI, MAGIC, uintptr_t)
 __ACPI_BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *)
 __ACPI_BUS_ACCESSOR(acpi, flags, ACPI, FLAGS, int)
-__ACPI_BUS_ACCESSOR(acpi, recheck, ACPI, RECHECK, int)
 
 void acpi_fake_objhandler(ACPI_HANDLE h, void *data);
 static __inline device_t
diff --git a/sys/dev/disk/sdhci/sdhci_acpi.c b/sys/dev/disk/sdhci/sdhci_acpi.c
index 9f50290565..ce838168d0 100644
--- a/sys/dev/disk/sdhci/sdhci_acpi.c
+++ b/sys/dev/disk/sdhci/sdhci_acpi.c
@@ -353,7 +353,6 @@ static driver_t sdhci_acpi_driver = {
 	"sdhci_acpi",
 	sdhci_methods,
 	sizeof(struct sdhci_acpi_softc),
-	.gpri = KOBJ_GPRI_ACPI
 };
 static devclass_t sdhci_acpi_devclass;
 
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 9767402e08..9e35d667b5 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -1236,10 +1236,9 @@ device_add_child_ordered(device_t dev, int order, const char *name, int unit)
 		return child;
 	child->order = order;
 
-	TAILQ_FOREACH(place, &dev->children, link) {
+	TAILQ_FOREACH(place, &dev->children, link)
 		if (place->order > order)
 			break;
-	}
 
 	if (place) {
 		/*
@@ -1396,7 +1395,7 @@ device_probe_child(device_t dev, device_t child)
 		return(0);
 
 	for (; dc; dc = dc->parent) {
-		for (dl = first_matching_driver(dc, child); dl;
+    		for (dl = first_matching_driver(dc, child); dl;
 		     dl = next_matching_driver(dc, child, dl)) {
 			PDEBUG(("Trying %s", DRIVERNAME(dl->driver)));
 			device_set_driver(child, dl->driver);
@@ -1425,101 +1424,6 @@ device_probe_child(device_t dev, device_t child)
 				continue;
 			}
 
-			/*
-			 * A priority lower than SUCCESS, remember the
-			 * best matching driver. Initialise the value
-			 * of pri for the first match.
-			 */
-			if (best == NULL || result > pri) {
-				best = dl;
-				pri = result;
-				continue;
-			}
-		}
-		/*
-	         * If we have unambiguous match in this devclass,
-	         * don't look in the parent.
-	         */
-	        if (best && pri == 0)
-			break;
-	}
-
-	/*
-	 * If we found a driver, change state and initialise the devclass.
-	 */
-	if (best) {
-		if (!child->devclass)
-			device_set_devclass(child, best->driver->name);
-		device_set_driver(child, best->driver);
-		if (pri < 0) {
-			/*
-			 * A bit bogus. Call the probe method again to make
-			 * sure that we have the right description.
-			 */
-			DEVICE_PROBE(child);
-		}
-
-		bus_data_generation_update();
-		child->state = DS_ALIVE;
-		return(0);
-	}
-
-	return(ENXIO);
-}
-
-int
-device_probe_child_gpri(device_t dev, device_t child, u_int gpri)
-{
-	devclass_t dc;
-	driverlink_t best = NULL;
-	driverlink_t dl;
-	int result, pri = 0;
-	int hasclass = (child->devclass != NULL);
-
-	dc = dev->devclass;
-	if (!dc)
-		panic("device_probe_child: parent device has no devclass");
-
-	if (child->state == DS_ALIVE)
-		return(0);
-
-	for (; dc; dc = dc->parent) {
-		for (dl = first_matching_driver(dc, child); dl;
-			dl = next_matching_driver(dc, child, dl)) {
-			/*
-			 * GPRI handling, only probe drivers with the
-			 * specific GPRI.
-			 */
-			if (dl->driver->gpri != gpri)
-				continue;
-
-			PDEBUG(("Trying %s", DRIVERNAME(dl->driver)));
-			device_set_driver(child, dl->driver);
-			if (!hasclass)
-				device_set_devclass(child, dl->driver->name);
-			result = DEVICE_PROBE(child);
-			if (!hasclass)
-				device_set_devclass(child, 0);
-
-			/*
-			 * If the driver returns SUCCESS, there can be
-			 * no higher match for this device.
-			 */
-			if (result == 0) {
-				best = dl;
-				pri = 0;
-				break;
-			}
-
-			/*
-			 * The driver returned an error so it
-			 * certainly doesn't match.
-			 */
-			if (result > 0) {
-				device_set_driver(child, NULL);
-				continue;
-			}
-
 			/*
 			 * A priority lower than SUCCESS, remember the
 			 * best matching driver. Initialise the value
@@ -1536,7 +1440,7 @@ device_probe_child_gpri(device_t dev, device_t child, u_int gpri)
 	         * don't look in the parent.
 	         */
 	        if (best && pri == 0)
-			break;
+	    	        break;
 	}
 
 	/*
@@ -1950,62 +1854,6 @@ device_probe_and_attach(device_t dev)
 	return(error);
 }
 
-int
-device_probe_and_attach_gpri(device_t dev, u_int gpri)
-{
-	device_t bus = dev->parent;
-	int error = 0;
-
-	if (dev->state >= DS_ALIVE)
-		return(0);
-
-	if ((dev->flags & DF_ENABLED) == 0) {
-		if (bootverbose) {
-			device_print_prettyname(dev);
-			kprintf("not probed (disabled)\n");
-		}
-		return(0);
-	}
-
-	error = device_probe_child_gpri(bus, dev, gpri);
-	if (error) {
-#if 0
-		if (!(dev->flags & DF_DONENOMATCH)) {
-			BUS_PROBE_NOMATCH(bus, dev);
-			devnomatch(dev);
-			dev->flags |= DF_DONENOMATCH;
-		}
-#endif
-		return(error);
-	}
-
-	/*
-	 * Output the exact device chain prior to the attach in case the
-	 * system locks up during attach, and generate the full info after
-	 * the attach so correct irq and other information is displayed.
-	 */
-	if (bootverbose && !device_is_quiet(dev)) {
-		device_t tmp;
-
-		kprintf("%s", device_get_nameunit(dev));
-		for (tmp = dev->parent; tmp; tmp = tmp->parent)
-			kprintf(".%s", device_get_nameunit(tmp));
-		kprintf("\n");
-	}
-	if (!device_is_quiet(dev))
-		device_print_child(bus, dev);
-	if ((dev->flags & DF_ASYNCPROBE) && do_async_attach) {
-		kprintf("%s: probing asynchronously\n",
-			device_get_nameunit(dev));
-		dev->state = DS_INPROGRESS;
-		device_attach_async(dev);
-		error = 0;
-	} else {
-		error = device_doattach(dev);
-	}
-	return(error);
-}
-
 /*
  * Device is known to be alive, do the attach asynchronously.
  * However, serialize the attaches with the mp lock.
@@ -2787,18 +2635,6 @@ bus_generic_attach(device_t dev)
 	return(0);
 }
 
-int
-bus_generic_attach_gpri(device_t dev, u_int gpri)
-{
-	device_t child;
-
-	TAILQ_FOREACH(child, &dev->children, link) {
-		device_probe_and_attach_gpri(child, gpri);
-	}
-
-	return(0);
-}
-
 int
 bus_generic_detach(device_t dev)
 {
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index e614b2314c..7f09ebb78d 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -245,7 +245,6 @@ struct resource_list *
 int     bus_generic_config_intr(device_t, device_t, int, enum intr_trigger,
 					enum intr_polarity);
 int	bus_generic_attach(device_t dev);
-int	bus_generic_attach_gpri(device_t dev, u_int gpri);
 int	bus_generic_child_present(device_t dev, device_t child);
 int	bus_generic_deactivate_resource(device_t dev, device_t child, int type,
 					int rid, struct resource *r);
@@ -384,9 +383,7 @@ int	device_is_quiet(device_t dev);
 int	device_print_prettyname(device_t dev);
 int	device_printf(device_t dev, const char *, ...) __printflike(2, 3);
 int	device_probe_and_attach(device_t dev);
-int	device_probe_and_attach_gpri(device_t dev, u_int gpri);
 int	device_probe_child(device_t dev, device_t child);
-int	device_probe_child_gpri(device_t dev, device_t child, u_int gpri);
 void	device_quiet(device_t dev);
 void	device_set_desc(device_t dev, const char* desc);
 void	device_set_desc_copy(device_t dev, const char* desc);
diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h
index e023fc9358..d002baed02 100644
--- a/sys/sys/kobj.h
+++ b/sys/sys/kobj.h
@@ -65,8 +65,7 @@ struct kobj_method {
 	size_t		size;		/* object size */		\
 	kobj_class_t	*baseclasses;	/* base classes */		\
 	u_int		refs;		/* reference count */		\
-	kobj_ops_t	ops;		/* compiled method table */	\
-	u_int		gpri		/* global probe/attach pri */
+	kobj_ops_t	ops		/* compiled method table */
 
 struct kobj_class {
 	KOBJ_CLASS_FIELDS;
@@ -82,14 +81,6 @@ struct kobj {
 	KOBJ_FIELDS;
 };
 
-/*
- * gpri values (higher values probe/attach first, allows us to
- * default the field to 0).
- */
-#define KOBJ_GPRI_ACPI		0x00FFU
-#define KOBJ_GPRI_LAST		0x0000U
-#define KOBJ_GPRI_DEFAULT	KOBJ_GPRI_LAST
-
 /*
  * The ops table is used as a cache of results from kobj_lookup_method().
  */
-- 
2.15.1

