drm/msm/dpu: use devres-managed allocation for VBIF data
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fri, 1 Dec 2023 21:18:36 +0000 (00:18 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tue, 5 Dec 2023 19:14:33 +0000 (22:14 +0300)
Use devm_kzalloc to create VBIF data structure. This allows us to
remove corresponding kfree and drop dpu_hw_vbif_destroy() function.

Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/570040/
Link: https://lore.kernel.org/r/20231201211845.1026967-5-dmitry.baryshkov@linaro.org
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.c
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_vbif.h
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c

index a5121a50b2bbf8cc4b6cc7becbfd8c48510cd465..98e34afde2d259ab3cbc0011af05c463aeb1d2bc 100644 (file)
@@ -2,6 +2,8 @@
 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  */
 
+#include <drm/drm_managed.h>
+
 #include "dpu_hwio.h"
 #include "dpu_hw_catalog.h"
 #include "dpu_hw_vbif.h"
@@ -211,12 +213,13 @@ static void _setup_vbif_ops(struct dpu_hw_vbif_ops *ops,
        ops->set_write_gather_en = dpu_hw_set_write_gather_en;
 }
 
-struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg,
-               void __iomem *addr)
+struct dpu_hw_vbif *dpu_hw_vbif_init(struct drm_device *dev,
+                                    const struct dpu_vbif_cfg *cfg,
+                                    void __iomem *addr)
 {
        struct dpu_hw_vbif *c;
 
-       c = kzalloc(sizeof(*c), GFP_KERNEL);
+       c = drmm_kzalloc(dev, sizeof(*c), GFP_KERNEL);
        if (!c)
                return ERR_PTR(-ENOMEM);
 
@@ -234,8 +237,3 @@ struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg,
 
        return c;
 }
-
-void dpu_hw_vbif_destroy(struct dpu_hw_vbif *vbif)
-{
-       kfree(vbif);
-}
index 7e10d2a172b45aef00bc53a6686ae753741d6780..e2b4307500e42f1c2ca4496561135df0d4726b35 100644 (file)
@@ -108,12 +108,12 @@ struct dpu_hw_vbif {
 /**
  * dpu_hw_vbif_init() - Initializes the VBIF driver for the passed
  * VBIF catalog entry.
+ * @dev:  Corresponding device for devres management
  * @cfg:  VBIF catalog entry for which driver object is required
  * @addr: Mapped register io address of MDSS
  */
-struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg,
-               void __iomem *addr);
-
-void dpu_hw_vbif_destroy(struct dpu_hw_vbif *vbif);
+struct dpu_hw_vbif *dpu_hw_vbif_init(struct drm_device *dev,
+                                    const struct dpu_vbif_cfg *cfg,
+                                    void __iomem *addr);
 
 #endif /*_DPU_HW_VBIF_H */
index 34d707db1d0cb327b2a0b9ae2ad20ac775c1a75f..a1753c54aaacbf2b11f1f49ac8a8f33fe907bb7d 100644 (file)
@@ -800,13 +800,8 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
        /* safe to call these more than once during shutdown */
        _dpu_kms_mmu_destroy(dpu_kms);
 
-       if (dpu_kms->catalog) {
-               for (i = 0; i < ARRAY_SIZE(dpu_kms->hw_vbif); i++) {
-                       if (dpu_kms->hw_vbif[i]) {
-                               dpu_hw_vbif_destroy(dpu_kms->hw_vbif[i]);
-                               dpu_kms->hw_vbif[i] = NULL;
-                       }
-               }
+       for (i = 0; i < ARRAY_SIZE(dpu_kms->hw_vbif); i++) {
+               dpu_kms->hw_vbif[i] = NULL;
        }
 
        if (dpu_kms->rm_init)
@@ -1109,7 +1104,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
                struct dpu_hw_vbif *hw;
                const struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i];
 
-               hw = dpu_hw_vbif_init(vbif, dpu_kms->vbif[vbif->id]);
+               hw = dpu_hw_vbif_init(dev, vbif, dpu_kms->vbif[vbif->id]);
                if (IS_ERR(hw)) {
                        rc = PTR_ERR(hw);
                        DPU_ERROR("failed to init vbif %d: %d\n", vbif->id, rc);