drm/vc4: crtc: Pass the device and data in vc4_crtc_init
authorMaxime Ripard <maxime@cerno.tech>
Wed, 23 Nov 2022 15:25:59 +0000 (16:25 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 28 Nov 2022 10:51:13 +0000 (11:51 +0100)
Both users of vc4_crtc_init need the same extra initialization to set
the pointer to the platform_device and the CRTC data. Since it's
mandatory, let's make them both arguments of vc4_crtc_init().

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20221123-rpi-kunit-tests-v1-17-051a0bb60a16@cerno.tech
drivers/gpu/drm/vc4/vc4_crtc.c
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_txp.c

index 0108613..1ea190d 100644 (file)
@@ -1278,9 +1278,12 @@ static void vc4_set_crtc_possible_masks(struct drm_device *drm,
        }
 }
 
-int vc4_crtc_init(struct drm_device *drm, struct vc4_crtc *vc4_crtc,
+int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
+                 struct vc4_crtc *vc4_crtc,
+                 const struct vc4_crtc_data *data,
                  const struct drm_crtc_funcs *crtc_funcs,
-                 const struct drm_crtc_helper_funcs *crtc_helper_funcs)
+                 const struct drm_crtc_helper_funcs *crtc_helper_funcs,
+                 bool feeds_txp)
 {
        struct vc4_dev *vc4 = to_vc4_dev(drm);
        struct drm_crtc *crtc = &vc4_crtc->base;
@@ -1300,6 +1303,9 @@ int vc4_crtc_init(struct drm_device *drm, struct vc4_crtc *vc4_crtc,
                return PTR_ERR(primary_plane);
        }
 
+       vc4_crtc->data = data;
+       vc4_crtc->pdev = pdev;
+       vc4_crtc->feeds_txp = feeds_txp;
        spin_lock_init(&vc4_crtc->irq_lock);
        ret = drmm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
                                         crtc_funcs, NULL);
@@ -1345,8 +1351,6 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
        pv_data = of_device_get_match_data(dev);
        if (!pv_data)
                return -ENODEV;
-       vc4_crtc->data = &pv_data->base;
-       vc4_crtc->pdev = pdev;
 
        vc4_crtc->regs = vc4_ioremap_regs(pdev, 0);
        if (IS_ERR(vc4_crtc->regs))
@@ -1356,8 +1360,9 @@ static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
        vc4_crtc->regset.regs = crtc_regs;
        vc4_crtc->regset.nregs = ARRAY_SIZE(crtc_regs);
 
-       ret = vc4_crtc_init(drm, vc4_crtc,
-                           &vc4_crtc_funcs, &vc4_crtc_helper_funcs);
+       ret = vc4_crtc_init(drm, pdev, vc4_crtc, &pv_data->base,
+                           &vc4_crtc_funcs, &vc4_crtc_helper_funcs,
+                           false);
        if (ret)
                return ret;
        vc4_set_crtc_possible_masks(drm, crtc);
index f43ed2a..31ce73f 100644 (file)
@@ -863,9 +863,11 @@ int vc4_bo_debugfs_init(struct drm_minor *minor);
 /* vc4_crtc.c */
 extern struct platform_driver vc4_crtc_driver;
 int vc4_crtc_disable_at_boot(struct drm_crtc *crtc);
-int vc4_crtc_init(struct drm_device *drm, struct vc4_crtc *vc4_crtc,
+int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
+                 struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
                  const struct drm_crtc_funcs *crtc_funcs,
-                 const struct drm_crtc_helper_funcs *crtc_helper_funcs);
+                 const struct drm_crtc_helper_funcs *crtc_helper_funcs,
+                 bool feeds_txp);
 int vc4_page_flip(struct drm_crtc *crtc,
                  struct drm_framebuffer *fb,
                  struct drm_pending_vblank_event *event,
index c2a6bea..841da24 100644 (file)
@@ -509,15 +509,12 @@ static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
                return PTR_ERR(txp->regs);
 
        vc4_crtc = &txp->base;
-       vc4_crtc->pdev = pdev;
-       vc4_crtc->data = &vc4_txp_crtc_data;
-       vc4_crtc->feeds_txp = true;
        vc4_crtc->regset.base = txp->regs;
        vc4_crtc->regset.regs = txp_regs;
        vc4_crtc->regset.nregs = ARRAY_SIZE(txp_regs);
 
-       ret = vc4_crtc_init(drm, vc4_crtc,
-                           &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs);
+       ret = vc4_crtc_init(drm, pdev, vc4_crtc, &vc4_txp_crtc_data,
+                           &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs, true);
        if (ret)
                return ret;