Re: [PATCH v1 5/5] [media] mtk-mdp: Remove mtk_mdp_comp.id and supporting functionality

2020-05-05 Thread Enric Balletbo Serra
Hi Eizan,

Thank you for your patch.

Missatge de Eizan Miyamoto  del dia dt., 5 de maig
2020 a les 6:02:
>
> Since components are registered in a list, the numeric component id that
> specified a location in an array is not necessary.
>
> Signed-off-by: ei...@chromium.org
> Signed-off-by: Eizan Miyamoto 

Ditto

> ---
>
>  drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 60 +++

This patch will conflict with this one [1]. It is already queued,
please rebase on top of it.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c?id=757570f11fa4b0ce5472a6583de6f06e996a8527


>  drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 19 +-
>  drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 +---
>  3 files changed, 11 insertions(+), 78 deletions(-)
>
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> index d4afed1363d5..362fff924aef 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
> @@ -14,46 +14,6 @@
>  #include "mtk_mdp_comp.h"
>
>
> -static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
> -   "mdp_rdma",
> -   "mdp_rsz",
> -   "mdp_wdma",
> -   "mdp_wrot",
> -};
> -
> -struct mtk_mdp_comp_match {
> -   enum mtk_mdp_comp_type type;
> -   int alias_id;
> -};
> -
> -static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MAX] 
> = {
> -   { MTK_MDP_RDMA, 0 },
> -   { MTK_MDP_RDMA, 1 },
> -   { MTK_MDP_RSZ,  0 },
> -   { MTK_MDP_RSZ,  1 },
> -   { MTK_MDP_RSZ,  2 },
> -   { MTK_MDP_WDMA, 0 },
> -   { MTK_MDP_WROT, 0 },
> -   { MTK_MDP_WROT, 1 },
> -};
> -
> -int mtk_mdp_comp_get_id(struct device *dev, struct device_node *node,
> -   enum mtk_mdp_comp_type comp_type)
> -{
> -   int id = of_alias_get_id(node, mtk_mdp_comp_stem[comp_type]);
> -   int i;
> -
> -   for (i = 0; i < ARRAY_SIZE(mtk_mdp_matches); i++) {
> -   if (comp_type == mtk_mdp_matches[i].type &&
> -   id == mtk_mdp_matches[i].alias_id)
> -   return i;
> -   }
> -
> -   dev_err(dev, "Failed to get id. type: %d, id: %d\n", comp_type, id);
> -
> -   return -EINVAL;
> -}
> -
>  void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
>  {
> int i, err;
> @@ -62,8 +22,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct 
> mtk_mdp_comp *comp)
> err = mtk_smi_larb_get(comp->larb_dev);
> if (err)
> dev_err(dev,
> -   "failed to get larb, err %d. type:%d id:%d\n",
> -   err, comp->type, comp->id);
> +   "failed to get larb, err %d. type:%d\n",
> +   err, comp->type);
> }
>
> for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
> @@ -72,8 +32,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct 
> mtk_mdp_comp *comp)
> err = clk_prepare_enable(comp->clk[i]);
> if (err)
> dev_err(dev,
> -   "failed to enable clock, err %d. type:%d id:%d 
> i:%d\n",
> -   err, comp->type, comp->id, i);
> +   "failed to enable clock, err %d. type:%d i:%d\n",
> +   err, comp->type, i);
> }
>  }
>
> @@ -92,21 +52,15 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct 
> mtk_mdp_comp *comp)
>  }
>
>  int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
> - struct mtk_mdp_comp *comp, enum mtk_mdp_comp_id comp_id)
> + struct mtk_mdp_comp *comp,
> + enum mtk_mdp_comp_type comp_type)
>  {
> struct device_node *larb_node;
> struct platform_device *larb_pdev;
> int i;
>
> -   if (comp_id < 0 || comp_id >= MTK_MDP_COMP_ID_MAX) {
> -   dev_err(dev, "Invalid comp_id %d\n", comp_id);
> -   return -EINVAL;
> -   }
> -
> -   INIT_LIST_HEAD(>node);
> comp->dev_node = of_node_get(node);
> -   comp->id = comp_id;
> -   comp->type = mtk_mdp_matches[comp_id].type;
> +   comp->type = comp_type;
>
> for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
> comp->clk[i] = of_clk_get(node, i);
> diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h 
> b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
> index 1f745891c6c3..1bf0242cce46 100644
> --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
> +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
> @@ -22,18 +22,6 @@ enum mtk_mdp_comp_type {
> MTK_MDP_COMP_TYPE_MAX,
>  };
>
> -enum mtk_mdp_comp_id {
> -   MTK_MDP_COMP_RDMA0,
> -   MTK_MDP_COMP_RDMA1,
> -   MTK_MDP_COMP_RSZ0,
> -   

[PATCH v1 5/5] [media] mtk-mdp: Remove mtk_mdp_comp.id and supporting functionality

2020-05-04 Thread Eizan Miyamoto
Since components are registered in a list, the numeric component id that
specified a location in an array is not necessary.

Signed-off-by: ei...@chromium.org
Signed-off-by: Eizan Miyamoto 
---

 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 60 +++
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 19 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 +---
 3 files changed, 11 insertions(+), 78 deletions(-)

diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
index d4afed1363d5..362fff924aef 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c
@@ -14,46 +14,6 @@
 #include "mtk_mdp_comp.h"
 
 
-static const char * const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX] = {
-   "mdp_rdma",
-   "mdp_rsz",
-   "mdp_wdma",
-   "mdp_wrot",
-};
-
-struct mtk_mdp_comp_match {
-   enum mtk_mdp_comp_type type;
-   int alias_id;
-};
-
-static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MAX] = {
-   { MTK_MDP_RDMA, 0 },
-   { MTK_MDP_RDMA, 1 },
-   { MTK_MDP_RSZ,  0 },
-   { MTK_MDP_RSZ,  1 },
-   { MTK_MDP_RSZ,  2 },
-   { MTK_MDP_WDMA, 0 },
-   { MTK_MDP_WROT, 0 },
-   { MTK_MDP_WROT, 1 },
-};
-
-int mtk_mdp_comp_get_id(struct device *dev, struct device_node *node,
-   enum mtk_mdp_comp_type comp_type)
-{
-   int id = of_alias_get_id(node, mtk_mdp_comp_stem[comp_type]);
-   int i;
-
-   for (i = 0; i < ARRAY_SIZE(mtk_mdp_matches); i++) {
-   if (comp_type == mtk_mdp_matches[i].type &&
-   id == mtk_mdp_matches[i].alias_id)
-   return i;
-   }
-
-   dev_err(dev, "Failed to get id. type: %d, id: %d\n", comp_type, id);
-
-   return -EINVAL;
-}
-
 void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp)
 {
int i, err;
@@ -62,8 +22,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct 
mtk_mdp_comp *comp)
err = mtk_smi_larb_get(comp->larb_dev);
if (err)
dev_err(dev,
-   "failed to get larb, err %d. type:%d id:%d\n",
-   err, comp->type, comp->id);
+   "failed to get larb, err %d. type:%d\n",
+   err, comp->type);
}
 
for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
@@ -72,8 +32,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct 
mtk_mdp_comp *comp)
err = clk_prepare_enable(comp->clk[i]);
if (err)
dev_err(dev,
-   "failed to enable clock, err %d. type:%d id:%d i:%d\n",
-   err, comp->type, comp->id, i);
+   "failed to enable clock, err %d. type:%d i:%d\n",
+   err, comp->type, i);
}
 }
 
@@ -92,21 +52,15 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct 
mtk_mdp_comp *comp)
 }
 
 int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
- struct mtk_mdp_comp *comp, enum mtk_mdp_comp_id comp_id)
+ struct mtk_mdp_comp *comp,
+ enum mtk_mdp_comp_type comp_type)
 {
struct device_node *larb_node;
struct platform_device *larb_pdev;
int i;
 
-   if (comp_id < 0 || comp_id >= MTK_MDP_COMP_ID_MAX) {
-   dev_err(dev, "Invalid comp_id %d\n", comp_id);
-   return -EINVAL;
-   }
-
-   INIT_LIST_HEAD(>node);
comp->dev_node = of_node_get(node);
-   comp->id = comp_id;
-   comp->type = mtk_mdp_matches[comp_id].type;
+   comp->type = comp_type;
 
for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
comp->clk[i] = of_clk_get(node, i);
diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h 
b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
index 1f745891c6c3..1bf0242cce46 100644
--- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
+++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h
@@ -22,18 +22,6 @@ enum mtk_mdp_comp_type {
MTK_MDP_COMP_TYPE_MAX,
 };
 
-enum mtk_mdp_comp_id {
-   MTK_MDP_COMP_RDMA0,
-   MTK_MDP_COMP_RDMA1,
-   MTK_MDP_COMP_RSZ0,
-   MTK_MDP_COMP_RSZ1,
-   MTK_MDP_COMP_RSZ2,
-   MTK_MDP_COMP_WDMA,
-   MTK_MDP_COMP_WROT0,
-   MTK_MDP_COMP_WROT1,
-   MTK_MDP_COMP_ID_MAX,
-};
-
 /**
  * struct mtk_mdp_comp - the MDP's function component data
  * @node:  list node to track sibing MDP components
@@ -41,7 +29,6 @@ enum mtk_mdp_comp_id {
  * @clk:   clocks required for component
  * @larb_dev:  SMI device required for component
  * @type:  component type
- * @id:component ID
  */
 struct mtk_mdp_comp {
struct list_headnode;
@@ -49,14 +36,12 @@ struct mtk_mdp_comp {
struct clk  *clk[2];