diff options
author | Jani Nikula <jani.nikula@intel.com> | 2014-05-14 09:58:19 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2014-05-29 21:58:41 -0400 |
commit | 2abdd3137e78adca69b0722307aa2ef89f2cf3b6 (patch) | |
tree | 8b78eaf6cf41b5e0956d2cdc4b62c65ab1960893 /drivers/gpu/drm/drm_crtc.c | |
parent | b8380580836bf81d032da6099879da9f6b515325 (diff) |
drm: store connector name in connector struct (v2)
This makes drm_get_connector_name() thread safe.
[airlied: fix to build.]
Reference: http://lkml.kernel.org/r/645ee6e22cad47d38a2b35c21c8d5fe3@DC1-MBX-01.ptsecurity.ru
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 34f0bf18d80d..293eb4c24f35 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -277,21 +277,11 @@ EXPORT_SYMBOL(drm_get_encoder_name); | |||
277 | 277 | ||
278 | /** | 278 | /** |
279 | * drm_get_connector_name - return a string for connector | 279 | * drm_get_connector_name - return a string for connector |
280 | * @connector: connector to compute name of | 280 | * @connector: the connector to get name for |
281 | * | ||
282 | * Note that the buffer used by this function is globally shared and owned by | ||
283 | * the function itself. | ||
284 | * | ||
285 | * FIXME: This isn't really multithreading safe. | ||
286 | */ | 281 | */ |
287 | const char *drm_get_connector_name(const struct drm_connector *connector) | 282 | const char *drm_get_connector_name(const struct drm_connector *connector) |
288 | { | 283 | { |
289 | static char buf[32]; | 284 | return connector->name; |
290 | |||
291 | snprintf(buf, 32, "%s-%d", | ||
292 | drm_connector_enum_list[connector->connector_type].name, | ||
293 | connector->connector_type_id); | ||
294 | return buf; | ||
295 | } | 285 | } |
296 | EXPORT_SYMBOL(drm_get_connector_name); | 286 | EXPORT_SYMBOL(drm_get_connector_name); |
297 | 287 | ||
@@ -824,7 +814,7 @@ int drm_connector_init(struct drm_device *dev, | |||
824 | 814 | ||
825 | ret = drm_mode_object_get(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR); | 815 | ret = drm_mode_object_get(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR); |
826 | if (ret) | 816 | if (ret) |
827 | goto out; | 817 | goto out_unlock; |
828 | 818 | ||
829 | connector->base.properties = &connector->properties; | 819 | connector->base.properties = &connector->properties; |
830 | connector->dev = dev; | 820 | connector->dev = dev; |
@@ -834,9 +824,17 @@ int drm_connector_init(struct drm_device *dev, | |||
834 | ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); | 824 | ida_simple_get(connector_ida, 1, 0, GFP_KERNEL); |
835 | if (connector->connector_type_id < 0) { | 825 | if (connector->connector_type_id < 0) { |
836 | ret = connector->connector_type_id; | 826 | ret = connector->connector_type_id; |
837 | drm_mode_object_put(dev, &connector->base); | 827 | goto out_put; |
838 | goto out; | ||
839 | } | 828 | } |
829 | connector->name = | ||
830 | kasprintf(GFP_KERNEL, "%s-%d", | ||
831 | drm_connector_enum_list[connector_type].name, | ||
832 | connector->connector_type_id); | ||
833 | if (!connector->name) { | ||
834 | ret = -ENOMEM; | ||
835 | goto out_put; | ||
836 | } | ||
837 | |||
840 | INIT_LIST_HEAD(&connector->probed_modes); | 838 | INIT_LIST_HEAD(&connector->probed_modes); |
841 | INIT_LIST_HEAD(&connector->modes); | 839 | INIT_LIST_HEAD(&connector->modes); |
842 | connector->edid_blob_ptr = NULL; | 840 | connector->edid_blob_ptr = NULL; |
@@ -853,7 +851,11 @@ int drm_connector_init(struct drm_device *dev, | |||
853 | drm_object_attach_property(&connector->base, | 851 | drm_object_attach_property(&connector->base, |
854 | dev->mode_config.dpms_property, 0); | 852 | dev->mode_config.dpms_property, 0); |
855 | 853 | ||
856 | out: | 854 | out_put: |
855 | if (ret) | ||
856 | drm_mode_object_put(dev, &connector->base); | ||
857 | |||
858 | out_unlock: | ||
857 | drm_modeset_unlock_all(dev); | 859 | drm_modeset_unlock_all(dev); |
858 | 860 | ||
859 | return ret; | 861 | return ret; |
@@ -881,6 +883,8 @@ void drm_connector_cleanup(struct drm_connector *connector) | |||
881 | connector->connector_type_id); | 883 | connector->connector_type_id); |
882 | 884 | ||
883 | drm_mode_object_put(dev, &connector->base); | 885 | drm_mode_object_put(dev, &connector->base); |
886 | kfree(connector->name); | ||
887 | connector->name = NULL; | ||
884 | list_del(&connector->head); | 888 | list_del(&connector->head); |
885 | dev->mode_config.num_connector--; | 889 | dev->mode_config.num_connector--; |
886 | } | 890 | } |