Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 74036
b: refs/heads/master
c: 74b2553
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell committed Nov 19, 2007
1 parent 5316a7c commit ae1c418
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d1c856e0f1a4c946c6329cff126548ef4288735f
refs/heads/master: 74b2553f1d13e60fb27063204bd5b6908a6f8494
10 changes: 7 additions & 3 deletions trunk/drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static int virtblk_probe(struct virtio_device *vdev)
err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_CAPACITY, &cap);
if (err) {
dev_err(&vdev->dev, "Bad/missing capacity in config\n");
goto out_put_disk;
goto out_cleanup_queue;
}

/* If capacity is too big, truncate with warning. */
Expand All @@ -239,20 +239,22 @@ static int virtblk_probe(struct virtio_device *vdev)
blk_queue_max_segment_size(vblk->disk->queue, v);
else if (err != -ENOENT) {
dev_err(&vdev->dev, "Bad SIZE_MAX in config\n");
goto out_put_disk;
goto out_cleanup_queue;
}

err = virtio_config_val(vdev, VIRTIO_CONFIG_BLK_F_SEG_MAX, &v);
if (!err)
blk_queue_max_hw_segments(vblk->disk->queue, v);
else if (err != -ENOENT) {
dev_err(&vdev->dev, "Bad SEG_MAX in config\n");
goto out_put_disk;
goto out_cleanup_queue;
}

add_disk(vblk->disk);
return 0;

out_cleanup_queue:
blk_cleanup_queue(vblk->disk->queue);
out_put_disk:
put_disk(vblk->disk);
out_unregister_blkdev:
Expand All @@ -277,6 +279,8 @@ static void virtblk_remove(struct virtio_device *vdev)
put_disk(vblk->disk);
unregister_blkdev(major, "virtblk");
mempool_destroy(vblk->pool);
/* There should be nothing in the queue now, so no need to shutdown */
vdev->config->del_vq(vblk->vq);
kfree(vblk);
}

Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/lguest/lguest_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ static void lg_del_vq(struct virtqueue *vq)
{
struct lguest_vq_info *lvq = vq->priv;

/* Release the interrupt */
free_irq(lvq->config.irq, vq);
/* Tell virtio_ring.c to free the virtqueue. */
vring_del_virtqueue(vq);
/* Unmap the pages containing the ring. */
Expand Down
8 changes: 6 additions & 2 deletions trunk/drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,12 @@ static int virtnet_probe(struct virtio_device *vdev)

static void virtnet_remove(struct virtio_device *vdev)
{
unregister_netdev(vdev->priv);
free_netdev(vdev->priv);
struct virtnet_info *vi = vdev->priv;

vdev->config->del_vq(vi->svq);
vdev->config->del_vq(vi->rvq);
unregister_netdev(vi->dev);
free_netdev(vi->dev);
}

static struct virtio_device_id id_table[] = {
Expand Down
13 changes: 13 additions & 0 deletions trunk/drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,23 @@ static int virtio_dev_probe(struct device *_d)
return err;
}

static int virtio_dev_remove(struct device *_d)
{
struct virtio_device *dev = container_of(_d,struct virtio_device,dev);
struct virtio_driver *drv = container_of(dev->dev.driver,
struct virtio_driver, driver);

dev->config->set_status(dev, dev->config->get_status(dev)
& ~VIRTIO_CONFIG_S_DRIVER);
drv->remove(dev);
return 0;
}

int register_virtio_driver(struct virtio_driver *driver)
{
driver->driver.bus = &virtio_bus;
driver->driver.probe = virtio_dev_probe;
driver->driver.remove = virtio_dev_remove;
return driver_register(&driver->driver);
}
EXPORT_SYMBOL_GPL(register_virtio_driver);
Expand Down

0 comments on commit ae1c418

Please sign in to comment.