Commit 59566b6e authored by Zhi Yong Wu's avatar Zhi Yong Wu Committed by David S. Miller

vhost: remove the dead branch

Since vhost_dev_init() forever return 0, some branches are never run,
therefore need to be removed.
Signed-off-by: default avatarZhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 941c2253
...@@ -683,7 +683,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) ...@@ -683,7 +683,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
struct vhost_net *n = kmalloc(sizeof *n, GFP_KERNEL); struct vhost_net *n = kmalloc(sizeof *n, GFP_KERNEL);
struct vhost_dev *dev; struct vhost_dev *dev;
struct vhost_virtqueue **vqs; struct vhost_virtqueue **vqs;
int r, i; int i;
if (!n) if (!n)
return -ENOMEM; return -ENOMEM;
...@@ -706,12 +706,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) ...@@ -706,12 +706,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
n->vqs[i].vhost_hlen = 0; n->vqs[i].vhost_hlen = 0;
n->vqs[i].sock_hlen = 0; n->vqs[i].sock_hlen = 0;
} }
r = vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX); vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
if (r < 0) {
kfree(n);
kfree(vqs);
return r;
}
vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev); vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev); vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
......
...@@ -1417,18 +1417,13 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) ...@@ -1417,18 +1417,13 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
vqs[i] = &vs->vqs[i].vq; vqs[i] = &vs->vqs[i].vq;
vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick; vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
} }
r = vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ); vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
tcm_vhost_init_inflight(vs, NULL); tcm_vhost_init_inflight(vs, NULL);
if (r < 0)
goto err_init;
f->private_data = vs; f->private_data = vs;
return 0; return 0;
err_init:
kfree(vqs);
err_vqs: err_vqs:
vhost_scsi_free(vs); vhost_scsi_free(vs);
err_vs: err_vs:
......
...@@ -104,7 +104,6 @@ static int vhost_test_open(struct inode *inode, struct file *f) ...@@ -104,7 +104,6 @@ static int vhost_test_open(struct inode *inode, struct file *f)
struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL); struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL);
struct vhost_dev *dev; struct vhost_dev *dev;
struct vhost_virtqueue **vqs; struct vhost_virtqueue **vqs;
int r;
if (!n) if (!n)
return -ENOMEM; return -ENOMEM;
...@@ -117,12 +116,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) ...@@ -117,12 +116,7 @@ static int vhost_test_open(struct inode *inode, struct file *f)
dev = &n->dev; dev = &n->dev;
vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ]; vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick; n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
r = vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX); vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
if (r < 0) {
kfree(vqs);
kfree(n);
return r;
}
f->private_data = n; f->private_data = n;
......
...@@ -290,7 +290,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev) ...@@ -290,7 +290,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)
vhost_vq_free_iovecs(dev->vqs[i]); vhost_vq_free_iovecs(dev->vqs[i]);
} }
long vhost_dev_init(struct vhost_dev *dev, void vhost_dev_init(struct vhost_dev *dev,
struct vhost_virtqueue **vqs, int nvqs) struct vhost_virtqueue **vqs, int nvqs)
{ {
struct vhost_virtqueue *vq; struct vhost_virtqueue *vq;
...@@ -319,8 +319,6 @@ long vhost_dev_init(struct vhost_dev *dev, ...@@ -319,8 +319,6 @@ long vhost_dev_init(struct vhost_dev *dev,
vhost_poll_init(&vq->poll, vq->handle_kick, vhost_poll_init(&vq->poll, vq->handle_kick,
POLLIN, dev); POLLIN, dev);
} }
return 0;
} }
EXPORT_SYMBOL_GPL(vhost_dev_init); EXPORT_SYMBOL_GPL(vhost_dev_init);
......
...@@ -127,7 +127,7 @@ struct vhost_dev { ...@@ -127,7 +127,7 @@ struct vhost_dev {
struct task_struct *worker; struct task_struct *worker;
}; };
long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs); void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
long vhost_dev_set_owner(struct vhost_dev *dev); long vhost_dev_set_owner(struct vhost_dev *dev);
bool vhost_dev_has_owner(struct vhost_dev *dev); bool vhost_dev_has_owner(struct vhost_dev *dev);
long vhost_dev_check_owner(struct vhost_dev *); long vhost_dev_check_owner(struct vhost_dev *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment