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: Noralf Trønnes <noralf@tronnes.org> Reviewed-by: David Lechner <david@lechnology.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180110185940.53841-7-noralf@tronnes.org
This commit is contained in:
parent
f730eceb42
commit
fe4be3b8f3
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
struct tinydrm_connector {
|
struct tinydrm_connector {
|
||||||
struct drm_connector base;
|
struct drm_connector base;
|
||||||
const struct drm_display_mode *mode;
|
struct drm_display_mode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct tinydrm_connector *
|
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 tinydrm_connector *tconn = to_tinydrm_connector(connector);
|
||||||
struct drm_display_mode *mode;
|
struct drm_display_mode *mode;
|
||||||
|
|
||||||
mode = drm_mode_duplicate(connector->dev, tconn->mode);
|
mode = drm_mode_duplicate(connector->dev, &tconn->mode);
|
||||||
if (!mode) {
|
if (!mode) {
|
||||||
DRM_ERROR("Failed to duplicate mode\n");
|
DRM_ERROR("Failed to duplicate mode\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -92,7 +92,7 @@ tinydrm_connector_create(struct drm_device *drm,
|
||||||
if (!tconn)
|
if (!tconn)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
tconn->mode = mode;
|
drm_mode_copy(&tconn->mode, mode);
|
||||||
connector = &tconn->base;
|
connector = &tconn->base;
|
||||||
|
|
||||||
drm_connector_helper_add(connector, &tinydrm_connector_hfuncs);
|
drm_connector_helper_add(connector, &tinydrm_connector_hfuncs);
|
||||||
|
@ -199,35 +199,27 @@ tinydrm_display_pipe_init(struct tinydrm_device *tdev,
|
||||||
unsigned int rotation)
|
unsigned int rotation)
|
||||||
{
|
{
|
||||||
struct drm_device *drm = tdev->drm;
|
struct drm_device *drm = tdev->drm;
|
||||||
struct drm_display_mode *mode_copy;
|
struct drm_display_mode mode_copy;
|
||||||
struct drm_connector *connector;
|
struct drm_connector *connector;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mode_copy = devm_kmalloc(drm->dev, sizeof(*mode_copy), GFP_KERNEL);
|
drm_mode_copy(&mode_copy, mode);
|
||||||
if (!mode_copy)
|
ret = tinydrm_rotate_mode(&mode_copy, rotation);
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
*mode_copy = *mode;
|
|
||||||
ret = tinydrm_rotate_mode(mode_copy, rotation);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_ERROR("Illegal rotation value %u\n", rotation);
|
DRM_ERROR("Illegal rotation value %u\n", rotation);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm->mode_config.min_width = mode_copy->hdisplay;
|
drm->mode_config.min_width = mode_copy.hdisplay;
|
||||||
drm->mode_config.max_width = mode_copy->hdisplay;
|
drm->mode_config.max_width = mode_copy.hdisplay;
|
||||||
drm->mode_config.min_height = mode_copy->vdisplay;
|
drm->mode_config.min_height = mode_copy.vdisplay;
|
||||||
drm->mode_config.max_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))
|
if (IS_ERR(connector))
|
||||||
return PTR_ERR(connector);
|
return PTR_ERR(connector);
|
||||||
|
|
||||||
ret = drm_simple_display_pipe_init(drm, &tdev->pipe, funcs, formats,
|
return drm_simple_display_pipe_init(drm, &tdev->pipe, funcs, formats,
|
||||||
format_count, NULL, connector);
|
format_count, NULL, connector);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(tinydrm_display_pipe_init);
|
EXPORT_SYMBOL(tinydrm_display_pipe_init);
|
||||||
|
|
Loading…
Reference in New Issue