Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Jul 2007 21:08:00 GMT
From:      Maxim Zhuravlev <thioretic@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 123752 for review
Message-ID:  <200707192108.l6JL80dv051973@repoman.freebsd.org>

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

Change 123752 by thioretic@thioretic on 2007/07/19 21:06:59

	Functional devices shouldn't be removed on dev->refs==0
		They should become children on root_bus.

Affected files ...

.. //depot/projects/soc2007/thioretic_gidl/kern/subr_bus.c#18 edit

Differences ...

==== //depot/projects/soc2007/thioretic_gidl/kern/subr_bus.c#18 (text+ko) ====

@@ -168,6 +168,7 @@
 #define	DF_QUIET	16		/* don't print verbose attach message */
 #define	DF_DONENOMATCH	32		/* don't execute DEVICE_NOMATCH again */
 #define	DF_REBID	128		/* Can rebid after attach */
+#define DF_PERSISTENT	256		/* Should not delete when refs == 0*/
 	u_char	order;			/**< order from device_add_child_ordered() */
 	u_char	pad;
 	void	*ivars;			/**< instance variables  */
@@ -2232,7 +2233,7 @@
 		free (grand);
 	}
 
-/*!!!*/	if ((error = device_detach(devtodel)) != 0)
+	if (!(devtodel->flags & DF_PERSISTENT) && ((error = device_detach(devtodel)) != 0))
 		return (error);
 	if (devtodel->devclass)
 		devclass_delete_device(devtodel->devclass, devtodel);
@@ -2246,8 +2247,13 @@
 		}
 	}
 
+	if (devtodel->flags & DF_PERSISTENT){
+		device_add_existing_parent(dev, root_bus);
+		return (0);
+	}
+
 	if (devtodel->refs) 
-		return (0);
+		return (1);
 
 	TAILQ_REMOVE(&bus_data_devices, devtodel, devlink);
 	kobj_delete((kobj_t) devtodel, M_BUS);
@@ -4664,6 +4670,7 @@
 	char* parents[];
 	int count=0, isfilter, devcount;
 	device_t dev, *devices;
+	u_int32_t flags;
 
 	dmd = (struct driver_module_data *)arg;
 	drv_intnl = dmd->dmd_driver;
@@ -4705,19 +4712,19 @@
 				    parentname, TRUE, FALSE);
 		} else {
 			*dmd->dmd_devclass =
-				devclass_find_internal(driver->name, 0, TRUE, FALSR);
+				devclass_find_internal(driver->name, 0, TRUE, FALSE);
 		}
 
-		if(drv_intnl->flags & DR_REQDEV){ /*restrict to DR_LOWEST? */
+		if(drv_intnl->flags & (DR_REQDEV|DR_LOWEST)){
 			dev = make_device (root_bus, DRIVERNAME(driver), -1);
 			device_set_driver(dev, driver);
-			/*if (!hasclass)*/
 			device_set_devclass(dev, driver->name);
 
 			/* Fetch any flags for the device before probing.
 			resource_int_value(dl->driver->name, child->unit,
 			    "flags", &child->devflags);
 			*/
+			dev->flags |= DF_PERSISTENT;
 			count = 0;
 			while (parents[count]){
 				if (!(parent_devclass = devclass_find(parents[count++])))
@@ -4727,12 +4734,9 @@
 					device_add_existing_parent(dev, devices[i]);
 				}
 			}
-			
 			result = DEVICE_PROBE(dev);
-
 			if(result <= 0)
 				device_attach(dev);
-			/*overwise the device is to be destroyed by now*/
 		}
 
 		break;



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