--- entry.c.orig	Sun Apr  2 04:21:53 2006
+++ entry.c	Sun Apr  2 05:07:08 2006
@@ -1905,5 +1905,5 @@
 {
 	IAL_ADAPTER_T * pAdapter = device_get_softc(dev);
-	int rid;
+	int rid, dev_unit;
 	union ccb *ccb;
 	struct cam_devq *devq;
@@ -1999,12 +1999,18 @@
 	free(ccb, M_DEVBUF);
 
-	/* Register shutdown handler, and start the work thread. */
-	if (device_get_unit(dev) == 0) {
-		pAdapter->eh = EVENTHANDLER_REGISTER(shutdown_final, 
-			hpt_shutdown, dev, SHUTDOWN_PRI_DEFAULT);
-		if (pAdapter->eh)
-			launch_worker_thread();
+	/* Register shutdown handler */
+	dev_unit = device_get_unit(dev);
+	pAdapter->eh = EVENTHANDLER_REGISTER(shutdown_final, hpt_shutdown, dev, SHUTDOWN_PRI_DEFAULT);
+	if ( ! pAdapter->eh) {
+		if ( 0 == dev_unit )
+			hpt_printk(("shutdown event registration failed dev %d ( no work thread started )\n", dev_unit ));
 		else
-			hpt_printk(("shutdown event registration failed\n"));
+			hpt_printk(("shutdown event registration failed dev %d\n", dev_unit ));
+	}
+	else if ( 0 == dev_unit ) {
+		// Note: No worker thread will be started if subsiquent shutdown
+		// registrations succeed after unit 0 failure this may be a bug
+		// but at least the user will have some indication of the failure
+		launch_worker_thread();
 	}
 
@@ -2076,5 +2082,5 @@
 	int i;
 
-	hpt_printk(("flush all devices\n"));
+	hpt_printk(("flushing unit %d devices\n", device_get_unit(pAdapter->hpt_dev) ));
 	
 	/* flush all devices */
@@ -2088,16 +2094,16 @@
 hpt_shutdown(device_t dev)
 {
-		IAL_ADAPTER_T *pAdapter;
+	IAL_ADAPTER_T *pAdapter;
 	
-		pAdapter = device_get_softc(dev);
-		if (pAdapter == NULL)
-			return (EINVAL);
-
-		EVENTHANDLER_DEREGISTER(shutdown_final, pAdapter->eh);
-		FlushAdapter(pAdapter);
-		  /* give the flush some time to happen, 
-		    *otherwise "shutdown -p now" will make file system corrupted */
-		DELAY(1000 * 1000 * 5);
-		return 0;
+	pAdapter = device_get_softc(dev);
+	if (pAdapter == NULL)
+		return (EINVAL);
+
+	EVENTHANDLER_DEREGISTER(shutdown_final, pAdapter->eh);
+	FlushAdapter(pAdapter);
+	/* give the flush some time to happen, 
+	 * otherwise "shutdown -p now" will make file system corrupted */
+	DELAY(1000 * 1000 * 5);
+	return 0;
 }
 
