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

drm/imx: Use drm_fb_cma_fbdev_init/fini()

Use drm_fb_cma_fbdev_init() and drm_fb_cma_fbdev_fini() which relies on
the fact that drm_device holds a pointer to the drm_fb_helper structure.
This means that the driver doesn't have to keep track of that.
Also use the drm_fb_helper functions directly.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20171115142001.45358-8-noralf@tronnes.org

+6 -28
+6 -27
drivers/gpu/drm/imx/imx-drm-core.c
··· 38 38 struct imx_drm_device { 39 39 struct drm_device *drm; 40 40 unsigned int pipes; 41 - struct drm_fbdev_cma *fbhelper; 42 41 struct drm_atomic_state *state; 43 42 }; 44 43 ··· 45 46 static int legacyfb_depth = 16; 46 47 module_param(legacyfb_depth, int, 0444); 47 48 #endif 48 - 49 - static void imx_drm_driver_lastclose(struct drm_device *drm) 50 - { 51 - struct imx_drm_device *imxdrm = drm->dev_private; 52 - 53 - drm_fbdev_cma_restore_mode(imxdrm->fbhelper); 54 - } 55 49 56 50 DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops); 57 51 ··· 60 68 drm_encoder_cleanup(encoder); 61 69 } 62 70 EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy); 63 - 64 - static void imx_drm_output_poll_changed(struct drm_device *drm) 65 - { 66 - struct imx_drm_device *imxdrm = drm->dev_private; 67 - 68 - drm_fbdev_cma_hotplug_event(imxdrm->fbhelper); 69 - } 70 71 71 72 static int imx_drm_atomic_check(struct drm_device *dev, 72 73 struct drm_atomic_state *state) ··· 92 107 93 108 static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { 94 109 .fb_create = drm_gem_fb_create, 95 - .output_poll_changed = imx_drm_output_poll_changed, 110 + .output_poll_changed = drm_fb_helper_output_poll_changed, 96 111 .atomic_check = imx_drm_atomic_check, 97 112 .atomic_commit = drm_atomic_helper_commit, 98 113 }; ··· 171 186 static struct drm_driver imx_drm_driver = { 172 187 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | 173 188 DRIVER_ATOMIC, 174 - .lastclose = imx_drm_driver_lastclose, 189 + .lastclose = drm_fb_helper_lastclose, 175 190 .gem_free_object_unlocked = drm_gem_cma_free_object, 176 191 .gem_vm_ops = &drm_gem_cma_vm_ops, 177 192 .dumb_create = drm_gem_cma_dumb_create, ··· 283 298 dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); 284 299 legacyfb_depth = 16; 285 300 } 286 - imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth, MAX_CRTC); 287 - if (IS_ERR(imxdrm->fbhelper)) { 288 - ret = PTR_ERR(imxdrm->fbhelper); 289 - imxdrm->fbhelper = NULL; 301 + ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC); 302 + if (ret) 290 303 goto err_unbind; 291 - } 292 304 #endif 293 305 294 306 drm_kms_helper_poll_init(drm); ··· 299 317 err_fbhelper: 300 318 drm_kms_helper_poll_fini(drm); 301 319 #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) 302 - if (imxdrm->fbhelper) 303 - drm_fbdev_cma_fini(imxdrm->fbhelper); 320 + drm_fb_cma_fbdev_fini(drm); 304 321 err_unbind: 305 322 #endif 306 323 component_unbind_all(drm->dev, drm); ··· 314 333 static void imx_drm_unbind(struct device *dev) 315 334 { 316 335 struct drm_device *drm = dev_get_drvdata(dev); 317 - struct imx_drm_device *imxdrm = drm->dev_private; 318 336 319 337 drm_dev_unregister(drm); 320 338 321 339 drm_kms_helper_poll_fini(drm); 322 340 323 - if (imxdrm->fbhelper) 324 - drm_fbdev_cma_fini(imxdrm->fbhelper); 341 + drm_fb_cma_fbdev_fini(drm); 325 342 326 343 drm_mode_config_cleanup(drm); 327 344
-1
drivers/gpu/drm/imx/imx-drm.h
··· 8 8 struct drm_device; 9 9 struct drm_display_mode; 10 10 struct drm_encoder; 11 - struct drm_fbdev_cma; 12 11 struct drm_framebuffer; 13 12 struct drm_plane; 14 13 struct imx_drm_crtc;