aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/virtio_blk.c
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2011-12-22 06:28:29 -0500
committerRusty Russell <rusty@rustcorp.com.au>2012-01-12 00:14:45 -0500
commit6abd6e5a4404056e28be04958a57d0286883161a (patch)
tree3a862f66577272bfc3103827b515e9564197b24c /drivers/block/virtio_blk.c
parentc743d09dbd018dd6345519fb3264b16bdaa41746 (diff)
virtio: blk: Move vq initialization to separate function
The probe and PM restore functions will share this code. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r--drivers/block/virtio_blk.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index ba73661fb9f3..e8af52355bf5 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -362,6 +362,18 @@ static void virtblk_config_changed(struct virtio_device *vdev)
362 queue_work(virtblk_wq, &vblk->config_work); 362 queue_work(virtblk_wq, &vblk->config_work);
363} 363}
364 364
365static int init_vq(struct virtio_blk *vblk)
366{
367 int err = 0;
368
369 /* We expect one virtqueue, for output. */
370 vblk->vq = virtio_find_single_vq(vblk->vdev, blk_done, "requests");
371 if (IS_ERR(vblk->vq))
372 err = PTR_ERR(vblk->vq);
373
374 return err;
375}
376
365static int __devinit virtblk_probe(struct virtio_device *vdev) 377static int __devinit virtblk_probe(struct virtio_device *vdev)
366{ 378{
367 struct virtio_blk *vblk; 379 struct virtio_blk *vblk;
@@ -405,12 +417,9 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
405 INIT_WORK(&vblk->config_work, virtblk_config_changed_work); 417 INIT_WORK(&vblk->config_work, virtblk_config_changed_work);
406 vblk->config_enable = true; 418 vblk->config_enable = true;
407 419
408 /* We expect one virtqueue, for output. */ 420 err = init_vq(vblk);
409 vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests"); 421 if (err)
410 if (IS_ERR(vblk->vq)) {
411 err = PTR_ERR(vblk->vq);
412 goto out_free_vblk; 422 goto out_free_vblk;
413 }
414 423
415 vblk->pool = mempool_create_kmalloc_pool(1,sizeof(struct virtblk_req)); 424 vblk->pool = mempool_create_kmalloc_pool(1,sizeof(struct virtblk_req));
416 if (!vblk->pool) { 425 if (!vblk->pool) {