Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jul 2006 20:32:14 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 101799 for review
Message-ID:  <200607172032.k6HKWEnY041477@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=101799

Change 101799 by imp@imp_lighthouse on 2006/07/17 20:31:52

	Allow hinted/reserved devices to block only non-hinting
	scenarios.  For a hinted scenario, a reservation doesn't block
	anything, but an actual device does.

Affected files ...

.. //depot/projects/arm/src/sys/kern/subr_bus.c#14 edit

Differences ...

==== //depot/projects/arm/src/sys/kern/subr_bus.c#14 (text+ko) ====

@@ -1286,13 +1286,14 @@
  * @param dc		the devclass to allocate from
  * @param unitp		points at the location for the allocated unit
  *			number
+ * @param reservedok	Allow allocation of a hinted/reserved unit
  *
  * @retval 0		success
  * @retval EEXIST	the requested unit number is already allocated
  * @retval ENOMEM	memory allocation failure
  */
 static int
-devclass_alloc_unit(devclass_t dc, int *unitp)
+devclass_alloc_unit(devclass_t dc, int *unitp, int reservedok)
 {
 	int unit = *unitp;
 	const char *where;
@@ -1318,7 +1319,7 @@
 		 */
 		unit = 0;
 		while ((unit < dc->maxunit && dc->devices[unit] != NULL) ||
-		    resource_string_value(dc->name, unit, "at", &where) == 0)
+		    (!reservedok && resource_string_value(dc->name, unit, "at", &where) == 0))
 			unit++;
 	}
 
@@ -1360,13 +1361,14 @@
  *
  * @param dc		the devclass to add to
  * @param dev		the device to add
+ * @param reservedok	Allocating reserved, but not busy, units is ok.
  *
  * @retval 0		success
  * @retval EEXIST	the requested unit number is already allocated
  * @retval ENOMEM	memory allocation failure
  */
 static int
-devclass_add_device(devclass_t dc, device_t dev)
+devclass_add_device(devclass_t dc, device_t dev, int reservedok)
 {
 	int buflen, error;
 
@@ -1379,7 +1381,7 @@
 	if (!dev->nameunit)
 		return (ENOMEM);
 
-	if ((error = devclass_alloc_unit(dc, &dev->unit)) != 0) {
+	if ((error = devclass_alloc_unit(dc, &dev->unit, reservedok)) != 0) {
 		free(dev->nameunit, M_BUS);
 		dev->nameunit = NULL;
 		return (error);
@@ -1474,7 +1476,7 @@
 		dev->flags |= DF_WILDCARD;
 	if (name) {
 		dev->flags |= DF_FIXEDCLASS;
-		if (devclass_add_device(dc, dev)) {
+		if (devclass_add_device(dc, dev, 0)) {
 			kobj_delete((kobj_t) dev, M_BUS);
 			return (NULL);
 		}
@@ -1733,7 +1735,7 @@
 					if (childdc->devices[unit] != NULL)
 						continue;
 					child->unit = unit;
-					devclass_add_device(childdc, child);
+					devclass_add_device(childdc, child, 1);
 				}
 			}
 			/* Fetch any flags for the device before probing. */
@@ -1822,7 +1824,7 @@
 				childdc = child->devclass;
 				devclass_delete_device(childdc, child);
 				child->unit = unit;
-				devclass_add_device(childdc, child);
+				devclass_add_device(childdc, child, 1);
 			}
 		}
 		resource_int_value(best->driver->name, child->unit,
@@ -2272,7 +2274,7 @@
 	if (!dc)
 		return (ENOMEM);
 
-	error = devclass_add_device(dc, dev);
+	error = devclass_add_device(dc, dev, 0); // XXXimp: right?
 
 	bus_data_generation_update();
 	return (error);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607172032.k6HKWEnY041477>