Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/exynos/dpi: embed display into private context

exynos_drm_display is used by internal Exynos DRM framework for
representing encoder:connector pair. As it should be mapped 1:1 to dpi
private context it seems more reasonable to embed it directly in that context.
As a result further code simplification will be possible.
Moreover it will be possible to handle multiple dpi devices in the system.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>

authored by

Andrzej Hajda and committed by
Inki Dae
4cfde1f2 63b3be32

+23 -20
+21 -18
drivers/gpu/drm/exynos/exynos_drm_dpi.c
··· 22 22 #include "exynos_drm_drv.h" 23 23 24 24 struct exynos_dpi { 25 + struct exynos_drm_display display; 25 26 struct device *dev; 26 27 struct device_node *panel_node; 27 28 ··· 35 34 }; 36 35 37 36 #define connector_to_dpi(c) container_of(c, struct exynos_dpi, connector) 37 + 38 + static inline struct exynos_dpi *display_to_dpi(struct exynos_drm_display *d) 39 + { 40 + return container_of(d, struct exynos_dpi, display); 41 + } 38 42 39 43 static enum drm_connector_status 40 44 exynos_dpi_detect(struct drm_connector *connector, bool force) ··· 171 165 .dpms = exynos_dpi_dpms 172 166 }; 173 167 174 - static struct exynos_drm_display exynos_dpi_display = { 175 - .type = EXYNOS_DISPLAY_TYPE_LCD, 176 - .ops = &exynos_dpi_display_ops, 177 - }; 178 - 179 168 /* of_* functions will be removed after merge of of_graph patches */ 180 169 static struct device_node * 181 170 of_get_child_by_name_reg(struct device_node *parent, const char *name, u32 reg) ··· 300 299 struct exynos_dpi *ctx; 301 300 int ret; 302 301 303 - ret = exynos_drm_component_add(dev, 304 - EXYNOS_DEVICE_TYPE_CONNECTOR, 305 - exynos_dpi_display.type); 306 - if (ret) 307 - return ERR_PTR(ret); 308 - 309 302 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); 310 303 if (!ctx) 311 - goto err_del_component; 304 + return ERR_PTR(-ENOMEM); 312 305 306 + ctx->display.type = EXYNOS_DISPLAY_TYPE_LCD; 307 + ctx->display.ops = &exynos_dpi_display_ops; 313 308 ctx->dev = dev; 314 - exynos_dpi_display.ctx = ctx; 309 + ctx->display.ctx = ctx; 315 310 ctx->dpms_mode = DRM_MODE_DPMS_OFF; 311 + 312 + ret = exynos_drm_component_add(dev, 313 + EXYNOS_DEVICE_TYPE_CONNECTOR, 314 + ctx->display.type); 315 + if (ret) 316 + return ERR_PTR(ret); 316 317 317 318 ret = exynos_dpi_parse_dt(ctx); 318 319 if (ret < 0) { ··· 331 328 } 332 329 } 333 330 334 - return &exynos_dpi_display; 331 + return &ctx->display; 335 332 336 333 err_del_component: 337 334 exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CONNECTOR); ··· 339 336 return NULL; 340 337 } 341 338 342 - int exynos_dpi_remove(struct device *dev) 339 + int exynos_dpi_remove(struct exynos_drm_display *display) 343 340 { 344 - struct exynos_dpi *ctx = exynos_dpi_display.ctx; 341 + struct exynos_dpi *ctx = display_to_dpi(display); 345 342 346 - exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF); 343 + exynos_dpi_dpms(&ctx->display, DRM_MODE_DPMS_OFF); 347 344 348 345 if (ctx->panel) 349 346 drm_panel_detach(ctx->panel); 350 347 351 - exynos_drm_component_del(dev, EXYNOS_DEVICE_TYPE_CONNECTOR); 348 + exynos_drm_component_del(ctx->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); 352 349 353 350 return 0; 354 351 }
+1 -1
drivers/gpu/drm/exynos/exynos_drm_drv.h
··· 304 304 305 305 #ifdef CONFIG_DRM_EXYNOS_DPI 306 306 struct exynos_drm_display * exynos_dpi_probe(struct device *dev); 307 - int exynos_dpi_remove(struct device *dev); 307 + int exynos_dpi_remove(struct exynos_drm_display *display); 308 308 #else 309 309 static inline struct exynos_drm_display * 310 310 exynos_dpi_probe(struct device *dev) { return NULL; }
+1 -1
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 1092 1092 fimd_dpms(&ctx->manager, DRM_MODE_DPMS_OFF); 1093 1093 1094 1094 if (ctx->display) 1095 - exynos_dpi_remove(dev); 1095 + exynos_dpi_remove(ctx->display); 1096 1096 1097 1097 fimd_mgr_remove(&ctx->manager); 1098 1098 }