Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 180819
b: refs/heads/master
c: 22a29ea
h: refs/heads/master
i:
  180817: ef6cdfb
  180815: 2de8f2f
v: v3
  • Loading branch information
Amit Shah authored and Rusty Russell committed Feb 24, 2010
1 parent 39fe778 commit c9e419d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 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: 7177876fea8306a6f49400d11f5913bf9b3b5e5f
refs/heads/master: 22a29eacd2a17f22c8260a8106a4e36bae7fb6ea
27 changes: 21 additions & 6 deletions trunk/drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,25 +1057,30 @@ static void config_intr(struct virtio_device *vdev)
resize_console(find_port_by_id(portdev, 0));
}

static void fill_queue(struct virtqueue *vq, spinlock_t *lock)
static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
{
struct port_buffer *buf;
int ret;
unsigned int ret;
int err;

ret = 0;
do {
buf = alloc_buf(PAGE_SIZE);
if (!buf)
break;

spin_lock_irq(lock);
ret = add_inbuf(vq, buf);
if (ret < 0) {
err = add_inbuf(vq, buf);
if (err < 0) {
spin_unlock_irq(lock);
free_buf(buf);
break;
}
ret++;
spin_unlock_irq(lock);
} while (ret > 0);
} while (err > 0);

return ret;
}

static int add_port(struct ports_device *portdev, u32 id)
Expand Down Expand Up @@ -1430,7 +1435,13 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
INIT_WORK(&portdev->control_work, &control_work_handler);
INIT_WORK(&portdev->config_work, &config_work_handler);

fill_queue(portdev->c_ivq, &portdev->cvq_lock);
err = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
if (!err) {
dev_err(&vdev->dev,
"Error allocating buffers for control queue\n");
err = -ENOMEM;
goto free_vqs;
}
}

for (i = 0; i < portdev->config.nr_ports; i++)
Expand All @@ -1440,6 +1451,10 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
early_put_chars = NULL;
return 0;

free_vqs:
vdev->config->del_vqs(vdev);
kfree(portdev->in_vqs);
kfree(portdev->out_vqs);
free_chrdev:
unregister_chrdev(portdev->chr_major, "virtio-portsdev");
free:
Expand Down

0 comments on commit c9e419d

Please sign in to comment.