Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1226335 > unrolled thread

[PATCH 09/17] Update the virtgpu driver to use idr helper functions.

Started byLee Duncan <lduncan@suse.com>
First post2015-09-16 20:00 +0200
Last post2015-09-16 20:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 09/17] Update the virtgpu driver to use idr helper functions. Lee Duncan <lduncan@suse.com> - 2015-09-16 20:00 +0200

#1226335 — [PATCH 09/17] Update the virtgpu driver to use idr helper functions.

FromLee Duncan <lduncan@suse.com>
Date2015-09-16 20:00 +0200
Subject[PATCH 09/17] Update the virtgpu driver to use idr helper functions.
Message-ID<q9p9V-3ca-49@gated-at.bofh.it>
Signed-off-by: Lee Duncan <lduncan@suse.com>
---
 drivers/gpu/drm/virtio/virtgpu_vq.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 1698669f4185..380947dad306 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -41,21 +41,14 @@
 void virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
 				uint32_t *resid)
 {
-	int handle;
-
-	idr_preload(GFP_KERNEL);
-	spin_lock(&vgdev->resource_idr_lock);
-	handle = idr_alloc(&vgdev->resource_idr, NULL, 1, 0, GFP_NOWAIT);
-	spin_unlock(&vgdev->resource_idr_lock);
-	idr_preload_end();
-	*resid = handle;
+	*resid = idr_get_index_in_range(&vgdev->resource_idr,
+					&vgdev->resource_idr_lock,
+					NULL, 1, 0);
 }
 
 void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
 {
-	spin_lock(&vgdev->resource_idr_lock);
-	idr_remove(&vgdev->resource_idr, id);
-	spin_unlock(&vgdev->resource_idr_lock);
+	idr_put_index(&vgdev->resource_idr, &vgdev->resource_idr_lock, id);
 }
 
 void virtio_gpu_ctrl_ack(struct virtqueue *vq)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web