media: qcom: camss: change internals of endpoint parsing to fwnode handling

Since a few called V4L2 functions operate with fwnode arguments the change
from OF device nodes to fwnodes brings a simplification to the code.

The camss_parse_endpoint_node() function is called once by camss_probe(),
and there is no use of knowing a number of asynchronously registered
remote devices, so it makes sense to remove the related computation from
the function.

Tested-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
Vladimir Zapolskiy 2025-11-20 02:46:03 +02:00 committed by Hans Verkuil
parent d965919af5
commit eccf5fa8e3

View File

@ -4206,16 +4206,16 @@ static const struct parent_dev_ops vfe_parent_dev_ops = {
};
/*
* camss_of_parse_endpoint_node - Parse port endpoint node
* @dev: Device
* @node: Device node to be parsed
* camss_parse_endpoint_node - Parse port endpoint node
* @dev: CAMSS device
* @ep: Device endpoint to be parsed
* @csd: Parsed data from port endpoint node
*
* Return 0 on success or a negative error code on failure
*/
static int camss_of_parse_endpoint_node(struct device *dev,
struct device_node *node,
struct camss_async_subdev *csd)
static int camss_parse_endpoint_node(struct device *dev,
struct fwnode_handle *ep,
struct camss_async_subdev *csd)
{
struct csiphy_lanes_cfg *lncfg = &csd->interface.csi2.lane_cfg;
struct v4l2_mbus_config_mipi_csi2 *mipi_csi2;
@ -4223,7 +4223,7 @@ static int camss_of_parse_endpoint_node(struct device *dev,
unsigned int i;
int ret;
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node), &vep);
ret = v4l2_fwnode_endpoint_parse(ep, &vep);
if (ret)
return ret;
@ -4258,49 +4258,46 @@ static int camss_of_parse_endpoint_node(struct device *dev,
}
/*
* camss_of_parse_ports - Parse ports node
* @dev: Device
* @notifier: v4l2_device notifier data
* camss_parse_ports - Parse ports node
* @dev: CAMSS device
*
* Return number of "port" nodes found in "ports" node
* Return 0 on success or a negative error code on failure
*/
static int camss_of_parse_ports(struct camss *camss)
static int camss_parse_ports(struct camss *camss)
{
struct device *dev = camss->dev;
struct device_node *node = NULL;
struct device_node *remote = NULL;
int ret, num_subdevs = 0;
struct fwnode_handle *fwnode = dev_fwnode(dev), *ep;
int ret;
for_each_endpoint_of_node(dev->of_node, node) {
fwnode_graph_for_each_endpoint(fwnode, ep) {
struct camss_async_subdev *csd;
struct fwnode_handle *remote;
remote = of_graph_get_remote_port_parent(node);
remote = fwnode_graph_get_remote_port_parent(ep);
if (!remote) {
dev_err(dev, "Cannot get remote parent\n");
ret = -EINVAL;
goto err_cleanup;
}
csd = v4l2_async_nf_add_fwnode(&camss->notifier,
of_fwnode_handle(remote),
csd = v4l2_async_nf_add_fwnode(&camss->notifier, remote,
struct camss_async_subdev);
of_node_put(remote);
fwnode_handle_put(remote);
if (IS_ERR(csd)) {
ret = PTR_ERR(csd);
goto err_cleanup;
}
ret = camss_of_parse_endpoint_node(dev, node, csd);
ret = camss_parse_endpoint_node(dev, ep, csd);
if (ret < 0)
goto err_cleanup;
num_subdevs++;
}
return num_subdevs;
return 0;
err_cleanup:
of_node_put(node);
fwnode_handle_put(ep);
return ret;
}
@ -4857,7 +4854,7 @@ static int camss_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
ret = camss_of_parse_ports(camss);
ret = camss_parse_ports(camss);
if (ret < 0)
goto err_v4l2_device_unregister;