drm/rockchip: vop2: use symmetric function pair vop2_{create,destroy}_crtcs
authorMichael Riesch <michael.riesch@wolfvision.net>
Tue, 24 Jan 2023 05:47:04 +0000 (06:47 +0100)
committerHeiko Stuebner <heiko@sntech.de>
Sun, 5 Feb 2023 14:21:38 +0000 (15:21 +0100)
Let the function name vop2_create_crtcs reflect that the function creates
multiple CRTCS. Also, use a symmetric function pair to create and destroy
the CRTCs and the corresponding planes.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20230124054706.3921383-5-michael.riesch@wolfvision.net
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c

index c59d383..2c170cb 100644 (file)
@@ -2245,7 +2245,7 @@ static struct vop2_video_port *find_vp_without_primary(struct vop2 *vop2)
 
 #define NR_LAYERS 6
 
-static int vop2_create_crtc(struct vop2 *vop2)
+static int vop2_create_crtcs(struct vop2 *vop2)
 {
        const struct vop2_data *vop2_data = vop2->data;
        struct drm_device *drm = vop2->drm;
@@ -2371,15 +2371,25 @@ static int vop2_create_crtc(struct vop2 *vop2)
        return 0;
 }
 
-static void vop2_destroy_crtc(struct drm_crtc *crtc)
+static void vop2_destroy_crtcs(struct vop2 *vop2)
 {
-       of_node_put(crtc->port);
+       struct drm_device *drm = vop2->drm;
+       struct list_head *crtc_list = &drm->mode_config.crtc_list;
+       struct list_head *plane_list = &drm->mode_config.plane_list;
+       struct drm_crtc *crtc, *tmpc;
+       struct drm_plane *plane, *tmpp;
+
+       list_for_each_entry_safe(plane, tmpp, plane_list, head)
+               drm_plane_cleanup(plane);
 
        /*
         * Destroy CRTC after vop2_plane_destroy() since vop2_disable_plane()
         * references the CRTC.
         */
-       drm_crtc_cleanup(crtc);
+       list_for_each_entry_safe(crtc, tmpc, crtc_list, head) {
+               of_node_put(crtc->port);
+               drm_crtc_cleanup(crtc);
+       }
 }
 
 static struct reg_field vop2_cluster_regs[VOP2_WIN_MAX_REG] = {
@@ -2683,7 +2693,7 @@ static int vop2_bind(struct device *dev, struct device *master, void *data)
        if (ret)
                return ret;
 
-       ret = vop2_create_crtc(vop2);
+       ret = vop2_create_crtcs(vop2);
        if (ret)
                return ret;
 
@@ -2697,19 +2707,10 @@ static int vop2_bind(struct device *dev, struct device *master, void *data)
 static void vop2_unbind(struct device *dev, struct device *master, void *data)
 {
        struct vop2 *vop2 = dev_get_drvdata(dev);
-       struct drm_device *drm = vop2->drm;
-       struct list_head *plane_list = &drm->mode_config.plane_list;
-       struct list_head *crtc_list = &drm->mode_config.crtc_list;
-       struct drm_crtc *crtc, *tmpc;
-       struct drm_plane *plane, *tmpp;
 
        pm_runtime_disable(dev);
 
-       list_for_each_entry_safe(plane, tmpp, plane_list, head)
-               drm_plane_cleanup(plane);
-
-       list_for_each_entry_safe(crtc, tmpc, crtc_list, head)
-               vop2_destroy_crtc(crtc);
+       vop2_destroy_crtcs(vop2);
 }
 
 const struct component_ops vop2_component_ops = {