diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-07 19:04:03 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-07 19:04:03 -0500 |
commit | 25cf84cf377c0aae5dbcf937ea89bc7893db5176 (patch) | |
tree | 171052d4734fda5e77668aacfff98de69e1f4237 /drivers/char | |
parent | 322aafa6645a48c3b7837ca7385f126ab78127fd (diff) | |
parent | 335a64a5c21ed58de21c0130c90c7e647cdcf572 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/amit/virtio-console
* git://git.kernel.org/pub/scm/linux/kernel/git/amit/virtio-console:
virtio: console: Use better variable names for fill_queue operation
virtio: console: Fix type of 'len' as unsigned int
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/virtio_console.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 213373b5f17f..f404ccfc9c20 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -379,7 +379,7 @@ static ssize_t send_control_msg(struct port *port, unsigned int event, | |||
379 | struct scatterlist sg[1]; | 379 | struct scatterlist sg[1]; |
380 | struct virtio_console_control cpkt; | 380 | struct virtio_console_control cpkt; |
381 | struct virtqueue *vq; | 381 | struct virtqueue *vq; |
382 | int len; | 382 | unsigned int len; |
383 | 383 | ||
384 | if (!use_multiport(port->portdev)) | 384 | if (!use_multiport(port->portdev)) |
385 | return 0; | 385 | return 0; |
@@ -1071,27 +1071,27 @@ static void config_intr(struct virtio_device *vdev) | |||
1071 | static unsigned int fill_queue(struct virtqueue *vq, spinlock_t *lock) | 1071 | static 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 | ||
1097 | static int add_port(struct ports_device *portdev, u32 id) | 1097 | static 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; |