drm: store encoder name in encoder struct
This makes drm_get_encoder_name() thread safe. 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>
This commit is contained in:
parent
2abdd3137e
commit
e5748946e9
|
@ -257,21 +257,11 @@ void drm_connector_ida_destroy(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* drm_get_encoder_name - return a string for encoder
|
* drm_get_encoder_name - return a string for encoder
|
||||||
* @encoder: encoder to compute name of
|
* @encoder: the encoder to get name for
|
||||||
*
|
|
||||||
* Note that the buffer used by this function is globally shared and owned by
|
|
||||||
* the function itself.
|
|
||||||
*
|
|
||||||
* FIXME: This isn't really multithreading safe.
|
|
||||||
*/
|
*/
|
||||||
const char *drm_get_encoder_name(const struct drm_encoder *encoder)
|
const char *drm_get_encoder_name(const struct drm_encoder *encoder)
|
||||||
{
|
{
|
||||||
static char buf[32];
|
return encoder->name;
|
||||||
|
|
||||||
snprintf(buf, 32, "%s-%d",
|
|
||||||
drm_encoder_enum_list[encoder->encoder_type].name,
|
|
||||||
encoder->base.id);
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(drm_get_encoder_name);
|
EXPORT_SYMBOL(drm_get_encoder_name);
|
||||||
|
|
||||||
|
@ -986,16 +976,27 @@ int drm_encoder_init(struct drm_device *dev,
|
||||||
|
|
||||||
ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER);
|
ret = drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out_unlock;
|
||||||
|
|
||||||
encoder->dev = dev;
|
encoder->dev = dev;
|
||||||
encoder->encoder_type = encoder_type;
|
encoder->encoder_type = encoder_type;
|
||||||
encoder->funcs = funcs;
|
encoder->funcs = funcs;
|
||||||
|
encoder->name = kasprintf(GFP_KERNEL, "%s-%d",
|
||||||
|
drm_encoder_enum_list[encoder_type].name,
|
||||||
|
encoder->base.id);
|
||||||
|
if (!encoder->name) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto out_put;
|
||||||
|
}
|
||||||
|
|
||||||
list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
|
list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
|
||||||
dev->mode_config.num_encoder++;
|
dev->mode_config.num_encoder++;
|
||||||
|
|
||||||
out:
|
out_put:
|
||||||
|
if (ret)
|
||||||
|
drm_mode_object_put(dev, &encoder->base);
|
||||||
|
|
||||||
|
out_unlock:
|
||||||
drm_modeset_unlock_all(dev);
|
drm_modeset_unlock_all(dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1013,6 +1014,8 @@ 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_put(dev, &encoder->base);
|
||||||
|
kfree(encoder->name);
|
||||||
|
encoder->name = NULL;
|
||||||
list_del(&encoder->head);
|
list_del(&encoder->head);
|
||||||
dev->mode_config.num_encoder--;
|
dev->mode_config.num_encoder--;
|
||||||
drm_modeset_unlock_all(dev);
|
drm_modeset_unlock_all(dev);
|
||||||
|
|
|
@ -400,6 +400,7 @@ struct drm_encoder_funcs {
|
||||||
* @dev: parent DRM device
|
* @dev: parent DRM device
|
||||||
* @head: list management
|
* @head: list management
|
||||||
* @base: base KMS object
|
* @base: base KMS object
|
||||||
|
* @name: encoder name
|
||||||
* @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
|
* @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
|
||||||
* @possible_crtcs: bitmask of potential CRTC bindings
|
* @possible_crtcs: bitmask of potential CRTC bindings
|
||||||
* @possible_clones: bitmask of potential sibling encoders for cloning
|
* @possible_clones: bitmask of potential sibling encoders for cloning
|
||||||
|
@ -416,6 +417,7 @@ struct drm_encoder {
|
||||||
struct list_head head;
|
struct list_head head;
|
||||||
|
|
||||||
struct drm_mode_object base;
|
struct drm_mode_object base;
|
||||||
|
char *name;
|
||||||
int encoder_type;
|
int encoder_type;
|
||||||
uint32_t possible_crtcs;
|
uint32_t possible_crtcs;
|
||||||
uint32_t possible_clones;
|
uint32_t possible_clones;
|
||||||
|
|
Loading…
Reference in New Issue