mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 16:54:20 +08:00
drm/vmwgfx: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: David Airlie <airlied@linux.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
36888db247
commit
cc39a8faed
@ -177,17 +177,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res)
|
|||||||
|
|
||||||
BUG_ON(res->id != -1);
|
BUG_ON(res->id != -1);
|
||||||
|
|
||||||
do {
|
idr_preload(GFP_KERNEL);
|
||||||
if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
|
write_lock(&dev_priv->resource_lock);
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
write_lock(&dev_priv->resource_lock);
|
ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT);
|
||||||
ret = idr_get_new_above(idr, res, 1, &res->id);
|
if (ret >= 0)
|
||||||
write_unlock(&dev_priv->resource_lock);
|
res->id = ret;
|
||||||
|
|
||||||
} while (ret == -EAGAIN);
|
write_unlock(&dev_priv->resource_lock);
|
||||||
|
idr_preload_end();
|
||||||
return ret;
|
return ret < 0 ? ret : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user