Skip to content

Commit

Permalink
xen: fix is_disconnected_device/exists_disconnected_device
Browse files Browse the repository at this point in the history
The logic of is_disconnected_device/exists_disconnected_device is wrong
in that they are used to test whether a device is trying to connect (i.e.
connecting).  For this reason the patch fixes them to not consider a
Closing or Closed device to be connecting.  At the same time the patch
also renames the functions according to what they really do; you could
say a closed device is "disconnected" (the old name), but not "connecting"
(the new name).

This patch is a backport of changeset 909 from the Xenbits tree.

Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
  • Loading branch information
Paolo Bonzini authored and Jeremy Fitzhardinge committed Dec 3, 2009
1 parent db05fed commit c6e1971
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/xen/xenbus/xenbus_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ postcore_initcall(xenbus_probe_init);

MODULE_LICENSE("GPL");

static int is_disconnected_device(struct device *dev, void *data)
static int is_device_connecting(struct device *dev, void *data)
{
struct xenbus_device *xendev = to_xenbus_device(dev);
struct device_driver *drv = data;
Expand All @@ -861,14 +861,15 @@ static int is_disconnected_device(struct device *dev, void *data)
return 0;

xendrv = to_xenbus_driver(dev->driver);
return (xendev->state != XenbusStateConnected ||
(xendrv->is_ready && !xendrv->is_ready(xendev)));
return (xendev->state < XenbusStateConnected ||
(xendev->state == XenbusStateConnected &&
xendrv->is_ready && !xendrv->is_ready(xendev)));
}

static int exists_disconnected_device(struct device_driver *drv)
static int exists_connecting_device(struct device_driver *drv)
{
return bus_for_each_dev(&xenbus_frontend.bus, NULL, drv,
is_disconnected_device);
is_device_connecting);
}

static int print_device_status(struct device *dev, void *data)
Expand Down Expand Up @@ -918,7 +919,7 @@ static void wait_for_devices(struct xenbus_driver *xendrv)
if (!ready_to_wait_for_devices || !xen_domain())
return;

while (exists_disconnected_device(drv)) {
while (exists_connecting_device(drv)) {
if (time_after(jiffies, timeout))
break;
schedule_timeout_interruptible(HZ/10);
Expand Down

0 comments on commit c6e1971

Please sign in to comment.