Skip to content

Commit 5b0ef98

Browse files
Dafna HirschfeldChun-Kuang Hu
authored andcommitted
drm/mediatek: Test component initialization earlier in the function mtk_drm_crtc_create
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 <[email protected]> Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 58e4c53 commit 5b0ef98

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,22 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
755755
for (i = 0; i < path_len; i++) {
756756
enum mtk_ddp_comp_id comp_id = path[i];
757757
struct device_node *node;
758+
struct mtk_ddp_comp *comp;
758759

759760
node = priv->comp_node[comp_id];
761+
comp = &priv->ddp_comp[comp_id];
762+
760763
if (!node) {
761764
dev_info(dev,
762765
"Not creating crtc %d because component %d is disabled or missing\n",
763766
pipe, comp_id);
764767
return 0;
765768
}
769+
770+
if (!comp->dev) {
771+
dev_err(dev, "Component %pOF not initialized\n", node);
772+
return -ENODEV;
773+
}
766774
}
767775

768776
mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL);
@@ -787,16 +795,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
787795
for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
788796
enum mtk_ddp_comp_id comp_id = path[i];
789797
struct mtk_ddp_comp *comp;
790-
struct device_node *node;
791798

792-
node = priv->comp_node[comp_id];
793799
comp = &priv->ddp_comp[comp_id];
794-
if (!comp) {
795-
dev_err(dev, "Component %pOF not initialized\n", node);
796-
ret = -ENODEV;
797-
return ret;
798-
}
799-
800800
mtk_crtc->ddp_comp[i] = comp;
801801

802802
if (comp->funcs) {

0 commit comments

Comments
 (0)