[PATCHv2 02/17] drm/omap: cleanup fbdev init/free
Sebastian Reichel
sre at kernel.org
Sun Jun 10 13:18:51 UTC 2018
Hi,
On Wed, Feb 28, 2018 at 01:25:59PM +0200, Tomi Valkeinen wrote:
> omap_fbdev_init() and omap_fbdev_free() use priv->fbdev directly.
> However, omap_fbdev_init() returns the fbdev, and omap_drv.c also
> assigns the return value to priv->fbdev. This is slightly confusing.
>
> Clean this up by removing the omap_fbdev_init() return value, as we
> don't care whether fbdev init succeeded or not. Also change omap_drv.c
> to call omap_fbdev_free() always, and omap_fbdev_free() does the check
> if fbdev was initialized.
>
> While at it, rename omap_fbdev_free() to omap_fbdev_fini() to better
> match the "init" counterpart.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ti.com>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel at collabora.co.uk>
-- Sebastian
> drivers/gpu/drm/omapdrm/omap_drv.c | 9 ++++-----
> drivers/gpu/drm/omapdrm/omap_fbdev.c | 18 ++++++++----------
> drivers/gpu/drm/omapdrm/omap_fbdev.h | 9 ++++-----
> 3 files changed, 16 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
> index 65a567dcf3ab..4f48b908bdc6 100644
> --- a/drivers/gpu/drm/omapdrm/omap_drv.c
> +++ b/drivers/gpu/drm/omapdrm/omap_drv.c
> @@ -570,7 +570,7 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
> for (i = 0; i < priv->num_crtcs; i++)
> drm_crtc_vblank_off(priv->crtcs[i]);
>
> - priv->fbdev = omap_fbdev_init(ddev);
> + omap_fbdev_init(ddev);
>
> drm_kms_helper_poll_init(ddev);
> omap_modeset_enable_external_hpd();
> @@ -588,8 +588,8 @@ static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
> err_cleanup_helpers:
> omap_modeset_disable_external_hpd();
> drm_kms_helper_poll_fini(ddev);
> - if (priv->fbdev)
> - omap_fbdev_free(ddev);
> +
> + omap_fbdev_fini(ddev);
> err_cleanup_modeset:
> drm_mode_config_cleanup(ddev);
> omap_drm_irq_uninstall(ddev);
> @@ -615,8 +615,7 @@ static void omapdrm_cleanup(struct omap_drm_private *priv)
> omap_modeset_disable_external_hpd();
> drm_kms_helper_poll_fini(ddev);
>
> - if (priv->fbdev)
> - omap_fbdev_free(ddev);
> + omap_fbdev_fini(ddev);
>
> drm_atomic_helper_shutdown(ddev);
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> index 632ebcf2165f..be94480326d7 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> @@ -242,7 +242,7 @@ static struct drm_fb_helper *get_fb(struct fb_info *fbi)
> }
>
> /* initialize fbdev helper */
> -struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
> +void omap_fbdev_init(struct drm_device *dev)
> {
> struct omap_drm_private *priv = dev->dev_private;
> struct omap_fbdev *fbdev = NULL;
> @@ -260,10 +260,8 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
> drm_fb_helper_prepare(dev, helper, &omap_fb_helper_funcs);
>
> ret = drm_fb_helper_init(dev, helper, priv->num_connectors);
> - if (ret) {
> - dev_err(dev->dev, "could not init fbdev: ret=%d\n", ret);
> + if (ret)
> goto fail;
> - }
>
> ret = drm_fb_helper_single_add_all_connectors(helper);
> if (ret)
> @@ -275,7 +273,7 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
>
> priv->fbdev = helper;
>
> - return helper;
> + return;
>
> fini:
> drm_fb_helper_fini(helper);
> @@ -283,12 +281,9 @@ struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
> kfree(fbdev);
>
> dev_warn(dev->dev, "omap_fbdev_init failed\n");
> - /* well, limp along without an fbdev.. maybe X11 will work? */
> -
> - return NULL;
> }
>
> -void omap_fbdev_free(struct drm_device *dev)
> +void omap_fbdev_fini(struct drm_device *dev)
> {
> struct omap_drm_private *priv = dev->dev_private;
> struct drm_fb_helper *helper = priv->fbdev;
> @@ -296,11 +291,14 @@ void omap_fbdev_free(struct drm_device *dev)
>
> DBG();
>
> + if (!helper)
> + return;
> +
> drm_fb_helper_unregister_fbi(helper);
>
> drm_fb_helper_fini(helper);
>
> - fbdev = to_omap_fbdev(priv->fbdev);
> + fbdev = to_omap_fbdev(helper);
>
> /* unpin the GEM object pinned in omap_fbdev_create() */
> if (fbdev->bo)
> diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.h b/drivers/gpu/drm/omapdrm/omap_fbdev.h
> index 1f5ba0996a1a..7dfd843f73f1 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fbdev.h
> +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.h
> @@ -24,14 +24,13 @@ struct drm_device;
> struct drm_fb_helper;
>
> #ifdef CONFIG_DRM_FBDEV_EMULATION
> -struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev);
> -void omap_fbdev_free(struct drm_device *dev);
> +void omap_fbdev_init(struct drm_device *dev);
> +void omap_fbdev_fini(struct drm_device *dev);
> #else
> -static inline struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev)
> +static inline void omap_fbdev_init(struct drm_device *dev)
> {
> - return NULL;
> }
> -static inline void omap_fbdev_free(struct drm_device *dev)
> +static inline void omap_fbdev_fini(struct drm_device *dev)
> {
> }
> #endif
> --
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20180610/7556267f/attachment.sig>
More information about the dri-devel
mailing list