aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/virtio_console.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 2bd6a9c302c8..f404ccfc9c20 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1071,27 +1071,27 @@ static void config_intr(struct virtio_device *vdev)
1071static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) 1071static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock)
1072{ 1072{
1073 struct port_buffer *buf; 1073 struct port_buffer *buf;
1074 unsigned int ret; 1074 unsigned int nr_added_bufs;
1075 int err; 1075 int ret;
1076 1076
1077 ret = 0; 1077 nr_added_bufs = 0;
1078 do { 1078 do {
1079 buf = alloc_buf(PAGE_SIZE); 1079 buf = alloc_buf(PAGE_SIZE);
1080 if (!buf) 1080 if (!buf)
1081 break; 1081 break;
1082 1082
1083 spin_lock_irq(lock); 1083 spin_lock_irq(lock);
1084 err = add_inbuf(vq, buf); 1084 ret = add_inbuf(vq, buf);
1085 if (err < 0) { 1085 if (ret < 0) {
1086 spin_unlock_irq(lock); 1086 spin_unlock_irq(lock);
1087 free_buf(buf); 1087 free_buf(buf);
1088 break; 1088 break;
1089 } 1089 }
1090 ret++; 1090 nr_added_bufs++;
1091 spin_unlock_irq(lock); 1091 spin_unlock_irq(lock);
1092 } while (err > 0); 1092 } while (ret > 0);
1093 1093
1094 return ret; 1094 return nr_added_bufs;
1095} 1095}
1096 1096
1097static int add_port(struct ports_device *portdev, u32 id) 1097static int add_port(struct ports_device *portdev, u32 id)
@@ -1100,6 +1100,7 @@ static int add_port(struct ports_device *portdev, u32 id)
1100 struct port *port; 1100 struct port *port;
1101 struct port_buffer *buf; 1101 struct port_buffer *buf;
1102 dev_t devt; 1102 dev_t devt;
1103 unsigned int nr_added_bufs;
1103 int err; 1104 int err;
1104 1105
1105 port = kmalloc(sizeof(*port), GFP_KERNEL); 1106 port = kmalloc(sizeof(*port), GFP_KERNEL);
@@ -1144,8 +1145,8 @@ static int add_port(struct ports_device *portdev, u32 id)
1144 init_waitqueue_head(&port->waitqueue); 1145 init_waitqueue_head(&port->waitqueue);
1145 1146
1146 /* Fill the in_vq with buffers so the host can send us data. */ 1147 /* Fill the in_vq with buffers so the host can send us data. */
1147 err = fill_queue(port->in_vq, &port->inbuf_lock); 1148 nr_added_bufs = fill_queue(port->in_vq, &port->inbuf_lock);
1148 if (!err) { 1149 if (!nr_added_bufs) {
1149 dev_err(port->dev, "Error allocating inbufs\n"); 1150 dev_err(port->dev, "Error allocating inbufs\n");
1150 err = -ENOMEM; 1151 err = -ENOMEM;
1151 goto free_device; 1152 goto free_device;
@@ -1442,12 +1443,14 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1442 INIT_LIST_HEAD(&portdev->ports); 1443 INIT_LIST_HEAD(&portdev->ports);
1443 1444
1444 if (multiport) { 1445 if (multiport) {
1446 unsigned int nr_added_bufs;
1447
1445 spin_lock_init(&portdev->cvq_lock); 1448 spin_lock_init(&portdev->cvq_lock);
1446 INIT_WORK(&portdev->control_work, &control_work_handler); 1449 INIT_WORK(&portdev->control_work, &control_work_handler);
1447 INIT_WORK(&portdev->config_work, &config_work_handler); 1450 INIT_WORK(&portdev->config_work, &config_work_handler);
1448 1451
1449 err = fill_queue(portdev->c_ivq, &portdev->cvq_lock); 1452 nr_added_bufs = fill_queue(portdev->c_ivq, &portdev->cvq_lock);
1450 if (!err) { 1453 if (!nr_added_bufs) {
1451 dev_err(&vdev->dev, 1454 dev_err(&vdev->dev,
1452 "Error allocating buffers for control queue\n"); 1455 "Error allocating buffers for control queue\n");
1453 err = -ENOMEM; 1456 err = -ENOMEM;