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

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.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7781f1d1
...@@ -1662,23 +1662,20 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi) ...@@ -1662,23 +1662,20 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
unsigned int max_cs = cqspi->num_chipselect - 1; unsigned int max_cs = cqspi->num_chipselect - 1;
struct platform_device *pdev = cqspi->pdev; struct platform_device *pdev = cqspi->pdev;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct cqspi_flash_pdata *f_pdata; struct cqspi_flash_pdata *f_pdata;
unsigned int cs; unsigned int cs;
int ret; int ret;
/* Get flash device data */ /* 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); ret = of_property_read_u32(np, "reg", &cs);
if (ret) { if (ret) {
dev_err(dev, "Couldn't determine chip select.\n"); dev_err(dev, "Couldn't determine chip select.\n");
of_node_put(np);
return ret; return ret;
} }
if (cs >= cqspi->num_chipselect) { if (cs >= cqspi->num_chipselect) {
dev_err(dev, "Chip select %d out of range.\n", cs); dev_err(dev, "Chip select %d out of range.\n", cs);
of_node_put(np);
return -EINVAL; return -EINVAL;
} else if (cs < max_cs) { } else if (cs < max_cs) {
max_cs = cs; max_cs = cs;
...@@ -1689,10 +1686,8 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi) ...@@ -1689,10 +1686,8 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
f_pdata->cs = cs; f_pdata->cs = cs;
ret = cqspi_of_get_flash_pdata(pdev, f_pdata, np); ret = cqspi_of_get_flash_pdata(pdev, f_pdata, np);
if (ret) { if (ret)
of_node_put(np);
return ret; return ret;
}
} }
cqspi->num_chipselect = max_cs + 1; cqspi->num_chipselect = max_cs + 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment