aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_crtc.c31
-rw-r--r--include/drm/drm_crtc.h2
2 files changed, 19 insertions, 14 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 293eb4c24f35..37a3e0791ddf 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -257,21 +257,11 @@ void drm_connector_ida_destroy(void)
257 257
258/** 258/**
259 * drm_get_encoder_name - return a string for encoder 259 * drm_get_encoder_name - return a string for encoder
260 * @encoder: encoder to compute name of 260 * @encoder: the encoder to get name for
261 *
262 * Note that the buffer used by this function is globally shared and owned by
263 * the function itself.
264 *
265 * FIXME: This isn't really multithreading safe.
266 */ 261 */
267const char *drm_get_encoder_name(const struct drm_encoder *encoder) 262const char *drm_get_encoder_name(const struct drm_encoder *encoder)
268{ 263{
269 static char buf[32]; 264 return encoder->name;
270
271 snprintf(buf, 32, "%s-%d",
272 drm_encoder_enum_list[encoder->encoder_type].name,
273 encoder->base.id);
274 return buf;
275} 265}
276EXPORT_SYMBOL(drm_get_encoder_name); 266EXPORT_SYMBOL(drm_get_encoder_name);
277 267
@@ -986,16 +976,27 @@ int drm_encoder_init(struct drm_device *dev,
986 976
987 ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER); 977 ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER);
988 if (ret) 978 if (ret)
989 goto out; 979 goto out_unlock;
990 980
991 encoder->dev = dev; 981 encoder->dev = dev;
992 encoder->encoder_type = encoder_type; 982 encoder->encoder_type = encoder_type;
993 encoder->funcs = funcs; 983 encoder->funcs = funcs;
984 encoder->name = kasprintf(GFP_KERNEL, "%s-%d",
985 drm_encoder_enum_list[encoder_type].name,
986 encoder->base.id);
987 if (!encoder->name) {
988 ret = -ENOMEM;
989 goto out_put;
990 }
994 991
995 list_add_tail(&encoder->head, &dev->mode_config.encoder_list); 992 list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
996 dev->mode_config.num_encoder++; 993 dev->mode_config.num_encoder++;
997 994
998 out: 995out_put:
996 if (ret)
997 drm_mode_object_put(dev, &encoder->base);
998
999out_unlock:
999 drm_modeset_unlock_all(dev); 1000 drm_modeset_unlock_all(dev);
1000 1001
1001 return ret; 1002 return ret;
@@ -1013,6 +1014,8 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
1013 struct drm_device *dev = encoder->dev; 1014 struct drm_device *dev = encoder->dev;
1014 drm_modeset_lock_all(dev); 1015 drm_modeset_lock_all(dev);
1015 drm_mode_object_put(dev, &encoder->base); 1016 drm_mode_object_put(dev, &encoder->base);
1017 kfree(encoder->name);
1018 encoder->name = NULL;
1016 list_del(&encoder->head); 1019 list_del(&encoder->head);
1017 dev->mode_config.num_encoder--; 1020 dev->mode_config.num_encoder--;
1018 drm_modeset_unlock_all(dev); 1021 drm_modeset_unlock_all(dev);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b5c97d5b2654..5c1c31cc11cd 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -400,6 +400,7 @@ struct drm_encoder_funcs {
400 * @dev: parent DRM device 400 * @dev: parent DRM device
401 * @head: list management 401 * @head: list management
402 * @base: base KMS object 402 * @base: base KMS object
403 * @name: encoder name
403 * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h 404 * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
404 * @possible_crtcs: bitmask of potential CRTC bindings 405 * @possible_crtcs: bitmask of potential CRTC bindings
405 * @possible_clones: bitmask of potential sibling encoders for cloning 406 * @possible_clones: bitmask of potential sibling encoders for cloning
@@ -416,6 +417,7 @@ struct drm_encoder {
416 struct list_head head; 417 struct list_head head;
417 418
418 struct drm_mode_object base; 419 struct drm_mode_object base;
420 char *name;
419 int encoder_type; 421 int encoder_type;
420 uint32_t possible_crtcs; 422 uint32_t possible_crtcs;
421 uint32_t possible_clones; 423 uint32_t possible_clones;