diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2018-02-12 04:44:36 -0500 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2018-09-03 09:13:25 -0400 |
commit | fb96b67c8ae0c91e17f0f9fe88cfce406ace6a94 (patch) | |
tree | ac73962624c4135d6bbe1b4ca842ba0322020fb4 /drivers/gpu/drm/omapdrm/omap_drv.c | |
parent | 5b394b2ddf0347bef56e50c69a58773c94343ff3 (diff) |
drm/omap: Allocate drm_device earlier and unref it as last step
If we allocate the drm_device earlier we can just return the error code
without the need to use goto.
Do the unref of the drm_device as a last step when cleaning up. This will
make the drm_device available longer for us and makes sure that we only
free up the memory when all other cleanups have been already done.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_drv.c')
-rw-r--r-- | drivers/gpu/drm/omapdrm/omap_drv.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 1b6601e9b107..e5afecb4fd45 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c | |||
@@ -525,6 +525,14 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) | |||
525 | 525 | ||
526 | DBG("%s", dev_name(dev)); | 526 | DBG("%s", dev_name(dev)); |
527 | 527 | ||
528 | /* Allocate and initialize the DRM device. */ | ||
529 | ddev = drm_dev_alloc(&omap_drm_driver, dev); | ||
530 | if (IS_ERR(ddev)) | ||
531 | return PTR_ERR(ddev); | ||
532 | |||
533 | priv->ddev = ddev; | ||
534 | ddev->dev_private = priv; | ||
535 | |||
528 | priv->dev = dev; | 536 | priv->dev = dev; |
529 | priv->dss = omapdss_get_dss(); | 537 | priv->dss = omapdss_get_dss(); |
530 | priv->dispc = dispc_get_dispc(priv->dss); | 538 | priv->dispc = dispc_get_dispc(priv->dss); |
@@ -543,16 +551,6 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) | |||
543 | mutex_init(&priv->list_lock); | 551 | mutex_init(&priv->list_lock); |
544 | INIT_LIST_HEAD(&priv->obj_list); | 552 | INIT_LIST_HEAD(&priv->obj_list); |
545 | 553 | ||
546 | /* Allocate and initialize the DRM device. */ | ||
547 | ddev = drm_dev_alloc(&omap_drm_driver, priv->dev); | ||
548 | if (IS_ERR(ddev)) { | ||
549 | ret = PTR_ERR(ddev); | ||
550 | goto err_destroy_wq; | ||
551 | } | ||
552 | |||
553 | priv->ddev = ddev; | ||
554 | ddev->dev_private = priv; | ||
555 | |||
556 | /* Get memory bandwidth limits */ | 554 | /* Get memory bandwidth limits */ |
557 | if (priv->dispc_ops->get_memory_bandwidth_limit) | 555 | if (priv->dispc_ops->get_memory_bandwidth_limit) |
558 | priv->max_bandwidth = | 556 | priv->max_bandwidth = |
@@ -563,7 +561,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev) | |||
563 | ret = omap_modeset_init(ddev); | 561 | ret = omap_modeset_init(ddev); |
564 | if (ret) { | 562 | if (ret) { |
565 | dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret); | 563 | dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret); |
566 | goto err_free_drm_dev; | 564 | goto err_gem_deinit; |
567 | } | 565 | } |
568 | 566 | ||
569 | /* Initialize vblank handling, start with all CRTCs disabled. */ | 567 | /* Initialize vblank handling, start with all CRTCs disabled. */ |
@@ -599,14 +597,13 @@ err_cleanup_helpers: | |||
599 | err_cleanup_modeset: | 597 | err_cleanup_modeset: |
600 | drm_mode_config_cleanup(ddev); | 598 | drm_mode_config_cleanup(ddev); |
601 | omap_drm_irq_uninstall(ddev); | 599 | omap_drm_irq_uninstall(ddev); |
602 | err_free_drm_dev: | 600 | err_gem_deinit: |
603 | omap_gem_deinit(ddev); | 601 | omap_gem_deinit(ddev); |
604 | drm_dev_unref(ddev); | ||
605 | err_destroy_wq: | ||
606 | destroy_workqueue(priv->wq); | 602 | destroy_workqueue(priv->wq); |
607 | omap_disconnect_dssdevs(); | 603 | omap_disconnect_dssdevs(); |
608 | err_crtc_uninit: | 604 | err_crtc_uninit: |
609 | omap_crtc_pre_uninit(); | 605 | omap_crtc_pre_uninit(); |
606 | drm_dev_unref(ddev); | ||
610 | return ret; | 607 | return ret; |
611 | } | 608 | } |
612 | 609 | ||
@@ -630,12 +627,12 @@ static void omapdrm_cleanup(struct omap_drm_private *priv) | |||
630 | omap_drm_irq_uninstall(ddev); | 627 | omap_drm_irq_uninstall(ddev); |
631 | omap_gem_deinit(ddev); | 628 | omap_gem_deinit(ddev); |
632 | 629 | ||
633 | drm_dev_unref(ddev); | ||
634 | |||
635 | destroy_workqueue(priv->wq); | 630 | destroy_workqueue(priv->wq); |
636 | 631 | ||
637 | omap_disconnect_dssdevs(); | 632 | omap_disconnect_dssdevs(); |
638 | omap_crtc_pre_uninit(); | 633 | omap_crtc_pre_uninit(); |
634 | |||
635 | drm_dev_unref(ddev); | ||
639 | } | 636 | } |
640 | 637 | ||
641 | static int pdev_probe(struct platform_device *pdev) | 638 | static int pdev_probe(struct platform_device *pdev) |