[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <665202d7-46be-4dc8-a6be-3579e1ec078f@bosc.ac.cn>
Date: Wed, 22 May 2024 20:13:34 +0800
From: Sui Jingfeng <suijingfeng@...c.ac.cn>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
chunkuang.hu@...nel.org
Cc: robh@...nel.org, krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
p.zabel@...gutronix.de, airlied@...il.com, daniel@...ll.ch,
maarten.lankhorst@...ux.intel.com, mripard@...nel.org, tzimmermann@...e.de,
matthias.bgg@...il.com, shawn.sung@...iatek.com, yu-chang.lee@...iatek.com,
ck.hu@...iatek.com, jitao.shi@...iatek.com, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
linux-mediatek@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
wenst@...omium.org, kernel@...labora.com,
Alexandre Mergnat <amergnat@...libre.com>
Subject: Re: [v5,3/3] drm/mediatek: Implement OF graphs support for display
paths
Hi,
On 5/21/24 15:57, AngeloGioacchino Del Regno wrote:
> +static int mtk_drm_of_get_ddp_comp_type(struct device_node *node, enum mtk_ddp_comp_type *ctype)
> +{
> + const struct of_device_id *of_id = of_match_node(mtk_ddp_comp_dt_ids, node);
> +
> + if (!of_id)
> + return -EINVAL;
> +
> + *ctype = (enum mtk_ddp_comp_type)((uintptr_t)of_id->data);
> +
> + return 0;
> +}
> +
> +static int mtk_drm_of_get_ddp_ep_cid(struct device_node *node,
> + int output_port, enum mtk_crtc_path crtc_path,
> + struct device_node **next, unsigned int *cid)
> +{
> + struct device_node *ep_dev_node, *ep_out;
> + enum mtk_ddp_comp_type comp_type;
> + int ret;
> +
> + ep_out = of_graph_get_endpoint_by_regs(node, output_port, crtc_path);
> + if (!ep_out)
> + return -ENOENT;
> +
> + ep_dev_node = of_graph_get_remote_port_parent(ep_out);
below here, 'ep_out' will not be used anymore.
of_node_put(ep_out);
Maybe we should call it under a error handling tag?
But this is trivial problem.
> + if (!ep_dev_node)
> + return -EINVAL;
> +
> + /*
> + * Pass the next node pointer regardless of failures in the later code
> + * so that if this function is called in a loop it will walk through all
> + * of the subsequent endpoints anyway.
> + */
> + *next = ep_dev_node;
> +
> + if (!of_device_is_available(ep_dev_node))
> + return -ENODEV;
> +
> + ret = mtk_drm_of_get_ddp_comp_type(ep_dev_node, &comp_type);
> + if (ret) {
> + if (mtk_ovl_adaptor_is_comp_present(ep_dev_node)) {
> + *cid = (unsigned int)DDP_COMPONENT_DRM_OVL_ADAPTOR;
> + return 0;
> + }
> + return ret;
> + }
> +
> + ret = mtk_ddp_comp_get_id(ep_dev_node, comp_type);
> + if (ret < 0)
> + return ret;
> +
> + /* All ok! Pass the Component ID to the caller. */
> + *cid = (unsigned int)ret;
> +
> + return 0;
> +}
> +
--
Best regards
Sui Jingfeng
Powered by blists - more mailing lists