Commit cee26ac4 authored by Dave Airlie's avatar Dave Airlie

drm/mode: use _object_find to find framebuffers.

No point have this code dupliated at this point, use the
_object_find code instead now.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent d0f37cf6
...@@ -362,8 +362,7 @@ static struct drm_mode_object *_object_find(struct drm_device *dev, ...@@ -362,8 +362,7 @@ static struct drm_mode_object *_object_find(struct drm_device *dev,
obj = NULL; obj = NULL;
/* don't leak out unref'd fb's */ /* don't leak out unref'd fb's */
if (obj && if (obj &&
(obj->type == DRM_MODE_OBJECT_FB || obj->type == DRM_MODE_OBJECT_BLOB)
obj->type == DRM_MODE_OBJECT_BLOB))
obj = NULL; obj = NULL;
mutex_unlock(&dev->mode_config.idr_mutex); mutex_unlock(&dev->mode_config.idr_mutex);
...@@ -478,23 +477,6 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, ...@@ -478,23 +477,6 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
} }
EXPORT_SYMBOL(drm_framebuffer_init); EXPORT_SYMBOL(drm_framebuffer_init);
static struct drm_framebuffer *__drm_framebuffer_lookup(struct drm_device *dev,
uint32_t id)
{
struct drm_mode_object *obj = NULL;
struct drm_framebuffer *fb;
mutex_lock(&dev->mode_config.idr_mutex);
obj = idr_find(&dev->mode_config.crtc_idr, id);
if (!obj || (obj->type != DRM_MODE_OBJECT_FB) || (obj->id != id))
fb = NULL;
else
fb = obj_to_fb(obj);
mutex_unlock(&dev->mode_config.idr_mutex);
return fb;
}
/** /**
* drm_framebuffer_lookup - look up a drm framebuffer and grab a reference * drm_framebuffer_lookup - look up a drm framebuffer and grab a reference
* @dev: drm device * @dev: drm device
...@@ -507,11 +489,13 @@ static struct drm_framebuffer *__drm_framebuffer_lookup(struct drm_device *dev, ...@@ -507,11 +489,13 @@ static struct drm_framebuffer *__drm_framebuffer_lookup(struct drm_device *dev,
struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
uint32_t id) uint32_t id)
{ {
struct drm_framebuffer *fb; struct drm_mode_object *obj;
struct drm_framebuffer *fb = NULL;
mutex_lock(&dev->mode_config.fb_lock); mutex_lock(&dev->mode_config.fb_lock);
fb = __drm_framebuffer_lookup(dev, id); obj = _object_find(dev, id, DRM_MODE_OBJECT_FB);
if (fb) { if (obj) {
fb = obj_to_fb(obj);
if (!kref_get_unless_zero(&fb->base.refcount)) if (!kref_get_unless_zero(&fb->base.refcount))
fb = NULL; fb = NULL;
} }
...@@ -3489,6 +3473,7 @@ int drm_mode_rmfb(struct drm_device *dev, ...@@ -3489,6 +3473,7 @@ int drm_mode_rmfb(struct drm_device *dev,
{ {
struct drm_framebuffer *fb = NULL; struct drm_framebuffer *fb = NULL;
struct drm_framebuffer *fbl = NULL; struct drm_framebuffer *fbl = NULL;
struct drm_mode_object *obj;
uint32_t *id = data; uint32_t *id = data;
int found = 0; int found = 0;
...@@ -3497,10 +3482,10 @@ int drm_mode_rmfb(struct drm_device *dev, ...@@ -3497,10 +3482,10 @@ int drm_mode_rmfb(struct drm_device *dev,
mutex_lock(&file_priv->fbs_lock); mutex_lock(&file_priv->fbs_lock);
mutex_lock(&dev->mode_config.fb_lock); mutex_lock(&dev->mode_config.fb_lock);
fb = __drm_framebuffer_lookup(dev, *id); obj = _object_find(dev, *id, DRM_MODE_OBJECT_FB);
if (!fb) if (!obj)
goto fail_lookup; goto fail_lookup;
fb = obj_to_fb(obj);
list_for_each_entry(fbl, &file_priv->fbs, filp_head) list_for_each_entry(fbl, &file_priv->fbs, filp_head)
if (fb == fbl) if (fb == fbl)
found = 1; found = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment