Unverified Commit 6a2ab229 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Mark Brown
Browse files

spi: cadence-quadspi: Simplify with scoped for each OF child loop



Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.

Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240814143805.98874-1-krzysztof.kozlowski@linaro.org


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7781f1d1
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -1662,23 +1662,20 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
	unsigned int max_cs = cqspi->num_chipselect - 1;
	struct platform_device *pdev = cqspi->pdev;
	struct device *dev = &pdev->dev;
	struct device_node *np = dev->of_node;
	struct cqspi_flash_pdata *f_pdata;
	unsigned int cs;
	int ret;

	/* Get flash device data */
	for_each_available_child_of_node(dev->of_node, np) {
	for_each_available_child_of_node_scoped(dev->of_node, np) {
		ret = of_property_read_u32(np, "reg", &cs);
		if (ret) {
			dev_err(dev, "Couldn't determine chip select.\n");
			of_node_put(np);
			return ret;
		}

		if (cs >= cqspi->num_chipselect) {
			dev_err(dev, "Chip select %d out of range.\n", cs);
			of_node_put(np);
			return -EINVAL;
		} else if (cs < max_cs) {
			max_cs = cs;
@@ -1689,11 +1686,9 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
		f_pdata->cs = cs;

		ret = cqspi_of_get_flash_pdata(pdev, f_pdata, np);
		if (ret) {
			of_node_put(np);
		if (ret)
			return ret;
	}
	}

	cqspi->num_chipselect = max_cs + 1;
	return 0;