aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio/virtio_mmio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/virtio/virtio_mmio.c')
-rw-r--r--drivers/virtio/virtio_mmio.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 6b1b7e184939..634f80bcdbd7 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -225,7 +225,7 @@ static void vm_notify(struct virtqueue *vq)
225 225
226 /* We write the queue's selector into the notification register to 226 /* We write the queue's selector into the notification register to
227 * signal the other end */ 227 * signal the other end */
228 writel(virtqueue_get_queue_index(vq), vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY); 228 writel(vq->index, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
229} 229}
230 230
231/* Notify all virtqueues on an interrupt. */ 231/* Notify all virtqueues on an interrupt. */
@@ -266,7 +266,7 @@ static void vm_del_vq(struct virtqueue *vq)
266 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev); 266 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
267 struct virtio_mmio_vq_info *info = vq->priv; 267 struct virtio_mmio_vq_info *info = vq->priv;
268 unsigned long flags, size; 268 unsigned long flags, size;
269 unsigned int index = virtqueue_get_queue_index(vq); 269 unsigned int index = vq->index;
270 270
271 spin_lock_irqsave(&vm_dev->lock, flags); 271 spin_lock_irqsave(&vm_dev->lock, flags);
272 list_del(&info->node); 272 list_del(&info->node);
@@ -521,25 +521,33 @@ static int vm_cmdline_set(const char *device,
521 int err; 521 int err;
522 struct resource resources[2] = {}; 522 struct resource resources[2] = {};
523 char *str; 523 char *str;
524 long long int base; 524 long long int base, size;
525 unsigned int irq;
525 int processed, consumed = 0; 526 int processed, consumed = 0;
526 struct platform_device *pdev; 527 struct platform_device *pdev;
527 528
528 resources[0].flags = IORESOURCE_MEM; 529 /* Consume "size" part of the command line parameter */
529 resources[1].flags = IORESOURCE_IRQ; 530 size = memparse(device, &str);
530
531 resources[0].end = memparse(device, &str) - 1;
532 531
532 /* Get "@<base>:<irq>[:<id>]" chunks */
533 processed = sscanf(str, "@%lli:%u%n:%d%n", 533 processed = sscanf(str, "@%lli:%u%n:%d%n",
534 &base, &resources[1].start, &consumed, 534 &base, &irq, &consumed,
535 &vm_cmdline_id, &consumed); 535 &vm_cmdline_id, &consumed);
536 536
537 if (processed < 2 || processed > 3 || str[consumed]) 537 /*
538 * sscanf() must processes at least 2 chunks; also there
539 * must be no extra characters after the last chunk, so
540 * str[consumed] must be '\0'
541 */
542 if (processed < 2 || str[consumed])
538 return -EINVAL; 543 return -EINVAL;
539 544
545 resources[0].flags = IORESOURCE_MEM;
540 resources[0].start = base; 546 resources[0].start = base;
541 resources[0].end += base; 547 resources[0].end = base + size - 1;
542 resources[1].end = resources[1].start; 548
549 resources[1].flags = IORESOURCE_IRQ;
550 resources[1].start = resources[1].end = irq;
543 551
544 if (!vm_cmdline_parent_registered) { 552 if (!vm_cmdline_parent_registered) {
545 err = device_register(&vm_cmdline_parent); 553 err = device_register(&vm_cmdline_parent);