drm: Introduce drm_mode_object_{get,put}()

For consistency with other reference counting APIs in the kernel, add
drm_mode_object_get() and drm_mode_object_put() to reference count DRM
mode objects.

Compatibility aliases are added to keep existing code working. To help
speed up the transition, all the instances of the old functions in the
DRM core are already replaced in this commit.

A semantic patch is provided that can be used to convert all drivers to
the new helpers.

Reviewed-by: Sean Paul <seanpaul@chromium.org>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170228144643.5668-3-thierry.reding@gmail.com
This commit is contained in:
Thierry Reding
2017-02-28 15:46:38 +01:00
parent 2135ea7aaf
commit 020a218f95
5 changed files with 95 additions and 29 deletions

View File

@@ -2238,13 +2238,13 @@ retry:
}
if (!obj->properties) {
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
ret = -ENOENT;
goto out;
}
if (get_user(count_props, count_props_ptr + copied_objs)) {
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
ret = -EFAULT;
goto out;
}
@@ -2257,14 +2257,14 @@ retry:
struct drm_property *prop;
if (get_user(prop_id, props_ptr + copied_props)) {
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
ret = -EFAULT;
goto out;
}
prop = drm_mode_obj_find_prop_id(obj, prop_id);
if (!prop) {
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
ret = -ENOENT;
goto out;
}
@@ -2272,14 +2272,14 @@ retry:
if (copy_from_user(&prop_value,
prop_values_ptr + copied_props,
sizeof(prop_value))) {
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
ret = -EFAULT;
goto out;
}
ret = atomic_set_prop(state, obj, prop, prop_value);
if (ret) {
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
goto out;
}
@@ -2292,7 +2292,7 @@ retry:
plane_mask |= (1 << drm_plane_index(plane));
plane->old_fb = plane->fb;
}
drm_mode_object_unreference(obj);
drm_mode_object_put(obj);
}
ret = prepare_crtc_signaling(dev, state, arg, file_priv, &fence_state,