[PATCH 1/3] of: device: Do some clean up with use of __free()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



__free() provides a scoped of_node_put() functionality to put the
device_node automatically, and we don't need to call of_node_put()
directly. Let's simplify the code a bit with the use of __free().

Signed-off-by: Zhang Zekun <zhangzekun11@xxxxxxxxxx>
---
 drivers/of/device.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index edf3be197265..7a71ef2aa16e 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -35,7 +35,7 @@ EXPORT_SYMBOL(of_match_device);
 static void
 of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
 {
-	struct device_node *node, *of_node = dev->of_node;
+	struct device_node *of_node = dev->of_node;
 	int count, i;
 
 	if (!IS_ENABLED(CONFIG_DMA_RESTRICTED_POOL))
@@ -54,17 +54,16 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
 	}
 
 	for (i = 0; i < count; i++) {
-		node = of_parse_phandle(of_node, "memory-region", i);
+		struct device_node *node __free(device_node) =
+			of_parse_phandle(of_node, "memory-region", i);
 		/*
 		 * There might be multiple memory regions, but only one
 		 * restricted-dma-pool region is allowed.
 		 */
 		if (of_device_is_compatible(node, "restricted-dma-pool") &&
 		    of_device_is_available(node)) {
-			of_node_put(node);
 			break;
 		}
-		of_node_put(node);
 	}
 
 	/*
-- 
2.17.1





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux