diff mbox

[v6,40/42] drivers/of: Return allocated memory chunk from of_fdt_unflatten_tree()

Message ID 1438834307-26960-41-git-send-email-gwshan@linux.vnet.ibm.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Gavin Shan Aug. 6, 2015, 4:11 a.m. UTC
This changes of_fdt_unflatten_tree() so that it returns the allocated
memory chunk for unflattened device-tree, which can be released once
it's obsoleted.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
---
 drivers/of/fdt.c       | 11 ++++++-----
 include/linux/of_fdt.h |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

Comments

Rob Herring Aug. 6, 2015, 2:19 p.m. UTC | #1
On Wed, Aug 5, 2015 at 11:11 PM, Gavin Shan <gwshan@linux.vnet.ibm.com> wrote:
> This changes of_fdt_unflatten_tree() so that it returns the allocated
> memory chunk for unflattened device-tree, which can be released once
> it's obsoleted.
>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>

Acked-by: Rob Herring <robh@kernel.org>

> ---
>  drivers/of/fdt.c       | 11 ++++++-----
>  include/linux/of_fdt.h |  2 +-
>  2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 074870a..8e1ba7e 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -408,7 +408,7 @@ static void *unflatten_dt_node(const void *blob,
>   * @dt_alloc: An allocator that provides a virtual address to memory
>   * for the resulting tree
>   */
> -static void __unflatten_device_tree(const void *blob,
> +static void *__unflatten_device_tree(const void *blob,
>                              struct device_node *dad,
>                              struct device_node **mynodes,
>                              void * (*dt_alloc)(u64 size, u64 align))
> @@ -421,7 +421,7 @@ static void __unflatten_device_tree(const void *blob,
>
>         if (!blob) {
>                 pr_debug("No device tree pointer\n");
> -               return;
> +               return NULL;
>         }
>
>         pr_debug("Unflattening device tree:\n");
> @@ -431,7 +431,7 @@ static void __unflatten_device_tree(const void *blob,
>
>         if (fdt_check_header(blob)) {
>                 pr_err("Invalid device tree blob header\n");
> -               return;
> +               return NULL;
>         }
>
>         /* First pass, scan for size */
> @@ -458,6 +458,7 @@ static void __unflatten_device_tree(const void *blob,
>                            be32_to_cpup(mem + size));
>
>         pr_debug(" <- unflatten_device_tree()\n");
> +       return mem;
>  }
>
>  static void *kernel_tree_alloc(u64 size, u64 align)
> @@ -473,11 +474,11 @@ static void *kernel_tree_alloc(u64 size, u64 align)
>   * pointers of the nodes so the normal device-tree walking functions
>   * can be used.
>   */
> -void of_fdt_unflatten_tree(const unsigned long *blob,
> +void *of_fdt_unflatten_tree(const unsigned long *blob,
>                         struct device_node *dad,
>                         struct device_node **mynodes)
>  {
> -       __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
> +       return __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
>  }
>  EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
>
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index 3644960..00db279 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -37,7 +37,7 @@ extern bool of_fdt_is_big_endian(const void *blob,
>                                  unsigned long node);
>  extern int of_fdt_match(const void *blob, unsigned long node,
>                         const char *const *compat);
> -extern void of_fdt_unflatten_tree(const unsigned long *blob,
> +extern void *of_fdt_unflatten_tree(const unsigned long *blob,
>                                struct device_node *dad,
>                                struct device_node **mynodes);
>
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Frank Rowand Aug. 10, 2015, 10:42 p.m. UTC | #2
On 8/5/2015 9:11 PM, Gavin Shan wrote:
> This changes of_fdt_unflatten_tree() so that it returns the allocated
> memory chunk for unflattened device-tree, which can be released once
> it's obsoleted.
> 
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
>  drivers/of/fdt.c       | 11 ++++++-----
>  include/linux/of_fdt.h |  2 +-
>  2 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 074870a..8e1ba7e 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -408,7 +408,7 @@ static void *unflatten_dt_node(const void *blob,
>   * @dt_alloc: An allocator that provides a virtual address to memory
>   * for the resulting tree
>   */
> -static void __unflatten_device_tree(const void *blob,
> +static void *__unflatten_device_tree(const void *blob,
>  			     struct device_node *dad,
>  			     struct device_node **mynodes,
>  			     void * (*dt_alloc)(u64 size, u64 align))

Please add a description of the return value to the documentation header.


> @@ -421,7 +421,7 @@ static void __unflatten_device_tree(const void *blob,
>  
>  	if (!blob) {
>  		pr_debug("No device tree pointer\n");
> -		return;
> +		return NULL;
>  	}
>  
>  	pr_debug("Unflattening device tree:\n");
> @@ -431,7 +431,7 @@ static void __unflatten_device_tree(const void *blob,
>  
>  	if (fdt_check_header(blob)) {
>  		pr_err("Invalid device tree blob header\n");
> -		return;
> +		return NULL;
>  	}
>  
>  	/* First pass, scan for size */
> @@ -458,6 +458,7 @@ static void __unflatten_device_tree(const void *blob,
>  			   be32_to_cpup(mem + size));
>  
>  	pr_debug(" <- unflatten_device_tree()\n");
> +	return mem;
>  }
>  
>  static void *kernel_tree_alloc(u64 size, u64 align)
> @@ -473,11 +474,11 @@ static void *kernel_tree_alloc(u64 size, u64 align)
>   * pointers of the nodes so the normal device-tree walking functions
>   * can be used.
>   */
> -void of_fdt_unflatten_tree(const unsigned long *blob,
> +void *of_fdt_unflatten_tree(const unsigned long *blob,

Please add a description of the return value to the documentation header.


>  			struct device_node *dad,
>  			struct device_node **mynodes)
>  {
> -	__unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
> +	return __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
>  }
>  EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
>  
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index 3644960..00db279 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -37,7 +37,7 @@ extern bool of_fdt_is_big_endian(const void *blob,
>  				 unsigned long node);
>  extern int of_fdt_match(const void *blob, unsigned long node,
>  			const char *const *compat);
> -extern void of_fdt_unflatten_tree(const unsigned long *blob,
> +extern void *of_fdt_unflatten_tree(const unsigned long *blob,
>  			       struct device_node *dad,
>  			       struct device_node **mynodes);
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gavin Shan Aug. 11, 2015, 12:52 a.m. UTC | #3
On Mon, Aug 10, 2015 at 03:42:32PM -0700, Frank Rowand wrote:
>On 8/5/2015 9:11 PM, Gavin Shan wrote:

Frank, thanks for your comments. All of them will be included
in next revision.

Thanks,
Gavin

>> This changes of_fdt_unflatten_tree() so that it returns the allocated
>> memory chunk for unflattened device-tree, which can be released once
>> it's obsoleted.
>> 
>> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>> ---
>>  drivers/of/fdt.c       | 11 ++++++-----
>>  include/linux/of_fdt.h |  2 +-
>>  2 files changed, 7 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 074870a..8e1ba7e 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -408,7 +408,7 @@ static void *unflatten_dt_node(const void *blob,
>>   * @dt_alloc: An allocator that provides a virtual address to memory
>>   * for the resulting tree
>>   */
>> -static void __unflatten_device_tree(const void *blob,
>> +static void *__unflatten_device_tree(const void *blob,
>>  			     struct device_node *dad,
>>  			     struct device_node **mynodes,
>>  			     void * (*dt_alloc)(u64 size, u64 align))
>
>Please add a description of the return value to the documentation header.
>
>
>> @@ -421,7 +421,7 @@ static void __unflatten_device_tree(const void *blob,
>>  
>>  	if (!blob) {
>>  		pr_debug("No device tree pointer\n");
>> -		return;
>> +		return NULL;
>>  	}
>>  
>>  	pr_debug("Unflattening device tree:\n");
>> @@ -431,7 +431,7 @@ static void __unflatten_device_tree(const void *blob,
>>  
>>  	if (fdt_check_header(blob)) {
>>  		pr_err("Invalid device tree blob header\n");
>> -		return;
>> +		return NULL;
>>  	}
>>  
>>  	/* First pass, scan for size */
>> @@ -458,6 +458,7 @@ static void __unflatten_device_tree(const void *blob,
>>  			   be32_to_cpup(mem + size));
>>  
>>  	pr_debug(" <- unflatten_device_tree()\n");
>> +	return mem;
>>  }
>>  
>>  static void *kernel_tree_alloc(u64 size, u64 align)
>> @@ -473,11 +474,11 @@ static void *kernel_tree_alloc(u64 size, u64 align)
>>   * pointers of the nodes so the normal device-tree walking functions
>>   * can be used.
>>   */
>> -void of_fdt_unflatten_tree(const unsigned long *blob,
>> +void *of_fdt_unflatten_tree(const unsigned long *blob,
>
>Please add a description of the return value to the documentation header.
>
>
>>  			struct device_node *dad,
>>  			struct device_node **mynodes)
>>  {
>> -	__unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
>> +	return __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
>>  }
>>  EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
>>  
>> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
>> index 3644960..00db279 100644
>> --- a/include/linux/of_fdt.h
>> +++ b/include/linux/of_fdt.h
>> @@ -37,7 +37,7 @@ extern bool of_fdt_is_big_endian(const void *blob,
>>  				 unsigned long node);
>>  extern int of_fdt_match(const void *blob, unsigned long node,
>>  			const char *const *compat);
>> -extern void of_fdt_unflatten_tree(const unsigned long *blob,
>> +extern void *of_fdt_unflatten_tree(const unsigned long *blob,
>>  			       struct device_node *dad,
>>  			       struct device_node **mynodes);
>>  
>> 
>

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 074870a..8e1ba7e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -408,7 +408,7 @@  static void *unflatten_dt_node(const void *blob,
  * @dt_alloc: An allocator that provides a virtual address to memory
  * for the resulting tree
  */
-static void __unflatten_device_tree(const void *blob,
+static void *__unflatten_device_tree(const void *blob,
 			     struct device_node *dad,
 			     struct device_node **mynodes,
 			     void * (*dt_alloc)(u64 size, u64 align))
@@ -421,7 +421,7 @@  static void __unflatten_device_tree(const void *blob,
 
 	if (!blob) {
 		pr_debug("No device tree pointer\n");
-		return;
+		return NULL;
 	}
 
 	pr_debug("Unflattening device tree:\n");
@@ -431,7 +431,7 @@  static void __unflatten_device_tree(const void *blob,
 
 	if (fdt_check_header(blob)) {
 		pr_err("Invalid device tree blob header\n");
-		return;
+		return NULL;
 	}
 
 	/* First pass, scan for size */
@@ -458,6 +458,7 @@  static void __unflatten_device_tree(const void *blob,
 			   be32_to_cpup(mem + size));
 
 	pr_debug(" <- unflatten_device_tree()\n");
+	return mem;
 }
 
 static void *kernel_tree_alloc(u64 size, u64 align)
@@ -473,11 +474,11 @@  static void *kernel_tree_alloc(u64 size, u64 align)
  * pointers of the nodes so the normal device-tree walking functions
  * can be used.
  */
-void of_fdt_unflatten_tree(const unsigned long *blob,
+void *of_fdt_unflatten_tree(const unsigned long *blob,
 			struct device_node *dad,
 			struct device_node **mynodes)
 {
-	__unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
+	return __unflatten_device_tree(blob, dad, mynodes, &kernel_tree_alloc);
 }
 EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);
 
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 3644960..00db279 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -37,7 +37,7 @@  extern bool of_fdt_is_big_endian(const void *blob,
 				 unsigned long node);
 extern int of_fdt_match(const void *blob, unsigned long node,
 			const char *const *compat);
-extern void of_fdt_unflatten_tree(const unsigned long *blob,
+extern void *of_fdt_unflatten_tree(const unsigned long *blob,
 			       struct device_node *dad,
 			       struct device_node **mynodes);