drm/msm/mdp5: use devres-managed allocation for pipe data
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sat, 8 Jul 2023 01:03:55 +0000 (04:03 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Sun, 3 Dec 2023 00:13:05 +0000 (03:13 +0300)
Use devm_kzalloc to create pipe data structure. This allows us
to remove corresponding kfree and drop mdp5_pipe_destroy() function.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/546171/
Link: https://lore.kernel.org/r/20230708010407.3871346-6-dmitry.baryshkov@linaro.org
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.h

index 3189b3b..b918c9d 100644 (file)
@@ -209,10 +209,6 @@ static void mdp5_kms_destroy(struct msm_kms *kms)
 {
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
        struct msm_gem_address_space *aspace = kms->aspace;
-       int i;
-
-       for (i = 0; i < mdp5_kms->num_hwpipes; i++)
-               mdp5_pipe_destroy(mdp5_kms->hwpipes[i]);
 
        if (aspace) {
                aspace->mmu->funcs->detach(aspace->mmu);
@@ -645,7 +641,7 @@ static int construct_pipes(struct mdp5_kms *mdp5_kms, int cnt,
        for (i = 0; i < cnt; i++) {
                struct mdp5_hw_pipe *hwpipe;
 
-               hwpipe = mdp5_pipe_init(pipes[i], offsets[i], caps);
+               hwpipe = mdp5_pipe_init(dev, pipes[i], offsets[i], caps);
                if (IS_ERR(hwpipe)) {
                        ret = PTR_ERR(hwpipe);
                        DRM_DEV_ERROR(dev->dev, "failed to construct pipe for %s (%d)\n",
index e4b8a78..99b2c30 100644 (file)
@@ -151,17 +151,13 @@ int mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe)
        return 0;
 }
 
-void mdp5_pipe_destroy(struct mdp5_hw_pipe *hwpipe)
-{
-       kfree(hwpipe);
-}
-
-struct mdp5_hw_pipe *mdp5_pipe_init(enum mdp5_pipe pipe,
+struct mdp5_hw_pipe *mdp5_pipe_init(struct drm_device *dev,
+               enum mdp5_pipe pipe,
                uint32_t reg_offset, uint32_t caps)
 {
        struct mdp5_hw_pipe *hwpipe;
 
-       hwpipe = kzalloc(sizeof(*hwpipe), GFP_KERNEL);
+       hwpipe = devm_kzalloc(dev->dev, sizeof(*hwpipe), GFP_KERNEL);
        if (!hwpipe)
                return ERR_PTR(-ENOMEM);
 
index cca6793..4521388 100644 (file)
@@ -39,8 +39,8 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
                     struct mdp5_hw_pipe **r_hwpipe);
 int mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe);
 
-struct mdp5_hw_pipe *mdp5_pipe_init(enum mdp5_pipe pipe,
+struct mdp5_hw_pipe *mdp5_pipe_init(struct drm_device *dev,
+               enum mdp5_pipe pipe,
                uint32_t reg_offset, uint32_t caps);
-void mdp5_pipe_destroy(struct mdp5_hw_pipe *hwpipe);
 
 #endif /* __MDP5_PIPE_H__ */