Commit ff98a2fd authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

Merge patch series "can: c_can: Simplify few things"

This series by Krzysztof Kozlowski simplifies the c_can_plat_probe()
function.

Changes in v2:
- None, just rebase and drop applied fix.
- Link to v1: https://lore.kernel.org/r/20250112-syscon-phandle-args-can-v1-0-314d9549906f@linaro.org

Link: https://patch.msgid.link/20250212-syscon-phandle-args-can-v2-0-ac9a1253396b@linaro.org


Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parents aefd232d 9f0f0345
Loading
Loading
Loading
Loading
+15 −36
Original line number Diff line number Diff line
@@ -269,30 +269,22 @@ static int c_can_plat_probe(struct platform_device *pdev)

	/* get the appropriate clk */
	clk = devm_clk_get(&pdev->dev, NULL);
	if (IS_ERR(clk)) {
		ret = PTR_ERR(clk);
		goto exit;
	}
	if (IS_ERR(clk))
		return PTR_ERR(clk);

	/* get the platform data */
	irq = platform_get_irq(pdev, 0);
	if (irq < 0) {
		ret = irq;
		goto exit;
	}
	if (irq < 0)
		return irq;

	addr = devm_platform_get_and_ioremap_resource(pdev, 0, &mem);
	if (IS_ERR(addr)) {
		ret =  PTR_ERR(addr);
		goto exit;
	}
	if (IS_ERR(addr))
		return PTR_ERR(addr);

	/* allocate the c_can device */
	dev = alloc_c_can_dev(drvdata->msg_obj_num);
	if (!dev) {
		ret = -ENOMEM;
		goto exit;
	}
	if (!dev)
		return -ENOMEM;

	priv = netdev_priv(dev);
	switch (drvdata->id) {
@@ -324,33 +316,22 @@ static int c_can_plat_probe(struct platform_device *pdev)
		/* Check if we need custom RAMINIT via syscon. Mostly for TI
		 * platforms. Only supported with DT boot.
		 */
		if (np && of_property_read_bool(np, "syscon-raminit")) {
		if (np && of_property_present(np, "syscon-raminit")) {
			unsigned int args[2];
			u32 id;
			struct c_can_raminit *raminit = &priv->raminit_sys;

			ret = -EINVAL;
			raminit->syscon = syscon_regmap_lookup_by_phandle(np,
									  "syscon-raminit");
			raminit->syscon = syscon_regmap_lookup_by_phandle_args(np,
									       "syscon-raminit",
									       2, args);
			if (IS_ERR(raminit->syscon)) {
				/* can fail with -EPROBE_DEFER */
				ret = PTR_ERR(raminit->syscon);
				free_c_can_dev(dev);
				return ret;
			}

			if (of_property_read_u32_index(np, "syscon-raminit", 1,
						       &raminit->reg)) {
				dev_err(&pdev->dev,
					"couldn't get the RAMINIT reg. offset!\n");
				goto exit_free_device;
			}

			if (of_property_read_u32_index(np, "syscon-raminit", 2,
						       &id)) {
				dev_err(&pdev->dev,
					"couldn't get the CAN instance ID\n");
				goto exit_free_device;
			}
			raminit->reg = args[0];
			id = args[1];

			if (id >= drvdata->raminit_num) {
				dev_err(&pdev->dev,
@@ -396,8 +377,6 @@ static int c_can_plat_probe(struct platform_device *pdev)
	pm_runtime_disable(priv->device);
exit_free_device:
	free_c_can_dev(dev);
exit:
	dev_err(&pdev->dev, "probe failed\n");

	return ret;
}