> Doesn't seem like an ideal thing to do from a stack space POV either.> > Would it be possible to break at the second scan, that is the device> probe and stick that into a workqueue or something. Then we'd only ever> have driver->device nesting.

Alan and Oliver have done some work in this area I think, combined withthe suspend/bind/unbind issues. I'll let them comment on your patch :)

if (dev) device_unregister(dev);Index: linux-2.6-2/drivers/base/dd.c===================================================================--- linux-2.6-2.orig/drivers/base/dd.c+++ linux-2.6-2/drivers/base/dd.c@@ -82,7 +82,7 @@ static void driver_sysfs_remove(struct d * for before calling this. (It is ok to call with no other effort * from a driver's probe() method.) *- * This function must be called with @dev->sem held.+ * This function must be called with @dev->mutex held. */ int device_bind_driver(struct device *dev) {@@ -180,8 +180,8 @@ int driver_probe_done(void) * This function returns 1 if a match is found, -ENODEV if the device is * not registered, and 0 otherwise. *- * This function must be called with @dev->sem held. When called for a- * USB interface, @dev->parent->sem must be held as well.+ * This function must be called with @dev->mutex held. When called for a+ * USB interface, @dev->parent->mutex must be held as well. */ int driver_probe_device(struct device_driver * drv, struct device * dev) {@@ -219,13 +219,13 @@ static int __device_attach(struct device * 0 if no matching device was found; * -ENODEV if the device is not registered. *- * When called for a USB interface, @dev->parent->sem must be held.+ * When called for a USB interface, @dev->parent->mutex must be held. */ int device_attach(struct device * dev) { int ret = 0;

/*- * __device_release_driver() must be called with @dev->sem held.- * When called for a USB interface, @dev->parent->sem must be held as well.+ * __device_release_driver() must be called with @dev->mutex held.+ * When called for a USB interface, @dev->parent->mutex must be held as well. */ static void __device_release_driver(struct device * dev) {@@ -315,7 +315,7 @@ static void __device_release_driver(stru * @dev: device. * * Manually detach device from driver.- * When called for a USB interface, @dev->parent->sem must be held.+ * When called for a USB interface, @dev->parent->mutex must be held. */ void device_release_driver(struct device * dev) {@@ -324,9 +324,9 @@ void device_release_driver(struct device * within their ->remove callback for the same device, they * will deadlock right here. */- down(&dev->sem);+ mutex_lock_nested(&dev->mutex, DEVICE_NORMAL); __device_release_driver(dev);- up(&dev->sem);+ mutex_unlock(&dev->mutex); }

/* release the resources so that other devices can use them */- down(&pnp_res_mutex);+ mutex_lock(&pnp_res_mutex); pnp_clean_resource_table(&dev->res);- up(&pnp_res_mutex);+ mutex_unlock(&pnp_res_mutex);

/* All 4 notifers below get called with the target struct device * * as an argument. Note that those functions are likely to be called- * with the device semaphore held in the core, so be careful.+ * with the device mutex held in the core, so be careful. */ #define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */ #define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */@@ -137,7 +137,6 @@ struct device_driver { int (*resume) (struct device * dev); };