Commit bdfa47d9 authored by Dmitry Baryshkov's avatar Dmitry Baryshkov

drm/msm/dpu: use devres-managed allocation for VBIF data

Use devm_kzalloc to create VBIF data structure. This allows us to
remove corresponding kfree and drop dpu_hw_vbif_destroy() function.
Reviewed-by: default avatarJessica Zhang <quic_jesszhan@quicinc.com>
Signed-off-by: default avatarDmitry 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
parent b19e6f7d
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
*/ */
#include <drm/drm_managed.h>
#include "dpu_hwio.h" #include "dpu_hwio.h"
#include "dpu_hw_catalog.h" #include "dpu_hw_catalog.h"
#include "dpu_hw_vbif.h" #include "dpu_hw_vbif.h"
...@@ -211,12 +213,13 @@ static void _setup_vbif_ops(struct dpu_hw_vbif_ops *ops, ...@@ -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; 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, struct dpu_hw_vbif *dpu_hw_vbif_init(struct drm_device *dev,
const struct dpu_vbif_cfg *cfg,
void __iomem *addr) void __iomem *addr)
{ {
struct dpu_hw_vbif *c; struct dpu_hw_vbif *c;
c = kzalloc(sizeof(*c), GFP_KERNEL); c = drmm_kzalloc(dev, sizeof(*c), GFP_KERNEL);
if (!c) if (!c)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -234,8 +237,3 @@ struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg, ...@@ -234,8 +237,3 @@ struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg,
return c; return c;
} }
void dpu_hw_vbif_destroy(struct dpu_hw_vbif *vbif)
{
kfree(vbif);
}
...@@ -108,12 +108,12 @@ struct dpu_hw_vbif { ...@@ -108,12 +108,12 @@ struct dpu_hw_vbif {
/** /**
* dpu_hw_vbif_init() - Initializes the VBIF driver for the passed * dpu_hw_vbif_init() - Initializes the VBIF driver for the passed
* VBIF catalog entry. * VBIF catalog entry.
* @dev: Corresponding device for devres management
* @cfg: VBIF catalog entry for which driver object is required * @cfg: VBIF catalog entry for which driver object is required
* @addr: Mapped register io address of MDSS * @addr: Mapped register io address of MDSS
*/ */
struct dpu_hw_vbif *dpu_hw_vbif_init(const struct dpu_vbif_cfg *cfg, struct dpu_hw_vbif *dpu_hw_vbif_init(struct drm_device *dev,
const struct dpu_vbif_cfg *cfg,
void __iomem *addr); void __iomem *addr);
void dpu_hw_vbif_destroy(struct dpu_hw_vbif *vbif);
#endif /*_DPU_HW_VBIF_H */ #endif /*_DPU_HW_VBIF_H */
...@@ -800,14 +800,9 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms) ...@@ -800,14 +800,9 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
/* safe to call these more than once during shutdown */ /* safe to call these more than once during shutdown */
_dpu_kms_mmu_destroy(dpu_kms); _dpu_kms_mmu_destroy(dpu_kms);
if (dpu_kms->catalog) {
for (i = 0; i < ARRAY_SIZE(dpu_kms->hw_vbif); i++) { 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; dpu_kms->hw_vbif[i] = NULL;
} }
}
}
if (dpu_kms->rm_init) if (dpu_kms->rm_init)
dpu_rm_destroy(&dpu_kms->rm); dpu_rm_destroy(&dpu_kms->rm);
...@@ -1109,7 +1104,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms) ...@@ -1109,7 +1104,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
struct dpu_hw_vbif *hw; struct dpu_hw_vbif *hw;
const struct dpu_vbif_cfg *vbif = &dpu_kms->catalog->vbif[i]; 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)) { if (IS_ERR(hw)) {
rc = PTR_ERR(hw); rc = PTR_ERR(hw);
DPU_ERROR("failed to init vbif %d: %d\n", vbif->id, rc); DPU_ERROR("failed to init vbif %d: %d\n", vbif->id, rc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment