drm/msm/dpu: use devres-managed allocation for interrupts data
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Fri, 1 Dec 2023 21:18:35 +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 interrupts data structure. This allows us to
remove corresponding kfree and drop dpu_hw_intr_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/570038/
Link: https://lore.kernel.org/r/20231201211845.1026967-4-dmitry.baryshkov@linaro.org
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.c
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_interrupts.h
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c

index 088807db2c83d93277acae21bf4ca170bff94392..946dd0135dffcf7dcd2b7f6445c62c048a044e8d 100644 (file)
@@ -6,6 +6,8 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 
+#include <drm/drm_managed.h>
+
 #include "dpu_core_irq.h"
 #include "dpu_kms.h"
 #include "dpu_hw_interrupts.h"
@@ -472,8 +474,9 @@ u32 dpu_core_irq_read(struct dpu_kms *dpu_kms,
        return intr_status;
 }
 
-struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,
-               const struct dpu_mdss_cfg *m)
+struct dpu_hw_intr *dpu_hw_intr_init(struct drm_device *dev,
+                                    void __iomem *addr,
+                                    const struct dpu_mdss_cfg *m)
 {
        struct dpu_hw_intr *intr;
        unsigned int i;
@@ -481,7 +484,7 @@ struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,
        if (!addr || !m)
                return ERR_PTR(-EINVAL);
 
-       intr = kzalloc(sizeof(*intr), GFP_KERNEL);
+       intr = drmm_kzalloc(dev, sizeof(*intr), GFP_KERNEL);
        if (!intr)
                return ERR_PTR(-ENOMEM);
 
@@ -512,11 +515,6 @@ struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,
        return intr;
 }
 
-void dpu_hw_intr_destroy(struct dpu_hw_intr *intr)
-{
-       kfree(intr);
-}
-
 int dpu_core_irq_register_callback(struct dpu_kms *dpu_kms,
                                   unsigned int irq_idx,
                                   void (*irq_cb)(void *arg),
index 53a21ebc57e8b960fad36e7d161fccfdd51baa20..564b750a28fe28749832861a9789fe6e341fcdd2 100644 (file)
@@ -70,15 +70,12 @@ struct dpu_hw_intr {
 
 /**
  * dpu_hw_intr_init(): Initializes the interrupts hw object
+ * @dev:  Corresponding device for devres management
  * @addr: mapped register io address of MDP
  * @m:    pointer to MDSS catalog data
  */
-struct dpu_hw_intr *dpu_hw_intr_init(void __iomem *addr,
-               const struct dpu_mdss_cfg *m);
+struct dpu_hw_intr *dpu_hw_intr_init(struct drm_device *dev,
+                                    void __iomem *addr,
+                                    const struct dpu_mdss_cfg *m);
 
-/**
- * dpu_hw_intr_destroy(): Cleanup interrutps hw object
- * @intr: pointer to interrupts hw object
- */
-void dpu_hw_intr_destroy(struct dpu_hw_intr *intr);
 #endif
index 75663f1626188d3eb96d597b7920a6d50d2fa0ec..34d707db1d0cb327b2a0b9ae2ad20ac775c1a75f 100644 (file)
@@ -795,8 +795,6 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
 {
        int i;
 
-       if (dpu_kms->hw_intr)
-               dpu_hw_intr_destroy(dpu_kms->hw_intr);
        dpu_kms->hw_intr = NULL;
 
        /* safe to call these more than once during shutdown */
@@ -1134,7 +1132,7 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
                goto err_pm_put;
        }
 
-       dpu_kms->hw_intr = dpu_hw_intr_init(dpu_kms->mmio, dpu_kms->catalog);
+       dpu_kms->hw_intr = dpu_hw_intr_init(dev, dpu_kms->mmio, dpu_kms->catalog);
        if (IS_ERR(dpu_kms->hw_intr)) {
                rc = PTR_ERR(dpu_kms->hw_intr);
                DPU_ERROR("hw_intr init failed: %d\n", rc);