Commit 7c8f6d25 authored by Dave Airlie's avatar Dave Airlie

drm/mode: rework drm_mode_object_put to drm_mode_object_unregister.

This changes the code to handle being called multiple times without
side effects. The new names seems more suitable for what it does.
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 9a297b36
...@@ -323,19 +323,24 @@ static void drm_mode_object_register(struct drm_device *dev, ...@@ -323,19 +323,24 @@ static void drm_mode_object_register(struct drm_device *dev,
} }
/** /**
* drm_mode_object_put - free a modeset identifer * drm_mode_object_unregister - free a modeset identifer
* @dev: DRM device * @dev: DRM device
* @object: object to free * @object: object to free
* *
* Free @id from @dev's unique identifier pool. Note that despite the _get * Free @id from @dev's unique identifier pool.
* postfix modeset identifiers are _not_ reference counted. Hence don't use this * This function can be called multiple times, and guards against
* multiple removals.
* These modeset identifiers are _not_ reference counted. Hence don't use this
* for reference counted modeset objects like framebuffers. * for reference counted modeset objects like framebuffers.
*/ */
void drm_mode_object_put(struct drm_device *dev, void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object) struct drm_mode_object *object)
{ {
mutex_lock(&dev->mode_config.idr_mutex); mutex_lock(&dev->mode_config.idr_mutex);
if (object->id) {
idr_remove(&dev->mode_config.crtc_idr, object->id); idr_remove(&dev->mode_config.crtc_idr, object->id);
object->id = 0;
}
mutex_unlock(&dev->mode_config.idr_mutex); mutex_unlock(&dev->mode_config.idr_mutex);
} }
...@@ -705,7 +710,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, ...@@ -705,7 +710,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
drm_num_crtcs(dev)); drm_num_crtcs(dev));
} }
if (!crtc->name) { if (!crtc->name) {
drm_mode_object_put(dev, &crtc->base); drm_mode_object_unregister(dev, &crtc->base);
return -ENOMEM; return -ENOMEM;
} }
...@@ -747,7 +752,7 @@ void drm_crtc_cleanup(struct drm_crtc *crtc) ...@@ -747,7 +752,7 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
drm_modeset_lock_fini(&crtc->mutex); drm_modeset_lock_fini(&crtc->mutex);
drm_mode_object_put(dev, &crtc->base); drm_mode_object_unregister(dev, &crtc->base);
list_del(&crtc->head); list_del(&crtc->head);
dev->mode_config.num_crtc--; dev->mode_config.num_crtc--;
...@@ -972,7 +977,7 @@ int drm_connector_init(struct drm_device *dev, ...@@ -972,7 +977,7 @@ int drm_connector_init(struct drm_device *dev,
ida_remove(&config->connector_ida, connector->connector_id); ida_remove(&config->connector_ida, connector->connector_id);
out_put: out_put:
if (ret) if (ret)
drm_mode_object_put(dev, &connector->base); drm_mode_object_unregister(dev, &connector->base);
out_unlock: out_unlock:
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
...@@ -1010,7 +1015,7 @@ void drm_connector_cleanup(struct drm_connector *connector) ...@@ -1010,7 +1015,7 @@ void drm_connector_cleanup(struct drm_connector *connector)
connector->connector_id); connector->connector_id);
kfree(connector->display_info.bus_formats); kfree(connector->display_info.bus_formats);
drm_mode_object_put(dev, &connector->base); drm_mode_object_unregister(dev, &connector->base);
kfree(connector->name); kfree(connector->name);
connector->name = NULL; connector->name = NULL;
list_del(&connector->head); list_del(&connector->head);
...@@ -1178,7 +1183,7 @@ int drm_encoder_init(struct drm_device *dev, ...@@ -1178,7 +1183,7 @@ int drm_encoder_init(struct drm_device *dev,
out_put: out_put:
if (ret) if (ret)
drm_mode_object_put(dev, &encoder->base); drm_mode_object_unregister(dev, &encoder->base);
out_unlock: out_unlock:
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
...@@ -1221,7 +1226,7 @@ void drm_encoder_cleanup(struct drm_encoder *encoder) ...@@ -1221,7 +1226,7 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
drm_mode_object_put(dev, &encoder->base); drm_mode_object_unregister(dev, &encoder->base);
kfree(encoder->name); kfree(encoder->name);
list_del(&encoder->head); list_del(&encoder->head);
dev->mode_config.num_encoder--; dev->mode_config.num_encoder--;
...@@ -1282,7 +1287,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, ...@@ -1282,7 +1287,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
GFP_KERNEL); GFP_KERNEL);
if (!plane->format_types) { if (!plane->format_types) {
DRM_DEBUG_KMS("out of memory when allocating plane\n"); DRM_DEBUG_KMS("out of memory when allocating plane\n");
drm_mode_object_put(dev, &plane->base); drm_mode_object_unregister(dev, &plane->base);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1298,7 +1303,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, ...@@ -1298,7 +1303,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
} }
if (!plane->name) { if (!plane->name) {
kfree(plane->format_types); kfree(plane->format_types);
drm_mode_object_put(dev, &plane->base); drm_mode_object_unregister(dev, &plane->base);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1378,7 +1383,7 @@ void drm_plane_cleanup(struct drm_plane *plane) ...@@ -1378,7 +1383,7 @@ void drm_plane_cleanup(struct drm_plane *plane)
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
kfree(plane->format_types); kfree(plane->format_types);
drm_mode_object_put(dev, &plane->base); drm_mode_object_unregister(dev, &plane->base);
BUG_ON(list_empty(&plane->head)); BUG_ON(list_empty(&plane->head));
...@@ -4069,7 +4074,7 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property) ...@@ -4069,7 +4074,7 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property)
if (property->num_values) if (property->num_values)
kfree(property->values); kfree(property->values);
drm_mode_object_put(dev, &property->base); drm_mode_object_unregister(dev, &property->base);
list_del(&property->head); list_del(&property->head);
kfree(property); kfree(property);
} }
...@@ -4347,7 +4352,7 @@ static void drm_property_free_blob(struct kref *kref) ...@@ -4347,7 +4352,7 @@ static void drm_property_free_blob(struct kref *kref)
list_del(&blob->head_global); list_del(&blob->head_global);
list_del(&blob->head_file); list_del(&blob->head_file);
drm_mode_object_put(blob->dev, &blob->base); drm_mode_object_unregister(blob->dev, &blob->base);
kfree(blob); kfree(blob);
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
int drm_mode_object_get(struct drm_device *dev, int drm_mode_object_get(struct drm_device *dev,
struct drm_mode_object *obj, uint32_t obj_type); struct drm_mode_object *obj, uint32_t obj_type);
void drm_mode_object_put(struct drm_device *dev, void drm_mode_object_unregister(struct drm_device *dev,
struct drm_mode_object *object); struct drm_mode_object *object);
/* drm_atomic.c */ /* drm_atomic.c */
......
...@@ -98,7 +98,7 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode) ...@@ -98,7 +98,7 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
if (!mode) if (!mode)
return; return;
drm_mode_object_put(dev, &mode->base); drm_mode_object_unregister(dev, &mode->base);
kfree(mode); kfree(mode);
} }
......
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