Commit be6ee102 authored by Emil Velikov's avatar Emil Velikov Committed by Emil Velikov

drm: remove _unlocked suffix in drm_gem_object_put_unlocked

Spelling out _unlocked for each and every driver is a annoying.
Especially if we consider how many drivers, do not know (or need to)
about the horror stories involving struct_mutex.

Just drop the suffix. It makes the API cleaner.

Done via the following script:

__from=drm_gem_object_put_unlocked
__to=drm_gem_object_put
for __file in $(git grep --name-only $__from); do
  sed -i  "s/$__from/$__to/g" $__file;
done

Pay special attention to the compat #define

v2: keep sed and #define removal separate

Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org> (v1)
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20200515095118.2743122-14-emil.l.velikov@gmail.com
parent 2f4dd13d
...@@ -178,7 +178,7 @@ GEM Objects Lifetime ...@@ -178,7 +178,7 @@ GEM Objects Lifetime
-------------------- --------------------
All GEM objects are reference-counted by the GEM core. References can be All GEM objects are reference-counted by the GEM core. References can be
acquired and release by calling drm_gem_object_get() and drm_gem_object_put_unlocked() acquired and release by calling drm_gem_object_get() and drm_gem_object_put()
respectively. respectively.
When the last reference to a GEM object is released the GEM core calls When the last reference to a GEM object is released the GEM core calls
......
...@@ -237,7 +237,7 @@ static void drm_client_buffer_delete(struct drm_client_buffer *buffer) ...@@ -237,7 +237,7 @@ static void drm_client_buffer_delete(struct drm_client_buffer *buffer)
drm_gem_vunmap(buffer->gem, buffer->vaddr); drm_gem_vunmap(buffer->gem, buffer->vaddr);
if (buffer->gem) if (buffer->gem)
drm_gem_object_put_unlocked(buffer->gem); drm_gem_object_put(buffer->gem);
if (buffer->handle) if (buffer->handle)
drm_mode_destroy_dumb(dev, buffer->handle, buffer->client->file); drm_mode_destroy_dumb(dev, buffer->handle, buffer->client->file);
......
...@@ -235,7 +235,7 @@ drm_gem_object_handle_put_unlocked(struct drm_gem_object *obj) ...@@ -235,7 +235,7 @@ drm_gem_object_handle_put_unlocked(struct drm_gem_object *obj)
mutex_unlock(&dev->object_name_lock); mutex_unlock(&dev->object_name_lock);
if (final) if (final)
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
} }
/* /*
...@@ -331,7 +331,7 @@ int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, ...@@ -331,7 +331,7 @@ int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
*offset = drm_vma_node_offset_addr(&obj->vma_node); *offset = drm_vma_node_offset_addr(&obj->vma_node);
out: out:
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return ret; return ret;
} }
...@@ -690,7 +690,7 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count, ...@@ -690,7 +690,7 @@ static int objects_lookup(struct drm_file *filp, u32 *handle, int count,
* Returns: * Returns:
* *
* @objs filled in with GEM object pointers. Returned GEM objects need to be * @objs filled in with GEM object pointers. Returned GEM objects need to be
* released with drm_gem_object_put_unlocked(). -ENOENT is returned on a lookup * released with drm_gem_object_put(). -ENOENT is returned on a lookup
* failure. 0 is returned on success. * failure. 0 is returned on success.
* *
*/ */
...@@ -785,7 +785,7 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle, ...@@ -785,7 +785,7 @@ long drm_gem_dma_resv_wait(struct drm_file *filep, u32 handle,
else if (ret > 0) else if (ret > 0)
ret = 0; ret = 0;
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return ret; return ret;
} }
...@@ -860,7 +860,7 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data, ...@@ -860,7 +860,7 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
err: err:
mutex_unlock(&dev->object_name_lock); mutex_unlock(&dev->object_name_lock);
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return ret; return ret;
} }
...@@ -898,7 +898,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data, ...@@ -898,7 +898,7 @@ drm_gem_open_ioctl(struct drm_device *dev, void *data,
/* drm_gem_handle_create_tail unlocks dev->object_name_lock. */ /* drm_gem_handle_create_tail unlocks dev->object_name_lock. */
ret = drm_gem_handle_create_tail(file_priv, obj, &handle); ret = drm_gem_handle_create_tail(file_priv, obj, &handle);
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
if (ret) if (ret)
return ret; return ret;
...@@ -991,7 +991,7 @@ EXPORT_SYMBOL(drm_gem_object_free); ...@@ -991,7 +991,7 @@ EXPORT_SYMBOL(drm_gem_object_free);
* driver doesn't use &drm_device.struct_mutex for anything. * driver doesn't use &drm_device.struct_mutex for anything.
* *
* For drivers not encumbered with legacy locking use * For drivers not encumbered with legacy locking use
* drm_gem_object_put_unlocked() instead. * drm_gem_object_put() instead.
*/ */
void void
drm_gem_object_put_locked(struct drm_gem_object *obj) drm_gem_object_put_locked(struct drm_gem_object *obj)
...@@ -1030,7 +1030,7 @@ void drm_gem_vm_close(struct vm_area_struct *vma) ...@@ -1030,7 +1030,7 @@ void drm_gem_vm_close(struct vm_area_struct *vma)
{ {
struct drm_gem_object *obj = vma->vm_private_data; struct drm_gem_object *obj = vma->vm_private_data;
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
} }
EXPORT_SYMBOL(drm_gem_vm_close); EXPORT_SYMBOL(drm_gem_vm_close);
...@@ -1079,7 +1079,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, ...@@ -1079,7 +1079,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
if (obj->funcs && obj->funcs->mmap) { if (obj->funcs && obj->funcs->mmap) {
ret = obj->funcs->mmap(obj, vma); ret = obj->funcs->mmap(obj, vma);
if (ret) { if (ret) {
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return ret; return ret;
} }
WARN_ON(!(vma->vm_flags & VM_DONTEXPAND)); WARN_ON(!(vma->vm_flags & VM_DONTEXPAND));
...@@ -1089,7 +1089,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, ...@@ -1089,7 +1089,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
else if (dev->driver->gem_vm_ops) else if (dev->driver->gem_vm_ops)
vma->vm_ops = dev->driver->gem_vm_ops; vma->vm_ops = dev->driver->gem_vm_ops;
else { else {
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return -EINVAL; return -EINVAL;
} }
...@@ -1155,13 +1155,13 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -1155,13 +1155,13 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL; return -EINVAL;
if (!drm_vma_node_is_allowed(node, priv)) { if (!drm_vma_node_is_allowed(node, priv)) {
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return -EACCES; return -EACCES;
} }
if (node->readonly) { if (node->readonly) {
if (vma->vm_flags & VM_WRITE) { if (vma->vm_flags & VM_WRITE) {
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return -EINVAL; return -EINVAL;
} }
...@@ -1171,7 +1171,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -1171,7 +1171,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node) << PAGE_SHIFT, ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node) << PAGE_SHIFT,
vma); vma);
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return ret; return ret;
} }
......
...@@ -114,7 +114,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, ...@@ -114,7 +114,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
return cma_obj; return cma_obj;
error: error:
drm_gem_object_put_unlocked(&cma_obj->base); drm_gem_object_put(&cma_obj->base);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(drm_gem_cma_create); EXPORT_SYMBOL_GPL(drm_gem_cma_create);
...@@ -156,7 +156,7 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv, ...@@ -156,7 +156,7 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv,
*/ */
ret = drm_gem_handle_create(file_priv, gem_obj, handle); ret = drm_gem_handle_create(file_priv, gem_obj, handle);
/* drop reference from allocate - handle holds it now. */ /* drop reference from allocate - handle holds it now. */
drm_gem_object_put_unlocked(gem_obj); drm_gem_object_put(gem_obj);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -380,13 +380,13 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp, ...@@ -380,13 +380,13 @@ unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
return -EINVAL; return -EINVAL;
if (!drm_vma_node_is_allowed(node, priv)) { if (!drm_vma_node_is_allowed(node, priv)) {
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return -EACCES; return -EACCES;
} }
cma_obj = to_drm_gem_cma_obj(obj); cma_obj = to_drm_gem_cma_obj(obj);
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
return cma_obj->vaddr ? (unsigned long)cma_obj->vaddr : -EINVAL; return cma_obj->vaddr ? (unsigned long)cma_obj->vaddr : -EINVAL;
} }
......
...@@ -95,7 +95,7 @@ void drm_gem_fb_destroy(struct drm_framebuffer *fb) ...@@ -95,7 +95,7 @@ void drm_gem_fb_destroy(struct drm_framebuffer *fb)
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
drm_gem_object_put_unlocked(fb->obj[i]); drm_gem_object_put(fb->obj[i]);
drm_framebuffer_cleanup(fb); drm_framebuffer_cleanup(fb);
kfree(fb); kfree(fb);
...@@ -175,7 +175,7 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev, ...@@ -175,7 +175,7 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev,
+ mode_cmd->offsets[i]; + mode_cmd->offsets[i];
if (objs[i]->size < min_size) { if (objs[i]->size < min_size) {
drm_gem_object_put_unlocked(objs[i]); drm_gem_object_put(objs[i]);
ret = -EINVAL; ret = -EINVAL;
goto err_gem_object_put; goto err_gem_object_put;
} }
...@@ -189,7 +189,7 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev, ...@@ -189,7 +189,7 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev,
err_gem_object_put: err_gem_object_put:
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
drm_gem_object_put_unlocked(objs[i]); drm_gem_object_put(objs[i]);
return ret; return ret;
} }
......
...@@ -360,7 +360,7 @@ drm_gem_shmem_create_with_handle(struct drm_file *file_priv, ...@@ -360,7 +360,7 @@ drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
*/ */
ret = drm_gem_handle_create(file_priv, &shmem->base, handle); ret = drm_gem_handle_create(file_priv, &shmem->base, handle);
/* drop reference from allocate - handle holds it now. */ /* drop reference from allocate - handle holds it now. */
drm_gem_object_put_unlocked(&shmem->base); drm_gem_object_put(&shmem->base);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -684,7 +684,7 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev, ...@@ -684,7 +684,7 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,
err_free_array: err_free_array:
kvfree(shmem->pages); kvfree(shmem->pages);
err_free_gem: err_free_gem:
drm_gem_object_put_unlocked(&shmem->base); drm_gem_object_put(&shmem->base);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
......
...@@ -74,7 +74,7 @@ int drm_gem_ttm_mmap(struct drm_gem_object *gem, ...@@ -74,7 +74,7 @@ int drm_gem_ttm_mmap(struct drm_gem_object *gem,
* ttm has its own object refcounting, so drop gem reference * ttm has its own object refcounting, so drop gem reference
* to avoid double accounting counting. * to avoid double accounting counting.
*/ */
drm_gem_object_put_unlocked(gem); drm_gem_object_put(gem);
return 0; return 0;
} }
......
...@@ -618,9 +618,9 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, ...@@ -618,9 +618,9 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
ret = drm_gem_handle_create(file, &gbo->bo.base, &handle); ret = drm_gem_handle_create(file, &gbo->bo.base, &handle);
if (ret) if (ret)
goto err_drm_gem_object_put_unlocked; goto err_drm_gem_object_put;
drm_gem_object_put_unlocked(&gbo->bo.base); drm_gem_object_put(&gbo->bo.base);
args->pitch = pitch; args->pitch = pitch;
args->size = size; args->size = size;
...@@ -628,8 +628,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, ...@@ -628,8 +628,8 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
return 0; return 0;
err_drm_gem_object_put_unlocked: err_drm_gem_object_put:
drm_gem_object_put_unlocked(&gbo->bo.base); drm_gem_object_put(&gbo->bo.base);
return ret; return ret;
} }
EXPORT_SYMBOL(drm_gem_vram_fill_create_dumb); EXPORT_SYMBOL(drm_gem_vram_fill_create_dumb);
...@@ -737,7 +737,7 @@ int drm_gem_vram_driver_dumb_mmap_offset(struct drm_file *file, ...@@ -737,7 +737,7 @@ int drm_gem_vram_driver_dumb_mmap_offset(struct drm_file *file,
gbo = drm_gem_vram_of_gem(gem); gbo = drm_gem_vram_of_gem(gem);
*offset = drm_gem_vram_mmap_offset(gbo); *offset = drm_gem_vram_mmap_offset(gbo);
drm_gem_object_put_unlocked(gem); drm_gem_object_put(gem);
return 0; return 0;
} }
......
...@@ -270,7 +270,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf) ...@@ -270,7 +270,7 @@ void drm_gem_dmabuf_release(struct dma_buf *dma_buf)
struct drm_device *dev = obj->dev; struct drm_device *dev = obj->dev;
/* drop the reference on the export fd holds */ /* drop the reference on the export fd holds */
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
drm_dev_put(dev); drm_dev_put(dev);
} }
...@@ -329,7 +329,7 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev, ...@@ -329,7 +329,7 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,
/* _handle_create_tail unconditionally unlocks dev->object_name_lock. */ /* _handle_create_tail unconditionally unlocks dev->object_name_lock. */
ret = drm_gem_handle_create_tail(file_priv, obj, handle); ret = drm_gem_handle_create_tail(file_priv, obj, handle);
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
if (ret) if (ret)
goto out_put; goto out_put;
...@@ -500,7 +500,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev, ...@@ -500,7 +500,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
fail_put_dmabuf: fail_put_dmabuf:
dma_buf_put(dmabuf); dma_buf_put(dmabuf);
out: out:
drm_gem_object_put_unlocked(obj); drm_gem_object_put(obj);
out_unlock: out_unlock:
mutex_unlock(&file_priv->prime.lock); mutex_unlock(&file_priv->prime.lock);
......
...@@ -188,7 +188,7 @@ struct drm_gem_object { ...@@ -188,7 +188,7 @@ struct drm_gem_object {
* Reference count of this object * Reference count of this object
* *
* Please use drm_gem_object_get() to acquire and drm_gem_object_put_locked() * Please use drm_gem_object_get() to acquire and drm_gem_object_put_locked()
* or drm_gem_object_put_unlocked() to release a reference to a GEM * or drm_gem_object_put() to release a reference to a GEM
* buffer object. * buffer object.
*/ */
struct kref refcount; struct kref refcount;
......
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