Commit 2135ea7a authored by Thierry Reding's avatar Thierry Reding

drm: Rename drm_mode_object_get()

Subsequent patches will introduce reference counting APIs that are more
consistent with similar APIs throughout the Linux kernel. These APIs use
the _get() and _put() suffixes and will collide with this existing
function.

Rename the function to drm_mode_object_add() which is a slightly more
accurate description of what it does. Also the kerneldoc for this
function gives an indication that it's badly named because it doesn't
actually acquire a reference to anything.
Reviewed-by: default avatarSean Paul <seanpaul@chromium.org>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170228144643.5668-2-thierry.reding@gmail.com
parent 499447db
...@@ -175,7 +175,7 @@ int drm_connector_init(struct drm_device *dev, ...@@ -175,7 +175,7 @@ int drm_connector_init(struct drm_device *dev,
struct ida *connector_ida = struct ida *connector_ida =
&drm_connector_enum_list[connector_type].ida; &drm_connector_enum_list[connector_type].ida;
ret = drm_mode_object_get_reg(dev, &connector->base, ret = __drm_mode_object_add(dev, &connector->base,
DRM_MODE_OBJECT_CONNECTOR, DRM_MODE_OBJECT_CONNECTOR,
false, drm_connector_free); false, drm_connector_free);
if (ret) if (ret)
......
...@@ -282,7 +282,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, ...@@ -282,7 +282,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
spin_lock_init(&crtc->commit_lock); spin_lock_init(&crtc->commit_lock);
drm_modeset_lock_init(&crtc->mutex); drm_modeset_lock_init(&crtc->mutex);
ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); ret = drm_mode_object_add(dev, &crtc->base, DRM_MODE_OBJECT_CRTC);
if (ret) if (ret)
return ret; return ret;
......
...@@ -98,15 +98,13 @@ int drm_mode_destroyblob_ioctl(struct drm_device *dev, ...@@ -98,15 +98,13 @@ int drm_mode_destroyblob_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv); void *data, struct drm_file *file_priv);
/* drm_mode_object.c */ /* drm_mode_object.c */
int drm_mode_object_get_reg(struct drm_device *dev, int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
struct drm_mode_object *obj, uint32_t obj_type, bool register_obj,
uint32_t obj_type,
bool register_obj,
void (*obj_free_cb)(struct kref *kref)); void (*obj_free_cb)(struct kref *kref));
int drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
uint32_t obj_type);
void drm_mode_object_register(struct drm_device *dev, void drm_mode_object_register(struct drm_device *dev,
struct drm_mode_object *obj); struct drm_mode_object *obj);
int drm_mode_object_get(struct drm_device *dev,
struct drm_mode_object *obj, uint32_t obj_type);
struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev, struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,
uint32_t id, uint32_t type); uint32_t id, uint32_t type);
void drm_mode_object_unregister(struct drm_device *dev, void drm_mode_object_unregister(struct drm_device *dev,
......
...@@ -110,7 +110,7 @@ int drm_encoder_init(struct drm_device *dev, ...@@ -110,7 +110,7 @@ int drm_encoder_init(struct drm_device *dev,
{ {
int ret; int ret;
ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER); ret = drm_mode_object_add(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER);
if (ret) if (ret)
return ret; return ret;
......
...@@ -638,7 +638,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb, ...@@ -638,7 +638,7 @@ int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
fb->funcs = funcs; fb->funcs = funcs;
ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB, ret = __drm_mode_object_add(dev, &fb->base, DRM_MODE_OBJECT_FB,
false, drm_framebuffer_free); false, drm_framebuffer_free);
if (ret) if (ret)
goto out; goto out;
......
...@@ -31,10 +31,8 @@ ...@@ -31,10 +31,8 @@
* Internal function to assign a slot in the object idr and optionally * Internal function to assign a slot in the object idr and optionally
* register the object into the idr. * register the object into the idr.
*/ */
int drm_mode_object_get_reg(struct drm_device *dev, int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
struct drm_mode_object *obj, uint32_t obj_type, bool register_obj,
uint32_t obj_type,
bool register_obj,
void (*obj_free_cb)(struct kref *kref)) void (*obj_free_cb)(struct kref *kref))
{ {
int ret; int ret;
...@@ -59,23 +57,21 @@ int drm_mode_object_get_reg(struct drm_device *dev, ...@@ -59,23 +57,21 @@ int drm_mode_object_get_reg(struct drm_device *dev,
} }
/** /**
* drm_mode_object_get - allocate a new modeset identifier * drm_mode_object_add - allocate a new modeset identifier
* @dev: DRM device * @dev: DRM device
* @obj: object pointer, used to generate unique ID * @obj: object pointer, used to generate unique ID
* @obj_type: object type * @obj_type: object type
* *
* Create a unique identifier based on @ptr in @dev's identifier space. Used * Create a unique identifier based on @ptr in @dev's identifier space. Used
* for tracking modes, CRTCs and connectors. Note that despite the _get postfix * for tracking modes, CRTCs and connectors.
* modeset identifiers are _not_ reference counted. Hence don't use this for
* reference counted modeset objects like framebuffers.
* *
* Returns: * Returns:
* Zero on success, error code on failure. * Zero on success, error code on failure.
*/ */
int drm_mode_object_get(struct drm_device *dev, int drm_mode_object_add(struct drm_device *dev,
struct drm_mode_object *obj, uint32_t obj_type) struct drm_mode_object *obj, uint32_t obj_type)
{ {
return drm_mode_object_get_reg(dev, obj, obj_type, true, NULL); return __drm_mode_object_add(dev, obj, obj_type, true, NULL);
} }
void drm_mode_object_register(struct drm_device *dev, void drm_mode_object_register(struct drm_device *dev,
......
...@@ -71,7 +71,7 @@ struct drm_display_mode *drm_mode_create(struct drm_device *dev) ...@@ -71,7 +71,7 @@ struct drm_display_mode *drm_mode_create(struct drm_device *dev)
if (!nmode) if (!nmode)
return NULL; return NULL;
if (drm_mode_object_get(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) { if (drm_mode_object_add(dev, &nmode->base, DRM_MODE_OBJECT_MODE)) {
kfree(nmode); kfree(nmode);
return NULL; return NULL;
} }
......
...@@ -88,7 +88,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, ...@@ -88,7 +88,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
struct drm_mode_config *config = &dev->mode_config; struct drm_mode_config *config = &dev->mode_config;
int ret; int ret;
ret = drm_mode_object_get(dev, &plane->base, DRM_MODE_OBJECT_PLANE); ret = drm_mode_object_add(dev, &plane->base, DRM_MODE_OBJECT_PLANE);
if (ret) if (ret)
return ret; return ret;
......
...@@ -91,7 +91,7 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags, ...@@ -91,7 +91,7 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
goto fail; goto fail;
} }
ret = drm_mode_object_get(dev, &property->base, DRM_MODE_OBJECT_PROPERTY); ret = drm_mode_object_add(dev, &property->base, DRM_MODE_OBJECT_PROPERTY);
if (ret) if (ret)
goto fail; goto fail;
...@@ -570,7 +570,7 @@ drm_property_create_blob(struct drm_device *dev, size_t length, ...@@ -570,7 +570,7 @@ drm_property_create_blob(struct drm_device *dev, size_t length,
if (data) if (data)
memcpy(blob->data, data, length); memcpy(blob->data, data, length);
ret = drm_mode_object_get_reg(dev, &blob->base, DRM_MODE_OBJECT_BLOB, ret = __drm_mode_object_add(dev, &blob->base, DRM_MODE_OBJECT_BLOB,
true, drm_property_free_blob); true, drm_property_free_blob);
if (ret) { if (ret) {
kfree(blob); kfree(blob);
......
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