diff options
Diffstat (limited to 'drivers/lguest')
-rw-r--r-- | drivers/lguest/lguest_device.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c index 4babed899d59..e082cdac88b4 100644 --- a/drivers/lguest/lguest_device.c +++ b/drivers/lguest/lguest_device.c | |||
@@ -313,6 +313,38 @@ static void lg_del_vq(struct virtqueue *vq) | |||
313 | kfree(lvq); | 313 | kfree(lvq); |
314 | } | 314 | } |
315 | 315 | ||
316 | static void lg_del_vqs(struct virtio_device *vdev) | ||
317 | { | ||
318 | struct virtqueue *vq, *n; | ||
319 | |||
320 | list_for_each_entry_safe(vq, n, &vdev->vqs, list) | ||
321 | lg_del_vq(vq); | ||
322 | } | ||
323 | |||
324 | static int lg_find_vqs(struct virtio_device *vdev, unsigned nvqs, | ||
325 | struct virtqueue *vqs[], | ||
326 | vq_callback_t *callbacks[], | ||
327 | const char *names[]) | ||
328 | { | ||
329 | struct lguest_device *ldev = to_lgdev(vdev); | ||
330 | int i; | ||
331 | |||
332 | /* We must have this many virtqueues. */ | ||
333 | if (nvqs > ldev->desc->num_vq) | ||
334 | return -ENOENT; | ||
335 | |||
336 | for (i = 0; i < nvqs; ++i) { | ||
337 | vqs[i] = lg_find_vq(vdev, i, callbacks[i], names[i]); | ||
338 | if (IS_ERR(vqs[i])) | ||
339 | goto error; | ||
340 | } | ||
341 | return 0; | ||
342 | |||
343 | error: | ||
344 | lg_del_vqs(vdev); | ||
345 | return PTR_ERR(vqs[i]); | ||
346 | } | ||
347 | |||
316 | /* The ops structure which hooks everything together. */ | 348 | /* The ops structure which hooks everything together. */ |
317 | static struct virtio_config_ops lguest_config_ops = { | 349 | static struct virtio_config_ops lguest_config_ops = { |
318 | .get_features = lg_get_features, | 350 | .get_features = lg_get_features, |
@@ -322,8 +354,8 @@ static struct virtio_config_ops lguest_config_ops = { | |||
322 | .get_status = lg_get_status, | 354 | .get_status = lg_get_status, |
323 | .set_status = lg_set_status, | 355 | .set_status = lg_set_status, |
324 | .reset = lg_reset, | 356 | .reset = lg_reset, |
325 | .find_vq = lg_find_vq, | 357 | .find_vqs = lg_find_vqs, |
326 | .del_vq = lg_del_vq, | 358 | .del_vqs = lg_del_vqs, |
327 | }; | 359 | }; |
328 | 360 | ||
329 | /* The root device for the lguest virtio devices. This makes them appear as | 361 | /* The root device for the lguest virtio devices. This makes them appear as |