From: Sebastian Reichel Subject: Re: [PATCH 12/48] drm: omapdrm: Split init and cleanup from probe and remove functions Date: Sat, 14 Oct 2017 14:41:49 +0200 Message-ID: <20171014124149.zitfhm2kjvin6sms@earth> References: <20171013145944.26557-1-laurent.pinchart@ideasonboard.com> <20171013145944.26557-13-laurent.pinchart@ideasonboard.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0813412383==" Return-path: Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 378E56E0CA for ; Sat, 14 Oct 2017 12:41:53 +0000 (UTC) In-Reply-To: <20171013145944.26557-13-laurent.pinchart@ideasonboard.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Laurent Pinchart Cc: Tomi Valkeinen , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0813412383== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dalhmyrt7idqari7" Content-Disposition: inline --dalhmyrt7idqari7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Fri, Oct 13, 2017 at 05:59:08PM +0300, Laurent Pinchart wrote: > When merging the omapdrm and omapdss drivers there will be not omapdrm > platform device anymore, and thus no associated probe and remove > functions. To prepare for that, split all the initialization code from > the probe function to make it usable without a platform device. > Similarly, split the cleanup code from the remove function. >=20 > Signed-off-by: Laurent Pinchart > --- Reviewed-by: Sebastian Reichel -- Sebastian > drivers/gpu/drm/omapdrm/omap_drv.c | 83 +++++++++++++++++++++++---------= ------ > drivers/gpu/drm/omapdrm/omap_drv.h | 2 + > 2 files changed, 53 insertions(+), 32 deletions(-) >=20 > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm= /omap_drv.c > index 2d15ea1d6c92..cbca70f80d8e 100644 > --- a/drivers/gpu/drm/omapdrm/omap_drv.c > +++ b/drivers/gpu/drm/omapdrm/omap_drv.c > @@ -542,24 +542,16 @@ static const struct soc_device_attribute omapdrm_so= c_devices[] =3D { > { /* sentinel */ } > }; > =20 > -static int pdev_probe(struct platform_device *pdev) > +static int omapdrm_init(struct omap_drm_private *priv, struct device *de= v) > { > const struct soc_device_attribute *soc; > - struct omap_drm_private *priv; > struct drm_device *ddev; > unsigned int i; > int ret; > =20 > - DBG("%s", pdev->name); > - > - if (omapdss_is_initialized() =3D=3D false) > - return -EPROBE_DEFER; > + DBG("%s", dev_name(dev)); > =20 > - ret =3D dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); > - if (ret) { > - dev_err(&pdev->dev, "Failed to set the DMA mask\n"); > - return ret; > - } > + priv->dev =3D dev; > =20 > omap_crtc_pre_init(); > =20 > @@ -567,13 +559,6 @@ static int pdev_probe(struct platform_device *pdev) > if (ret) > goto err_crtc_uninit; > =20 > - /* Allocate and initialize the driver private structure. */ > - priv =3D kzalloc(sizeof(*priv), GFP_KERNEL); > - if (!priv) { > - ret =3D -ENOMEM; > - goto err_disconnect_dssdevs; > - } > - > priv->dispc_ops =3D dispc_get_ops(); > =20 > soc =3D soc_device_match(omapdrm_soc_devices); > @@ -584,27 +569,27 @@ static int pdev_probe(struct platform_device *pdev) > INIT_LIST_HEAD(&priv->obj_list); > =20 > /* Allocate and initialize the DRM device. */ > - ddev =3D drm_dev_alloc(&omap_drm_driver, &pdev->dev); > + ddev =3D drm_dev_alloc(&omap_drm_driver, priv->dev); > if (IS_ERR(ddev)) { > ret =3D PTR_ERR(ddev); > - goto err_free_priv; > + goto err_destroy_wq; > } > =20 > + priv->ddev =3D ddev; > ddev->dev_private =3D priv; > - platform_set_drvdata(pdev, ddev); > =20 > omap_gem_init(ddev); > =20 > ret =3D omap_modeset_init(ddev); > if (ret) { > - dev_err(&pdev->dev, "omap_modeset_init failed: ret=3D%d\n", ret); > + dev_err(priv->dev, "omap_modeset_init failed: ret=3D%d\n", ret); > goto err_free_drm_dev; > } > =20 > /* Initialize vblank handling, start with all CRTCs disabled. */ > ret =3D drm_vblank_init(ddev, priv->num_crtcs); > if (ret) { > - dev_err(&pdev->dev, "could not init vblank\n"); > + dev_err(priv->dev, "could not init vblank\n"); > goto err_cleanup_modeset; > } > =20 > @@ -637,20 +622,17 @@ static int pdev_probe(struct platform_device *pdev) > err_free_drm_dev: > omap_gem_deinit(ddev); > drm_dev_unref(ddev); > -err_free_priv: > +err_destroy_wq: > destroy_workqueue(priv->wq); > - kfree(priv); > -err_disconnect_dssdevs: > omap_disconnect_dssdevs(); > err_crtc_uninit: > omap_crtc_pre_uninit(); > return ret; > } > =20 > -static int pdev_remove(struct platform_device *pdev) > +static void omapdrm_cleanup(struct omap_drm_private *priv) > { > - struct drm_device *ddev =3D platform_get_drvdata(pdev); > - struct omap_drm_private *priv =3D ddev->dev_private; > + struct drm_device *ddev =3D priv->ddev; > =20 > DBG(""); > =20 > @@ -672,10 +654,45 @@ static int pdev_remove(struct platform_device *pdev) > drm_dev_unref(ddev); > =20 > destroy_workqueue(priv->wq); > - kfree(priv); > =20 > omap_disconnect_dssdevs(); > omap_crtc_pre_uninit(); > +} > + > +static int pdev_probe(struct platform_device *pdev) > +{ > + struct omap_drm_private *priv; > + int ret; > + > + if (omapdss_is_initialized() =3D=3D false) > + return -EPROBE_DEFER; > + > + ret =3D dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)); > + if (ret) { > + dev_err(&pdev->dev, "Failed to set the DMA mask\n"); > + return ret; > + } > + > + /* Allocate and initialize the driver private structure. */ > + priv =3D kzalloc(sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + platform_set_drvdata(pdev, priv); > + > + ret =3D omapdrm_init(priv, &pdev->dev); > + if (ret < 0) > + kfree(priv); > + > + return ret; > +} > + > +static int pdev_remove(struct platform_device *pdev) > +{ > + struct omap_drm_private *priv =3D platform_get_drvdata(pdev); > + > + omapdrm_cleanup(priv); > + kfree(priv); > =20 > return 0; > } > @@ -719,7 +736,8 @@ static int omap_drm_resume_all_displays(void) > =20 > static int omap_drm_suspend(struct device *dev) > { > - struct drm_device *drm_dev =3D dev_get_drvdata(dev); > + struct omap_drm_private *priv =3D dev_get_drvdata(dev); > + struct drm_device *drm_dev =3D priv->ddev; > =20 > drm_kms_helper_poll_disable(drm_dev); > =20 > @@ -732,7 +750,8 @@ static int omap_drm_suspend(struct device *dev) > =20 > static int omap_drm_resume(struct device *dev) > { > - struct drm_device *drm_dev =3D dev_get_drvdata(dev); > + struct omap_drm_private *priv =3D dev_get_drvdata(dev); > + struct drm_device *drm_dev =3D priv->ddev; > =20 > drm_modeset_lock_all(drm_dev); > omap_drm_resume_all_displays(); > diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm= /omap_drv.h > index 7bf008f02a77..2c06533a2d0a 100644 > --- a/drivers/gpu/drm/omapdrm/omap_drv.h > +++ b/drivers/gpu/drm/omapdrm/omap_drv.h > @@ -48,6 +48,8 @@ > struct omap_drm_usergart; > =20 > struct omap_drm_private { > + struct drm_device *ddev; > + struct device *dev; > u32 omaprev; > =20 > const struct dispc_ops *dispc_ops; > --=20 > Regards, >=20 > Laurent Pinchart >=20 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --dalhmyrt7idqari7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAlniBg0ACgkQ2O7X88g7 +ppB+g/7BADCQmqGnpa+6g9rsXeae4NwF3PsEBuMhGy7iyX05FU2gK/jxncXTMvU kVdg8BULIf+NdK+cwhfQiy9qPLiq7QEFz+Zd+3VPwXPabAI1zCYKe1qrug5uJ7aC UAdKdilx6UEzHGHoT/Jvret1xOQu0wnjreqsuLM0hdZ5nHJtBk8uFokU9ZaY3Awy k4hduJmURJ/bag1inaeWpb8FV2Pag65hutDH4WfTW+K88xMqa892aTSnFnBfaC26 fDKqb1nc8o7zmCaq1AI7qkCrhCYaLpEaZPQfmjjuc9/t6OOGjESN+EdazHCRzSYx bd3n0CIGgtvMnfEcjzeknZVYzvYQZ125DZW7pfslYSIHqEkchT2gsj+P0aCZ/WYh yAGhnmfH67FjwYo6suEPK0RV82u+elZlNMf7Yj8hjtLaJKW2w0LBg+OqWsI4/rrz DkckjT2HMnVRWz3HSBT+KpCcL13RGycKgJO9+0oHLXbb22/8RpjiOhFFQDksJ7Sp tQb0HwBv+8xtn4zqmeTrCupvVgzr2VooFC4e6fW3qAA8eez0MC7Jmd6+5LT+YJ02 nYVLrK6X9+GSg4GqqUs0jjMxyjrkZEJ8alXDuwz8z0D9kAfvfE3a3q0agDoQTco8 isz7asRekltusRQD+MPdaZ8JGSaWy3uY6oQkSU+FHCBpkgfP+qM= =10D5 -----END PGP SIGNATURE----- --dalhmyrt7idqari7-- --===============0813412383== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0813412383==--