lguest: fix for CONFIG_SPARSE_IRQ=y
[safe/jmp/linux-2.6] / drivers / lguest / lguest_device.c
index b02f6bc..8132533 100644 (file)
@@ -212,6 +212,9 @@ static void lg_notify(struct virtqueue *vq)
        hcall(LHCALL_NOTIFY, lvq->config.pfn << PAGE_SHIFT, 0, 0);
 }
 
+/* An extern declaration inside a C file is bad form.  Don't do it. */
+extern void lguest_setup_irq(unsigned int irq);
+
 /* This routine finds the first virtqueue described in the configuration of
  * this device and sets it up.
  *
@@ -266,13 +269,16 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
                goto unmap;
        }
 
+       /* Make sure the interrupt is allocated. */
+       lguest_setup_irq(lvq->config.irq);
+
        /* Tell the interrupt for this virtqueue to go to the virtio_ring
         * interrupt handler. */
        /* FIXME: We used to have a flag for the Host to tell us we could use
         * the interrupt as a source of randomness: it'd be nice to have that
         * back.. */
        err = request_irq(lvq->config.irq, vring_interrupt, IRQF_SHARED,
-                         vdev->dev.bus_id, vq);
+                         dev_name(&vdev->dev), vq);
        if (err)
                goto destroy_vring;
 
@@ -321,10 +327,7 @@ static struct virtio_config_ops lguest_config_ops = {
 
 /* The root device for the lguest virtio devices.  This makes them appear as
  * /sys/devices/lguest/0,1,2 not /sys/devices/0,1,2. */
-static struct device lguest_root = {
-       .parent = NULL,
-       .bus_id = "lguest",
-};
+static struct device *lguest_root;
 
 /*D:120 This is the core of the lguest bus: actually adding a new device.
  * It's a separate function because it's neater that way, and because an
@@ -351,7 +354,7 @@ static void add_lguest_device(struct lguest_device_desc *d,
        }
 
        /* This devices' parent is the lguest/ dir. */
-       ldev->vdev.dev.parent = &lguest_root;
+       ldev->vdev.dev.parent = lguest_root;
        /* We have a unique device index thanks to the dev_index counter. */
        ldev->vdev.id.device = d->type;
        /* We have a simple set of routines for querying the device's
@@ -407,7 +410,8 @@ static int __init lguest_devices_init(void)
        if (strcmp(pv_info.name, "lguest") != 0)
                return 0;
 
-       if (device_register(&lguest_root) != 0)
+       lguest_root = root_device_register("lguest");
+       if (IS_ERR(lguest_root))
                panic("Could not register lguest root");
 
        /* Devices are in a single page above top of "normal" mem */