All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: dri-devel@lists.freedesktop.org
Cc: kernel@pengutronix.de
Subject: [PATCH v3 7/7] drm/imx: ipuv3-crtc: use drmm_crtc_alloc_with_planes()
Date: Fri, 11 Sep 2020 15:57:24 +0200	[thread overview]
Message-ID: <20200911135724.25833-7-p.zabel@pengutronix.de> (raw)
In-Reply-To: <20200911135724.25833-1-p.zabel@pengutronix.de>

Merge ipu_crtc_init into ipu_drm_bind and use
drmm_crtc_alloc_with_planes().
This allows to drop the custom drm_crtc_cleanup action.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
New in v3, example conversion of drm_crtc_init_with_planes() user.
---
 drivers/gpu/drm/imx/ipuv3-crtc.c | 71 ++++++++++++--------------------
 1 file changed, 26 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index f284e4ea6d5f..982ef79653ae 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -349,47 +349,43 @@ static int ipu_get_resources(struct drm_device *dev, struct ipu_crtc *ipu_crtc,
 	return 0;
 }
 
-static void ipu_crtc_cleanup(struct drm_device *drm, void *ptr)
-{
-	struct drm_crtc *crtc = ptr;
-
-	drm_crtc_cleanup(crtc);
-}
-
-static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
-	struct ipu_client_platformdata *pdata, struct drm_device *drm)
+static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
 {
-	struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
-	struct drm_crtc *crtc = &ipu_crtc->base;
+	struct ipu_client_platformdata *pdata = dev->platform_data;
+	struct ipu_soc *ipu = dev_get_drvdata(dev->parent);
+	struct drm_device *drm = data;
+	struct ipu_plane *primary_plane;
+	struct ipu_crtc *ipu_crtc;
+	struct drm_crtc *crtc;
 	int dp = -EINVAL;
 	int ret;
 
-	ret = ipu_get_resources(drm, ipu_crtc, pdata);
-	if (ret) {
-		dev_err(ipu_crtc->dev, "getting resources failed with %d.\n",
-				ret);
-		return ret;
-	}
-
 	if (pdata->dp >= 0)
 		dp = IPU_DP_FLOW_SYNC_BG;
-	ipu_crtc->plane[0] = ipu_plane_init(drm, ipu, pdata->dma[0], dp, 0,
-					    DRM_PLANE_TYPE_PRIMARY);
-	if (IS_ERR(ipu_crtc->plane[0])) {
-		ret = PTR_ERR(ipu_crtc->plane[0]);
-		return ret;
-	}
+	primary_plane = ipu_plane_init(drm, ipu, pdata->dma[0], dp, 0,
+				       DRM_PLANE_TYPE_PRIMARY);
+	if (IS_ERR(primary_plane))
+		return PTR_ERR(primary_plane);
 
+	ipu_crtc = drmm_crtc_alloc_with_planes(drm, struct ipu_crtc, base,
+					       &primary_plane->base, NULL,
+					       &ipu_crtc_funcs, NULL);
+	if (IS_ERR(ipu_crtc))
+		return PTR_ERR(ipu_crtc);
+
+	ipu_crtc->dev = dev;
+	ipu_crtc->plane[0] = primary_plane;
+
+	crtc = &ipu_crtc->base;
 	crtc->port = pdata->of_node;
 	drm_crtc_helper_add(crtc, &ipu_helper_funcs);
-	ret = drm_crtc_init_with_planes(drm, crtc, &ipu_crtc->plane[0]->base,
-					NULL, &ipu_crtc_funcs, NULL);
-	if (ret)
-		return ret;
 
-	ret = drmm_add_action_or_reset(drm, ipu_crtc_cleanup, crtc);
-	if (ret)
+	ret = ipu_get_resources(drm, ipu_crtc, pdata);
+	if (ret) {
+		dev_err(ipu_crtc->dev, "getting resources failed with %d.\n",
+			ret);
 		return ret;
+	}
 
 	/* If this crtc is using the DP, add an overlay plane */
 	if (pdata->dp >= 0 && pdata->dma[1] > 0) {
@@ -414,21 +410,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
 	return 0;
 }
 
-static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
-{
-	struct ipu_client_platformdata *pdata = dev->platform_data;
-	struct drm_device *drm = data;
-	struct ipu_crtc *ipu_crtc;
-
-	ipu_crtc = drmm_kzalloc(drm, sizeof(*ipu_crtc), GFP_KERNEL);
-	if (!ipu_crtc)
-		return -ENOMEM;
-
-	ipu_crtc->dev = dev;
-
-	return ipu_crtc_init(ipu_crtc, pdata, drm);
-}
-
 static const struct component_ops ipu_crtc_ops = {
 	.bind = ipu_drm_bind,
 };
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-09-11 13:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 13:57 [PATCH v3 1/7] drm: add drmm_encoder_alloc() Philipp Zabel
2020-09-11 13:57 ` [PATCH v3 2/7] drm/simple_kms_helper: add drmm_simple_encoder_alloc() Philipp Zabel
2020-12-04  9:19   ` Laurent Pinchart
2020-12-04 10:13     ` Philipp Zabel
2020-12-05 18:58       ` Laurent Pinchart
2020-09-11 13:57 ` [PATCH v3 3/7] drm/plane: add drmm_universal_plane_alloc() Philipp Zabel
2020-12-04  9:22   ` Laurent Pinchart
2020-09-11 13:57 ` [PATCH v3 4/7] drm/crtc: add drmm_crtc_alloc_with_planes() Philipp Zabel
2020-12-04  9:23   ` Laurent Pinchart
2020-09-11 13:57 ` [PATCH v3 5/7] drm/imx: use drmm_simple_encoder_alloc() Philipp Zabel
2020-09-16  9:08   ` Daniel Vetter
2020-09-16 10:22     ` Philipp Zabel
2020-09-11 13:57 ` [PATCH v3 6/7] drm/imx: use drmm_universal_plane_alloc() Philipp Zabel
2020-09-11 13:57 ` Philipp Zabel [this message]
2020-12-04  9:17 ` [PATCH v3 1/7] drm: add drmm_encoder_alloc() Laurent Pinchart
2020-12-04 10:12   ` Philipp Zabel
2020-12-05 18:57     ` Laurent Pinchart
2020-12-09  0:22       ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200911135724.25833-7-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.