lkml.org 
[lkml]   [2013]   [Feb]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 36/77] drm/vmwgfx: convert to idr_alloc()
    Date
    Convert to the much saner new idr interface.

    Only compile tested.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Cc: David Airlie <airlied@linux.ie>
    Cc: dri-devel@lists.freedesktop.org
    ---
    drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 17 ++++++++---------
    1 file changed, 8 insertions(+), 9 deletions(-)

    diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
    index e01a17b..c9d0676 100644
    --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
    +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
    @@ -177,17 +177,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res)

    BUG_ON(res->id != -1);

    - do {
    - if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
    - return -ENOMEM;
    -
    - write_lock(&dev_priv->resource_lock);
    - ret = idr_get_new_above(idr, res, 1, &res->id);
    - write_unlock(&dev_priv->resource_lock);
    + idr_preload(GFP_KERNEL);
    + write_lock(&dev_priv->resource_lock);

    - } while (ret == -EAGAIN);
    + ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT);
    + if (ret >= 0)
    + res->id = ret;

    - return ret;
    + write_unlock(&dev_priv->resource_lock);
    + idr_preload_end();
    + return ret < 0 ? ret : 0;
    }

    /**
    --
    1.8.1


    \
     
     \ /
      Last update: 2013-02-07 06:21    [W:3.717 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site