Commit fe4be3b8 authored by Noralf Trønnes's avatar Noralf Trønnes

drm/tinydrm: Embed the mode in tinydrm_connector

Embed the mode in tinydrm_connector instead of doing an devm_ allocation.
Remove unnecessary use of ret variable at the end of
tinydrm_display_pipe_init().
Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Reviewed-by: default avatarDavid Lechner <david@lechnology.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180110185940.53841-7-noralf@tronnes.org
parent f730eceb
......@@ -15,7 +15,7 @@
struct tinydrm_connector {
struct drm_connector base;
const struct drm_display_mode *mode;
struct drm_display_mode mode;
};
static inline struct tinydrm_connector *
......@@ -29,7 +29,7 @@ static int tinydrm_connector_get_modes(struct drm_connector *connector)
struct tinydrm_connector *tconn = to_tinydrm_connector(connector);
struct drm_display_mode *mode;
mode = drm_mode_duplicate(connector->dev, tconn->mode);
mode = drm_mode_duplicate(connector->dev, &tconn->mode);
if (!mode) {
DRM_ERROR("Failed to duplicate mode\n");
return 0;
......@@ -92,7 +92,7 @@ tinydrm_connector_create(struct drm_device *drm,
if (!tconn)
return ERR_PTR(-ENOMEM);
tconn->mode = mode;
drm_mode_copy(&tconn->mode, mode);
connector = &tconn->base;
drm_connector_helper_add(connector, &tinydrm_connector_hfuncs);
......@@ -199,35 +199,27 @@ tinydrm_display_pipe_init(struct tinydrm_device *tdev,
unsigned int rotation)
{
struct drm_device *drm = tdev->drm;
struct drm_display_mode *mode_copy;
struct drm_display_mode mode_copy;
struct drm_connector *connector;
int ret;
mode_copy = devm_kmalloc(drm->dev, sizeof(*mode_copy), GFP_KERNEL);
if (!mode_copy)
return -ENOMEM;
*mode_copy = *mode;
ret = tinydrm_rotate_mode(mode_copy, rotation);
drm_mode_copy(&mode_copy, mode);
ret = tinydrm_rotate_mode(&mode_copy, rotation);
if (ret) {
DRM_ERROR("Illegal rotation value %u\n", rotation);
return -EINVAL;
}
drm->mode_config.min_width = mode_copy->hdisplay;
drm->mode_config.max_width = mode_copy->hdisplay;
drm->mode_config.min_height = mode_copy->vdisplay;
drm->mode_config.max_height = mode_copy->vdisplay;
drm->mode_config.min_width = mode_copy.hdisplay;
drm->mode_config.max_width = mode_copy.hdisplay;
drm->mode_config.min_height = mode_copy.vdisplay;
drm->mode_config.max_height = mode_copy.vdisplay;
connector = tinydrm_connector_create(drm, mode_copy, connector_type);
connector = tinydrm_connector_create(drm, &mode_copy, connector_type);
if (IS_ERR(connector))
return PTR_ERR(connector);
ret = drm_simple_display_pipe_init(drm, &tdev->pipe, funcs, formats,
format_count, NULL, connector);
if (ret)
return ret;
return 0;
return drm_simple_display_pipe_init(drm, &tdev->pipe, funcs, formats,
format_count, NULL, connector);
}
EXPORT_SYMBOL(tinydrm_display_pipe_init);
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