Skip to content

Commit 7485be9

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: mtk_hdmi: Move CEC device parsing in new function
Move the CEC device parsing logic to a new function called mtk_hdmi_get_cec_dev(), and move the parsing action to the end of mtk_hdmi_dt_parse_pdata(), allowing to remove gotos in this function, reducing code size and improving readability. Reviewed-by: CK Hu <[email protected]> Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 03c7aea commit 7485be9

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

drivers/gpu/drm/mediatek/mtk_hdmi.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,14 +1357,10 @@ static const struct drm_bridge_funcs mtk_hdmi_bridge_funcs = {
13571357
.edid_read = mtk_hdmi_bridge_edid_read,
13581358
};
13591359

1360-
static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
1361-
struct platform_device *pdev)
1360+
static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np)
13621361
{
1363-
struct device *dev = &pdev->dev;
1364-
struct device_node *np = dev->of_node;
1365-
struct device_node *cec_np, *remote, *i2c_np;
13661362
struct platform_device *cec_pdev;
1367-
struct regmap *regmap;
1363+
struct device_node *cec_np;
13681364
int ret;
13691365

13701366
ret = mtk_hdmi_get_all_clk(hdmi, np);
@@ -1384,62 +1380,66 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
13841380
return -EPROBE_DEFER;
13851381
}
13861382
of_node_put(cec_np);
1387-
hdmi->cec_dev = &cec_pdev->dev;
13881383

13891384
/*
13901385
* The mediatek,syscon-hdmi property contains a phandle link to the
13911386
* MMSYS_CONFIG device and the register offset of the HDMI_SYS_CFG
13921387
* registers it contains.
13931388
*/
1394-
regmap = syscon_regmap_lookup_by_phandle_args(np, "mediatek,syscon-hdmi",
1395-
1, &hdmi->sys_offset);
1396-
if (IS_ERR(regmap)) {
1397-
ret = dev_err_probe(dev, PTR_ERR(regmap),
1398-
"Failed to get system configuration registers\n");
1399-
goto put_device;
1400-
}
1401-
hdmi->sys_regmap = regmap;
1389+
hdmi->sys_regmap = syscon_regmap_lookup_by_phandle_args(np, "mediatek,syscon-hdmi",
1390+
1, &hdmi->sys_offset);
1391+
if (IS_ERR(hdmi->sys_regmap))
1392+
return dev_err_probe(dev, PTR_ERR(hdmi->sys_regmap),
1393+
"Failed to get system configuration registers\n");
1394+
1395+
hdmi->cec_dev = &cec_pdev->dev;
1396+
return 0;
1397+
}
1398+
1399+
static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
1400+
struct platform_device *pdev)
1401+
{
1402+
struct device *dev = &pdev->dev;
1403+
struct device_node *np = dev->of_node;
1404+
struct device_node *remote, *i2c_np;
1405+
int ret;
1406+
1407+
ret = mtk_hdmi_get_all_clk(hdmi, np);
1408+
if (ret)
1409+
return dev_err_probe(dev, ret, "Failed to get clocks\n");
14021410

14031411
hdmi->regs = device_node_to_regmap(dev->of_node);
1404-
if (IS_ERR(hdmi->regs)) {
1405-
ret = PTR_ERR(hdmi->regs);
1406-
goto put_device;
1407-
}
1412+
if (IS_ERR(hdmi->regs))
1413+
return PTR_ERR(hdmi->regs);
14081414

14091415
remote = of_graph_get_remote_node(np, 1, 0);
1410-
if (!remote) {
1411-
ret = -EINVAL;
1412-
goto put_device;
1413-
}
1416+
if (!remote)
1417+
return -EINVAL;
14141418

14151419
if (!of_device_is_compatible(remote, "hdmi-connector")) {
14161420
hdmi->next_bridge = of_drm_find_bridge(remote);
14171421
if (!hdmi->next_bridge) {
14181422
dev_err(dev, "Waiting for external bridge\n");
14191423
of_node_put(remote);
1420-
ret = -EPROBE_DEFER;
1421-
goto put_device;
1424+
return -EPROBE_DEFER;
14221425
}
14231426
}
14241427

14251428
i2c_np = of_parse_phandle(remote, "ddc-i2c-bus", 0);
14261429
of_node_put(remote);
1427-
if (!i2c_np) {
1428-
ret = dev_err_probe(dev, -EINVAL, "No ddc-i2c-bus in connector\n");
1429-
goto put_device;
1430-
}
1430+
if (!i2c_np)
1431+
return dev_err_probe(dev, -EINVAL, "No ddc-i2c-bus in connector\n");
14311432

14321433
hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
14331434
of_node_put(i2c_np);
1434-
if (!hdmi->ddc_adpt) {
1435-
ret = dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n");
1436-
goto put_device;
1437-
}
1435+
if (!hdmi->ddc_adpt)
1436+
return dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n");
1437+
1438+
ret = mtk_hdmi_get_cec_dev(hdmi, dev, np);
1439+
if (ret)
1440+
return ret;
14381441

14391442
return 0;
1440-
put_device:
1441-
put_device(hdmi->cec_dev);
1442-
return ret;
14431443
}
14441444

14451445
/*

0 commit comments

Comments
 (0)