Skip to content

Commit 6724059

Browse files
sandy-huangrkhuangtao
authored andcommitted
drm/rockchip: lvds: if port is null return -EINVAL
Change-Id: I9503b4f2d317a12d91ce136213d8d2e629b72823 Signed-off-by: Huang Jiachai <hjc@rock-chips.com>
1 parent 2d1c413 commit 6724059

1 file changed

Lines changed: 52 additions & 49 deletions

File tree

drivers/gpu/drm/rockchip/rockchip_lvds.c

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -673,64 +673,67 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
673673
lvds->drm_dev = drm_dev;
674674

675675
port = of_graph_get_port_by_id(dev->of_node, 1);
676-
if (port) {
677-
endpoint = of_get_child_by_name(port, "endpoint");
678-
of_node_put(port);
679-
if (!endpoint) {
680-
dev_err(dev, "no output endpoint found\n");
681-
return -EINVAL;
682-
}
683-
panel_node = of_graph_get_remote_port_parent(endpoint);
684-
of_node_put(endpoint);
685-
if (!panel_node) {
686-
dev_err(dev, "no output node found\n");
687-
return -EINVAL;
688-
}
689-
lvds->panel = of_drm_find_panel(panel_node);
690-
if (!lvds->panel) {
691-
DRM_ERROR("failed to find panel\n");
692-
of_node_put(panel_node);
693-
return -EPROBE_DEFER;
694-
}
676+
if (!port) {
677+
dev_err(dev, "can't found port point, please init lvds panel port!\n");
678+
return -EINVAL;
679+
}
695680

696-
if (of_property_read_string(panel_node, "rockchip,output", &name))
697-
/* default set it as output rgb */
698-
lvds->output = DISPLAY_OUTPUT_RGB;
699-
else
700-
lvds->output = lvds_name_to_output(name);
681+
endpoint = of_get_child_by_name(port, "endpoint");
682+
of_node_put(port);
683+
if (!endpoint) {
684+
dev_err(dev, "no output endpoint found\n");
685+
return -EINVAL;
686+
}
687+
panel_node = of_graph_get_remote_port_parent(endpoint);
688+
of_node_put(endpoint);
689+
if (!panel_node) {
690+
dev_err(dev, "no output node found\n");
691+
return -EINVAL;
692+
}
693+
lvds->panel = of_drm_find_panel(panel_node);
694+
if (!lvds->panel) {
695+
DRM_ERROR("failed to find panel\n");
696+
of_node_put(panel_node);
697+
return -EPROBE_DEFER;
698+
}
701699

702-
if (lvds->output < 0) {
703-
dev_err(dev, "invalid output type [%s]\n", name);
704-
return lvds->output;
705-
}
700+
if (of_property_read_string(panel_node, "rockchip,output", &name))
701+
/* default set it as output rgb */
702+
lvds->output = DISPLAY_OUTPUT_RGB;
703+
else
704+
lvds->output = lvds_name_to_output(name);
706705

707-
if (of_property_read_string(panel_node, "rockchip,data-mapping",
708-
&name))
709-
/* default set it as format jeida */
710-
lvds->format = LVDS_FORMAT_JEIDA;
711-
else
712-
lvds->format = lvds_name_to_format(name);
706+
if (lvds->output < 0) {
707+
dev_err(dev, "invalid output type [%s]\n", name);
708+
return lvds->output;
709+
}
713710

714-
if (lvds->format < 0) {
715-
dev_err(dev, "invalid data-mapping format [%s]\n", name);
716-
return lvds->format;
717-
}
711+
if (of_property_read_string(panel_node, "rockchip,data-mapping",
712+
&name))
713+
/* default set it as format jeida */
714+
lvds->format = LVDS_FORMAT_JEIDA;
715+
else
716+
lvds->format = lvds_name_to_format(name);
718717

719-
if (of_property_read_u32(panel_node, "rockchip,data-width", &i)) {
718+
if (lvds->format < 0) {
719+
dev_err(dev, "invalid data-mapping format [%s]\n", name);
720+
return lvds->format;
721+
}
722+
723+
if (of_property_read_u32(panel_node, "rockchip,data-width", &i)) {
724+
lvds->format |= LVDS_24BIT;
725+
} else {
726+
if (i == 24) {
720727
lvds->format |= LVDS_24BIT;
728+
} else if (i == 18) {
729+
lvds->format |= LVDS_18BIT;
721730
} else {
722-
if (i == 24) {
723-
lvds->format |= LVDS_24BIT;
724-
} else if (i == 18) {
725-
lvds->format |= LVDS_18BIT;
726-
} else {
727-
dev_err(dev,
728-
"rockchip-lvds unsupport data-width[%d]\n", i);
729-
return -EINVAL;
730-
}
731+
dev_err(dev,
732+
"rockchip-lvds unsupport data-width[%d]\n", i);
733+
return -EINVAL;
731734
}
732-
of_node_put(panel_node);
733735
}
736+
of_node_put(panel_node);
734737

735738
encoder = &lvds->encoder;
736739
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev,

0 commit comments

Comments
 (0)