From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754607AbbIPRxH (ORCPT ); Wed, 16 Sep 2015 13:53:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:51433 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754278AbbIPRvT (ORCPT ); Wed, 16 Sep 2015 13:51:19 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Lee Duncan To: linux-scsi@vger.kernel.org, James.Bottomley@HansenPartnership.com Cc: linux-kernel@vger.kernel.org, hare@suse.com, jthumshirn@suse.de, hch@infradead.org, Lee Duncan , Gerd Hoffmann Subject: [PATCH 09/17] Update the virtgpu driver to use idr helper functions. Date: Wed, 16 Sep 2015 10:50:27 -0700 Message-Id: <83e5daa0708729d4a3b6fda61c6ab8d70e501606.1442263513.git.lduncan@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Lee Duncan --- 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