Since crtc maps 1:1 to the device there is no point in allocating it separately, another benefit is possibility of direct initialisation of its fields which is more readable and allows further expansion. Signed-off-by: Andrzej Hajda <a.hajda@xxxxxxxxxxx> --- drivers/gpu/drm/exynos/exynos_mixer.c | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 1c82265acf0a..7fcefcbe68db 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -99,7 +99,7 @@ struct mixer_context { struct platform_device *pdev; struct device *dev; struct drm_device *drm_dev; - struct exynos_drm_crtc *crtc; + struct exynos_drm_crtc crtc; struct exynos_drm_plane planes[MIXER_WIN_NR]; unsigned long flags; @@ -117,6 +117,8 @@ struct mixer_context { int scan_value; }; +#define to_mixer(ptr) container_of(ptr, struct mixer_context, ptr) + struct mixer_drv_data { enum mixer_version_id version; bool is_vp_enabled; @@ -474,7 +476,7 @@ static void mixer_stop(struct mixer_context *ctx) static void mixer_commit(struct mixer_context *ctx) { - struct drm_display_mode *mode = &ctx->crtc->base.state->adjusted_mode; + struct drm_display_mode *mode = &ctx->crtc.base.state->adjusted_mode; mixer_cfg_scan(ctx, mode->hdisplay, mode->vdisplay); mixer_cfg_rgb_fmt(ctx, mode); @@ -732,7 +734,7 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) && !mixer_is_synced(ctx)) goto out; - drm_crtc_handle_vblank(&ctx->crtc->base); + drm_crtc_handle_vblank(&ctx->crtc.base); } out: @@ -876,7 +878,7 @@ static void mixer_ctx_remove(struct mixer_context *mixer_ctx) static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); __set_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) @@ -891,7 +893,7 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); __clear_bit(MXR_BIT_VSYNC, &mixer_ctx->flags); @@ -905,7 +907,7 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) return; @@ -918,7 +920,7 @@ static void mixer_atomic_begin(struct exynos_drm_crtc *crtc) static void mixer_update_plane(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); DRM_DEBUG_KMS("win: %d\n", plane->index); @@ -934,7 +936,7 @@ static void mixer_update_plane(struct exynos_drm_crtc *crtc, static void mixer_disable_plane(struct exynos_drm_crtc *crtc, struct exynos_drm_plane *plane) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); unsigned long flags; DRM_DEBUG_KMS("win: %d\n", plane->index); @@ -949,7 +951,7 @@ static void mixer_disable_plane(struct exynos_drm_crtc *crtc, static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) { - struct mixer_context *mixer_ctx = crtc->ctx; + struct mixer_context *mixer_ctx = to_mixer(crtc); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) return; @@ -960,7 +962,7 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc) static void mixer_enable(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); if (test_bit(MXR_BIT_POWERED, &ctx->flags)) return; @@ -989,7 +991,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) static void mixer_disable(struct exynos_drm_crtc *crtc) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); int i; if (!test_bit(MXR_BIT_POWERED, &ctx->flags)) @@ -1011,7 +1013,7 @@ static void mixer_disable(struct exynos_drm_crtc *crtc) static int mixer_mode_valid(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); u32 w = mode->hdisplay, h = mode->vdisplay; DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%d\n", w, h, @@ -1037,7 +1039,7 @@ static bool mixer_mode_fixup(struct exynos_drm_crtc *crtc, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct mixer_context *ctx = crtc->ctx; + struct mixer_context *ctx = to_mixer(crtc); int width = mode->hdisplay, height = mode->vdisplay, i; struct { @@ -1139,7 +1141,6 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) { struct mixer_context *ctx = dev_get_drvdata(dev); struct drm_device *drm_dev = data; - struct exynos_drm_plane *exynos_plane; unsigned int i; int ret; static enum drm_plane_type types[] = { DRM_PLANE_TYPE_PRIMARY, @@ -1173,14 +1174,14 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data) return ret; } - exynos_plane = &ctx->planes[DEFAULT_WIN]; - ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base, - EXYNOS_DISPLAY_TYPE_HDMI, &mixer_crtc_ops, ctx); - if (IS_ERR(ctx->crtc)) { + ctx->crtc.type = EXYNOS_DISPLAY_TYPE_HDMI; + ctx->crtc.ops = &mixer_crtc_ops; + ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev); + if (ret) { mixer_ctx_remove(ctx); - ret = PTR_ERR(ctx->crtc); goto free_ctx; } + ctx->crtc.base.primary = &ctx->planes[DEFAULT_WIN].base; return 0; -- 2.17.1