linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: cadence-xspi: use for_each_available_child_of_node_scoped()
@ 2024-04-10 13:01 Kousik Sanagavarapu
  2024-04-10 19:37 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Kousik Sanagavarapu @ 2024-04-10 13:01 UTC (permalink / raw)
  To: linux-spi, linux-kernel
  Cc: Mark Brown, Shuah Khan, Javier Carrasco, Julia Lawall,
	Kousik Sanagavarapu

Refactor code for "is the node's child available?" check by using the
corresponding macro instead, which reads more clearly.

While at it, use scope-based cleanup instead of manual of_node_put()
calls when getting platform data through cdns_xspi_of_get_plat_data().

This removes the unnecessary "node_child" declaration out of the loop's
scope and auto cleans up "node_child" when it goes out of scope, even
when we return early due to error.

Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
---
 drivers/spi/spi-cadence-xspi.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xspi.c
index 8648b8eb080d..2209e9fc378f 100644
--- a/drivers/spi/spi-cadence-xspi.c
+++ b/drivers/spi/spi-cadence-xspi.c
@@ -486,20 +486,14 @@ static irqreturn_t cdns_xspi_irq_handler(int this_irq, void *dev)
 static int cdns_xspi_of_get_plat_data(struct platform_device *pdev)
 {
 	struct device_node *node_prop = pdev->dev.of_node;
-	struct device_node *node_child;
 	unsigned int cs;
 
-	for_each_child_of_node(node_prop, node_child) {
-		if (!of_device_is_available(node_child))
-			continue;
-
+	for_each_available_child_of_node_scoped(node_prop, node_child) {
 		if (of_property_read_u32(node_child, "reg", &cs)) {
 			dev_err(&pdev->dev, "Couldn't get memory chip select\n");
-			of_node_put(node_child);
 			return -ENXIO;
 		} else if (cs >= CDNS_XSPI_MAX_BANKS) {
 			dev_err(&pdev->dev, "reg (cs) parameter value too large\n");
-			of_node_put(node_child);
 			return -ENXIO;
 		}
 	}
-- 
2.44.0.548.g91ec36f2cc


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: cadence-xspi: use for_each_available_child_of_node_scoped()
  2024-04-10 13:01 [PATCH] spi: cadence-xspi: use for_each_available_child_of_node_scoped() Kousik Sanagavarapu
@ 2024-04-10 19:37 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-04-10 19:37 UTC (permalink / raw)
  To: linux-spi, linux-kernel, Kousik Sanagavarapu
  Cc: Shuah Khan, Javier Carrasco, Julia Lawall

On Wed, 10 Apr 2024 18:31:16 +0530, Kousik Sanagavarapu wrote:
> Refactor code for "is the node's child available?" check by using the
> corresponding macro instead, which reads more clearly.
> 
> While at it, use scope-based cleanup instead of manual of_node_put()
> calls when getting platform data through cdns_xspi_of_get_plat_data().
> 
> This removes the unnecessary "node_child" declaration out of the loop's
> scope and auto cleans up "node_child" when it goes out of scope, even
> when we return early due to error.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: cadence-xspi: use for_each_available_child_of_node_scoped()
      commit: b0f3e56938f8cc8c4d606846270b879650ae7741

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-10 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 13:01 [PATCH] spi: cadence-xspi: use for_each_available_child_of_node_scoped() Kousik Sanagavarapu
2024-04-10 19:37 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).