]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/virtio/virtio.c
virtio: set device index in common code.
[linux-2.6-omap-h63xx.git] / drivers / virtio / virtio.c
index 13866789b3561027b803797a95c985f573671fd4..0f3c2bb7bf3523ef2987788389c640748f516b39 100644 (file)
@@ -2,6 +2,9 @@
 #include <linux/spinlock.h>
 #include <linux/virtio_config.h>
 
+/* Unique numbering for virtio devices. */
+static unsigned int dev_index;
+
 static ssize_t device_show(struct device *_d,
                           struct device_attribute *attr, char *buf)
 {
@@ -166,7 +169,10 @@ int register_virtio_device(struct virtio_device *dev)
        int err;
 
        dev->dev.bus = &virtio_bus;
-       sprintf(dev->dev.bus_id, "%u", dev->index);
+
+       /* Assign a unique device index and hence name. */
+       dev->index = dev_index++;
+       sprintf(dev->dev.bus_id, "virtio%u", dev->index);
 
        /* We always start by resetting the device, in case a previous
         * driver messed it up.  This also tests that code path a little. */