LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] drm/mediatek: Test component initialization earlier in the function mtk_drm_crtc_create
@ 2021-07-12 18:12 Dafna Hirschfeld
  2021-08-09 14:20 ` Chun-Kuang Hu
  0 siblings, 1 reply; 2+ messages in thread
From: Dafna Hirschfeld @ 2021-07-12 18:12 UTC (permalink / raw)
  To: dri-devel, linux-mediatek, linux-kernel
  Cc: dafna.hirschfeld, kernel, dafna3, chunkuang.hu, p.zabel, airlied,
	daniel, enric.balletbo, laurent.pinchart

The initialization is currently tested in a later stage in
the function for no reason.
In addition, the test '!comp' will never fail since comp is
set with the '&' operator. Instead, test if a comp was not
initialized by testing "!comp->dev".

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 474efb844249..06f40e589922 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -755,14 +755,22 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
 	for (i = 0; i < path_len; i++) {
 		enum mtk_ddp_comp_id comp_id = path[i];
 		struct device_node *node;
+		struct mtk_ddp_comp *comp;
 
 		node = priv->comp_node[comp_id];
+		comp = &priv->ddp_comp[comp_id];
+
 		if (!node) {
 			dev_info(dev,
 				 "Not creating crtc %d because component %d is disabled or missing\n",
 				 pipe, comp_id);
 			return 0;
 		}
+
+		if (!comp->dev) {
+			dev_err(dev, "Component %pOF not initialized\n", node);
+			return -ENODEV;
+		}
 	}
 
 	mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
@@ -787,16 +795,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
 	for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
 		enum mtk_ddp_comp_id comp_id = path[i];
 		struct mtk_ddp_comp *comp;
-		struct device_node *node;
 
-		node = priv->comp_node[comp_id];
 		comp = &priv->ddp_comp[comp_id];
-		if (!comp) {
-			dev_err(dev, "Component %pOF not initialized\n", node);
-			ret = -ENODEV;
-			return ret;
-		}
-
 		mtk_crtc->ddp_comp[i] = comp;
 
 		if (comp->funcs) {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/mediatek: Test component initialization earlier in the function mtk_drm_crtc_create
  2021-07-12 18:12 [PATCH] drm/mediatek: Test component initialization earlier in the function mtk_drm_crtc_create Dafna Hirschfeld
@ 2021-08-09 14:20 ` Chun-Kuang Hu
  0 siblings, 0 replies; 2+ messages in thread
From: Chun-Kuang Hu @ 2021-08-09 14:20 UTC (permalink / raw)
  To: Dafna Hirschfeld
  Cc: DRI Development, moderated list:ARM/Mediatek SoC support,
	linux-kernel, Collabora Kernel ML, dafna3, Chun-Kuang Hu,
	Philipp Zabel, David Airlie, Daniel Vetter,
	Enric Balletbo i Serra, Laurent Pinchart

Hi, Dafna:

Dafna Hirschfeld <dafna.hirschfeld@collabora.com> 於 2021年7月13日 週二 上午2:12寫道:
>
> The initialization is currently tested in a later stage in
> the function for no reason.
> In addition, the test '!comp' will never fail since comp is
> set with the '&' operator. Instead, test if a comp was not
> initialized by testing "!comp->dev".

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 474efb844249..06f40e589922 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -755,14 +755,22 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>         for (i = 0; i < path_len; i++) {
>                 enum mtk_ddp_comp_id comp_id = path[i];
>                 struct device_node *node;
> +               struct mtk_ddp_comp *comp;
>
>                 node = priv->comp_node[comp_id];
> +               comp = &priv->ddp_comp[comp_id];
> +
>                 if (!node) {
>                         dev_info(dev,
>                                  "Not creating crtc %d because component %d is disabled or missing\n",
>                                  pipe, comp_id);
>                         return 0;
>                 }
> +
> +               if (!comp->dev) {
> +                       dev_err(dev, "Component %pOF not initialized\n", node);
> +                       return -ENODEV;
> +               }
>         }
>
>         mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
> @@ -787,16 +795,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>         for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
>                 enum mtk_ddp_comp_id comp_id = path[i];
>                 struct mtk_ddp_comp *comp;
> -               struct device_node *node;
>
> -               node = priv->comp_node[comp_id];
>                 comp = &priv->ddp_comp[comp_id];
> -               if (!comp) {
> -                       dev_err(dev, "Component %pOF not initialized\n", node);
> -                       ret = -ENODEV;
> -                       return ret;
> -               }
> -
>                 mtk_crtc->ddp_comp[i] = comp;
>
>                 if (comp->funcs) {
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-09 14:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 18:12 [PATCH] drm/mediatek: Test component initialization earlier in the function mtk_drm_crtc_create Dafna Hirschfeld
2021-08-09 14:20 ` Chun-Kuang Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).