linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-s3c64xx.c: Remove of_node_put for auto cleanup
@ 2024-04-18  0:05 Shivani Gupta
  2024-04-24 13:58 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Shivani Gupta @ 2024-04-18  0:05 UTC (permalink / raw)
  To: andi.shyti, broonie, krzysztof.kozlowski, alim.akhtar
  Cc: linux-spi, linux-samsung-soc, linux-arm-kernel, linux-kernel,
	skhan, javier.carrasco.cruz, Shivani Gupta, Julia Lawall

Use the scope based of_node_put() cleanup in s3c64xx_spi_csinfo to
automatically release the device node with the __free() cleanup handler
Initialize data_np at the point of declaration for clarity of scope.

This change reduces the risk of memory leaks and simplifies the code by
removing manual node put call.

Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Shivani Gupta <shivani07g@gmail.com>
---
 drivers/spi/spi-s3c64xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index f726d8670428..833c58c88e40 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -950,7 +950,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_target_ctrldata(
 				struct spi_device *spi)
 {
 	struct s3c64xx_spi_csinfo *cs;
-	struct device_node *target_np, *data_np = NULL;
+	struct device_node *target_np;
 	u32 fb_delay = 0;

 	target_np = spi->dev.of_node;
@@ -963,7 +963,8 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_target_ctrldata(
 	if (!cs)
 		return ERR_PTR(-ENOMEM);

-	data_np = of_get_child_by_name(target_np, "controller-data");
+	struct device_node *data_np __free(device_node) =
+			of_get_child_by_name(target_np, "controller-data");
 	if (!data_np) {
 		dev_info(&spi->dev, "feedback delay set to default (0)\n");
 		return cs;
@@ -971,7 +972,6 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_target_ctrldata(

 	of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
 	cs->fb_delay = fb_delay;
-	of_node_put(data_np);
 	return cs;
 }

--
2.34.1


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

* Re: [PATCH] spi: spi-s3c64xx.c: Remove of_node_put for auto cleanup
  2024-04-18  0:05 [PATCH] spi: spi-s3c64xx.c: Remove of_node_put for auto cleanup Shivani Gupta
@ 2024-04-24 13:58 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-04-24 13:58 UTC (permalink / raw)
  To: andi.shyti, krzysztof.kozlowski, alim.akhtar, Shivani Gupta
  Cc: linux-spi, linux-samsung-soc, linux-arm-kernel, linux-kernel,
	skhan, javier.carrasco.cruz, Julia Lawall

On Thu, 18 Apr 2024 00:05:05 +0000, Shivani Gupta wrote:
> Use the scope based of_node_put() cleanup in s3c64xx_spi_csinfo to
> automatically release the device node with the __free() cleanup handler
> Initialize data_np at the point of declaration for clarity of scope.
> 
> This change reduces the risk of memory leaks and simplifies the code by
> removing manual node put call.
> 
> [...]

Applied to

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

Thanks!

[1/1] spi: spi-s3c64xx.c: Remove of_node_put for auto cleanup
      commit: abba116f601800a0c74b9a9c2c91e2eebca791c1

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-24 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18  0:05 [PATCH] spi: spi-s3c64xx.c: Remove of_node_put for auto cleanup Shivani Gupta
2024-04-24 13:58 ` 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).