Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2516b0b authored by Chris Lew's avatar Chris Lew
Browse files

soc: qcom: glink_probe: Move node parsing logic into helper



The complexity of adding a glink node may increase in the future for
SSR cases and new transports. Move this logic into a helper function
to avoid nested indentation.

Change-Id: I089975994023f0a8c5774f692e5affb488efcf01
Signed-off-by: default avatarChris Lew <clew@codeaurora.org>
parent c92f19d6
Loading
Loading
Loading
Loading
+34 −27
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -19,34 +19,41 @@

static struct qcom_glink *edge_infos[NUM_SUBSYSTEMS];

static int glink_probe(struct platform_device *pdev)
static void probe_subsystem(struct device *dev, struct device_node *np)
{
	struct device_node *cn, *pn = pdev->dev.of_node;
	struct qcom_glink *glink = ERR_PTR(-EINVAL);
	const char *xprt;
	const char *transport;
	u32 pid;
	int ret;

	for_each_available_child_of_node(pn, cn) {
		ret = of_property_read_u32(cn, "qcom,remote-pid", &pid);
	ret = of_property_read_u32(np, "qcom,remote-pid", &pid);
	if (ret || pid >= NUM_SUBSYSTEMS) {
			dev_err(&pdev->dev, "invalid pid:%d ret:%d\n",
				pid, ret);
			return -EINVAL;
		dev_err(dev, "invalid pid:%d ret:%d\n", pid, ret);
		return;
	}
		xprt = of_get_property(cn, "transport", NULL);
		if (!xprt) {
			dev_err(&pdev->dev, "missing xprt pid:%d\n", pid);
			return -EINVAL;

	ret = of_property_read_string(np, "transport", &transport);
	if (ret < 0) {
		dev_err(dev, "missing transport pid:%d\n", pid);
		return;
	}
		if (!strcmp(xprt, "smem"))
			glink = qcom_glink_smem_register(&pdev->dev, cn);
	if (!strcmp(transport, "smem"))
		glink = qcom_glink_smem_register(dev, np);

	if (IS_ERR(glink)) {
			dev_err(&pdev->dev, "%s failed\n", cn->name);
			return PTR_ERR(glink);
		dev_err(dev, "%s failed %d\n", np->name, PTR_ERR(glink));
		return;
	}
	edge_infos[pid] = glink;
}

static int glink_probe(struct platform_device *pdev)
{
	struct device_node *cn, *pn = pdev->dev.of_node;

	for_each_available_child_of_node(pn, cn) {
		probe_subsystem(&pdev->dev, cn);
	}
	return 0;
}

@@ -66,13 +73,13 @@ static struct platform_driver glink_probe_driver = {

static int __init glink_probe_init(void)
{
	int rc;
	int ret;

	rc = platform_driver_register(&glink_probe_driver);
	if (rc) {
	ret = platform_driver_register(&glink_probe_driver);
	if (ret) {
		pr_err("%s: glink_probe register failed %d\n",
			__func__, rc);
		return rc;
			__func__, ret);
		return ret;
	}

	return 0;