summaryrefslogtreecommitdiffstats
path: root/drivers/uwb/umc-bus.c
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@csr.com>2008-11-07 17:37:33 +0000
committerDavid Vrabel <david.vrabel@csr.com>2008-11-07 17:37:33 +0000
commit307ba6dd73254fe7d2ce27db64ffd90e1bb3c6c0 (patch)
tree535e10e6bd399c1f1d1f55a546e0c6aa92ba9dee /drivers/uwb/umc-bus.c
parentfec1a5932f16c0eb1b3f5ca2e18d81d860924088 (diff)
downloadlinux-307ba6dd73254fe7d2ce27db64ffd90e1bb3c6c0.tar.bz2
uwb: don't unbind the radio controller driver when resetting
Use pre_reset and post_reset methods to avoid unbinding the radio controller driver after a uwb_rc_reset_all() call. This avoids a deadlock in uwb_rc_rm() when waiting for the uwb event thread to stop. Signed-off-by: David Vrabel <david.vrabel@csr.com>
Diffstat (limited to 'drivers/uwb/umc-bus.c')
-rw-r--r--drivers/uwb/umc-bus.c62
1 files changed, 43 insertions, 19 deletions
diff --git a/drivers/uwb/umc-bus.c b/drivers/uwb/umc-bus.c
index 2d8d62d9f53e..5ad36164c13b 100644
--- a/drivers/uwb/umc-bus.c
+++ b/drivers/uwb/umc-bus.c
@@ -11,23 +11,48 @@
#include <linux/uwb/umc.h>
#include <linux/pci.h>
-static int umc_bus_unbind_helper(struct device *dev, void *data)
+static int umc_bus_pre_reset_helper(struct device *dev, void *data)
{
- struct device *parent = data;
+ int ret = 0;
- if (dev->parent == parent && dev->driver)
- device_release_driver(dev);
- return 0;
+ if (dev->driver) {
+ struct umc_dev *umc = to_umc_dev(dev);
+ struct umc_driver *umc_drv = to_umc_driver(dev->driver);
+
+ if (umc_drv->pre_reset)
+ ret = umc_drv->pre_reset(umc);
+ else
+ device_release_driver(dev);
+ }
+ return ret;
+}
+
+static int umc_bus_post_reset_helper(struct device *dev, void *data)
+{
+ int ret = 0;
+
+ if (dev->driver) {
+ struct umc_dev *umc = to_umc_dev(dev);
+ struct umc_driver *umc_drv = to_umc_driver(dev->driver);
+
+ if (umc_drv->post_reset)
+ ret = umc_drv->post_reset(umc);
+ } else
+ ret = device_attach(dev);
+
+ return ret;
}
/**
* umc_controller_reset - reset the whole UMC controller
* @umc: the UMC device for the radio controller.
*
- * Drivers will be unbound from all UMC devices belonging to the
- * controller and then the radio controller will be rebound. The
- * radio controller is expected to do a full hardware reset when it is
- * probed.
+ * Drivers or all capabilities of the controller will have their
+ * pre_reset methods called or be unbound from their device. Then all
+ * post_reset methods will be called or the drivers will be rebound.
+ *
+ * Radio controllers must provide pre_reset and post_reset methods and
+ * reset the hardware in their start method.
*
* If this is called while a probe() or remove() is in progress it
* will return -EAGAIN and not perform the reset.
@@ -35,14 +60,13 @@ static int umc_bus_unbind_helper(struct device *dev, void *data)
int umc_controller_reset(struct umc_dev *umc)
{
struct device *parent = umc->dev.parent;
- int ret;
+ int ret = 0;
- if (down_trylock(&parent->sem))
+ if(down_trylock(&parent->sem))
return -EAGAIN;
- bus_for_each_dev(&umc_bus_type, NULL, parent, umc_bus_unbind_helper);
- ret = device_attach(&umc->dev);
- if (ret == 1)
- ret = 0;
+ ret = device_for_each_child(parent, parent, umc_bus_pre_reset_helper);
+ if (ret >= 0)
+ device_for_each_child(parent, parent, umc_bus_post_reset_helper);
up(&parent->sem);
return ret;
@@ -75,10 +99,10 @@ static int umc_bus_rescan_helper(struct device *dev, void *data)
if (!dev->driver)
ret = device_attach(dev);
- return ret < 0 ? ret : 0;
+ return ret;
}
-static void umc_bus_rescan(void)
+static void umc_bus_rescan(struct device *parent)
{
int err;
@@ -86,7 +110,7 @@ static void umc_bus_rescan(void)
* We can't use bus_rescan_devices() here as it deadlocks when
* it tries to retake the dev->parent semaphore.
*/
- err = bus_for_each_dev(&umc_bus_type, NULL, NULL, umc_bus_rescan_helper);
+ err = device_for_each_child(parent, NULL, umc_bus_rescan_helper);
if (err < 0)
printk(KERN_WARNING "%s: rescan of bus failed: %d\n",
KBUILD_MODNAME, err);
@@ -120,7 +144,7 @@ static int umc_device_probe(struct device *dev)
if (err)
put_device(dev);
else
- umc_bus_rescan();
+ umc_bus_rescan(dev->parent);
return err;
}