diff options
Diffstat (limited to 'drivers/virtio/virtio.c')
-rw-r--r-- | drivers/virtio/virtio.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c index 13866789b356..7084e7e146c0 100644 --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c | |||
@@ -2,6 +2,9 @@ | |||
2 | #include <linux/spinlock.h> | 2 | #include <linux/spinlock.h> |
3 | #include <linux/virtio_config.h> | 3 | #include <linux/virtio_config.h> |
4 | 4 | ||
5 | /* Unique numbering for virtio devices. */ | ||
6 | static unsigned int dev_index; | ||
7 | |||
5 | static ssize_t device_show(struct device *_d, | 8 | static ssize_t device_show(struct device *_d, |
6 | struct device_attribute *attr, char *buf) | 9 | struct device_attribute *attr, char *buf) |
7 | { | 10 | { |
@@ -121,9 +124,9 @@ static int virtio_dev_probe(struct device *_d) | |||
121 | if (err) | 124 | if (err) |
122 | add_status(dev, VIRTIO_CONFIG_S_FAILED); | 125 | add_status(dev, VIRTIO_CONFIG_S_FAILED); |
123 | else { | 126 | else { |
124 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); | ||
125 | /* They should never have set feature bits beyond 32 */ | 127 | /* They should never have set feature bits beyond 32 */ |
126 | dev->config->set_features(dev, dev->features[0]); | 128 | dev->config->set_features(dev, dev->features[0]); |
129 | add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); | ||
127 | } | 130 | } |
128 | return err; | 131 | return err; |
129 | } | 132 | } |
@@ -166,7 +169,10 @@ int register_virtio_device(struct virtio_device *dev) | |||
166 | int err; | 169 | int err; |
167 | 170 | ||
168 | dev->dev.bus = &virtio_bus; | 171 | dev->dev.bus = &virtio_bus; |
169 | sprintf(dev->dev.bus_id, "%u", dev->index); | 172 | |
173 | /* Assign a unique device index and hence name. */ | ||
174 | dev->index = dev_index++; | ||
175 | sprintf(dev->dev.bus_id, "virtio%u", dev->index); | ||
170 | 176 | ||
171 | /* We always start by resetting the device, in case a previous | 177 | /* We always start by resetting the device, in case a previous |
172 | * driver messed it up. This also tests that code path a little. */ | 178 | * driver messed it up. This also tests that code path a little. */ |