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

drm/arc: Initialize sim connector before display pipe

That way we can get rid of this final piece of init code, and use the
simple pipe helpers as intended.

v2: Fix indent (Sam)

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Alexey Brodkin <abrodkin@synopsys.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210112084358.2771527-14-daniel.vetter@ffwll.ch

+17 -36
+17 -36
drivers/gpu/drm/arc/arcpgu_drv.c
··· 95 95 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 96 96 }; 97 97 98 - static int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np) 98 + static int arcpgu_drm_sim_init(struct drm_device *drm, struct drm_connector *connector) 99 99 { 100 - struct arcpgu_drm_private *arcpgu = dev_to_arcpgu(drm); 101 - struct drm_encoder *encoder; 102 - struct drm_connector *connector; 103 - int ret; 104 - 105 - encoder = &arcpgu->pipe.encoder; 106 - 107 - connector = &arcpgu->sim_conn; 108 100 drm_connector_helper_add(connector, &arcpgu_drm_connector_helper_funcs); 109 - 110 - ret = drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, 111 - DRM_MODE_CONNECTOR_VIRTUAL); 112 - if (ret < 0) { 113 - dev_err(drm->dev, "failed to initialize drm connector\n"); 114 - return ret; 115 - } 116 - 117 - ret = drm_connector_attach_encoder(connector, encoder); 118 - if (ret < 0) { 119 - dev_err(drm->dev, "could not attach connector to encoder\n"); 120 - return ret; 121 - } 122 - 123 - return 0; 101 + return drm_connector_init(drm, connector, &arcpgu_drm_connector_funcs, 102 + DRM_MODE_CONNECTOR_VIRTUAL); 124 103 } 125 104 126 105 #define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1)) ··· 246 267 { 247 268 struct platform_device *pdev = to_platform_device(arcpgu->drm.dev); 248 269 struct device_node *encoder_node = NULL, *endpoint_node = NULL; 270 + struct drm_connector *connector = NULL; 249 271 struct drm_device *drm = &arcpgu->drm; 250 272 struct resource *res; 251 273 int ret; ··· 281 301 if (dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32))) 282 302 return -ENODEV; 283 303 284 - ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, 285 - arc_pgu_supported_formats, 286 - ARRAY_SIZE(arc_pgu_supported_formats), 287 - NULL, NULL); 288 - if (ret) 289 - return ret; 290 - 291 304 /* 292 305 * There is only one output port inside each device. It is linked with 293 306 * encoder endpoint. ··· 289 316 if (endpoint_node) { 290 317 encoder_node = of_graph_get_remote_port_parent(endpoint_node); 291 318 of_node_put(endpoint_node); 319 + } else { 320 + connector = &arcpgu->sim_conn; 321 + dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); 322 + ret = arcpgu_drm_sim_init(drm, connector); 323 + if (ret < 0) 324 + return ret; 292 325 } 326 + 327 + ret = drm_simple_display_pipe_init(drm, &arcpgu->pipe, &arc_pgu_pipe_funcs, 328 + arc_pgu_supported_formats, 329 + ARRAY_SIZE(arc_pgu_supported_formats), 330 + NULL, connector); 331 + if (ret) 332 + return ret; 293 333 294 334 if (encoder_node) { 295 335 struct drm_bridge *bridge; ··· 314 328 315 329 ret = drm_simple_display_pipe_attach_bridge(&arcpgu->pipe, bridge); 316 330 if (ret) 317 - return ret; 318 - } else { 319 - dev_info(drm->dev, "no encoder found. Assumed virtual LCD on simulation platform\n"); 320 - ret = arcpgu_drm_sim_init(drm, NULL); 321 - if (ret < 0) 322 331 return ret; 323 332 } 324 333