diff mbox

[RFC,v3,11/24] ARM: fdt: Export and introduce new fdt functions

Message ID 1500378106-2620-12-git-send-email-vijay.kilari@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Vijay Kilari July 18, 2017, 11:41 a.m. UTC
From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>

Introduce new api device_tree_type_matches() to check for
device type. Also export device_tree_get_u32() and
device_tree_node_compatible()

These functions are later used for parsing NUMA information.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
---
v3: Export device_tree_node_compatible() instead of
    device_tree_node_matches()
---
 xen/arch/arm/bootfdt.c      | 20 ++++++++++++++++----
 xen/include/asm-arm/setup.h |  5 +++++
 2 files changed, 21 insertions(+), 4 deletions(-)

Comments

Wei Liu July 18, 2017, 3:29 p.m. UTC | #1
On Tue, Jul 18, 2017 at 05:11:33PM +0530, vijay.kilari@gmail.com wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
> 
> Introduce new api device_tree_type_matches() to check for
> device type. Also export device_tree_get_u32() and
> device_tree_node_compatible()
> 
> These functions are later used for parsing NUMA information.
> 
> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
> ---
> v3: Export device_tree_node_compatible() instead of
>     device_tree_node_matches()
> ---
>  xen/arch/arm/bootfdt.c      | 20 ++++++++++++++++----
>  xen/include/asm-arm/setup.h |  5 +++++
>  2 files changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> index ea188a0..6e8251b 100644
> --- a/xen/arch/arm/bootfdt.c
> +++ b/xen/arch/arm/bootfdt.c
> @@ -31,8 +31,8 @@ static bool_t __init device_tree_node_matches(const void *fdt, int node,
>          && (name[match_len] == '@' || name[match_len] == '\0');
>  }
>  
> -static bool_t __init device_tree_node_compatible(const void *fdt, int node,
> -                                                 const char *match)
> +bool_t __init device_tree_node_compatible(const void *fdt, int node,
> +                                          const char *match)

While you're changing the code please change bool_t to bool
Julien Grall July 18, 2017, 4:29 p.m. UTC | #2
On 18/07/17 16:29, Wei Liu wrote:
> On Tue, Jul 18, 2017 at 05:11:33PM +0530, vijay.kilari@gmail.com wrote:
>> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>>
>> Introduce new api device_tree_type_matches() to check for
>> device type. Also export device_tree_get_u32() and
>> device_tree_node_compatible()
>>
>> These functions are later used for parsing NUMA information.
>>
>> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>> ---
>> v3: Export device_tree_node_compatible() instead of
>>     device_tree_node_matches()
>> ---
>>  xen/arch/arm/bootfdt.c      | 20 ++++++++++++++++----
>>  xen/include/asm-arm/setup.h |  5 +++++
>>  2 files changed, 21 insertions(+), 4 deletions(-)
>>
>> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
>> index ea188a0..6e8251b 100644
>> --- a/xen/arch/arm/bootfdt.c
>> +++ b/xen/arch/arm/bootfdt.c
>> @@ -31,8 +31,8 @@ static bool_t __init device_tree_node_matches(const void *fdt, int node,
>>          && (name[match_len] == '@' || name[match_len] == '\0');
>>  }
>>
>> -static bool_t __init device_tree_node_compatible(const void *fdt, int node,
>> -                                                 const char *match)
>> +bool_t __init device_tree_node_compatible(const void *fdt, int node,
>> +                                          const char *match)
>
> While you're changing the code please change bool_t to bool

+1.

Also, it is not necessary to CC all the people on every patches. Can you 
please use scripts/get_maintainers.pl to only CC relevant maintainers + 
people wanted to follow the series on each patch and not everyone 
everywhere...

>
diff mbox

Patch

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index ea188a0..6e8251b 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -31,8 +31,8 @@  static bool_t __init device_tree_node_matches(const void *fdt, int node,
         && (name[match_len] == '@' || name[match_len] == '\0');
 }
 
-static bool_t __init device_tree_node_compatible(const void *fdt, int node,
-                                                 const char *match)
+bool_t __init device_tree_node_compatible(const void *fdt, int node,
+                                          const char *match)
 {
     int len, l;
     int mlen;
@@ -62,8 +62,20 @@  static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells,
     *size = dt_next_cell(size_cells, cell);
 }
 
-static u32 __init device_tree_get_u32(const void *fdt, int node,
-                                      const char *prop_name, u32 dflt)
+bool_t __init device_tree_type_matches(const void *fdt, int node,
+                                       const char *match)
+{
+    const void *prop;
+
+    prop = fdt_getprop(fdt, node, "device_type", NULL);
+    if ( prop == NULL )
+        return 0;
+
+    return strcmp(prop, match) == 0 ? 1 : 0;
+}
+
+u32 __init device_tree_get_u32(const void *fdt, int node,
+                               const char *prop_name, u32 dflt)
 {
     const struct fdt_property *prop;
 
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 7ff2c34..fb78478 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -83,6 +83,11 @@  struct bootmodule *add_boot_module(bootmodule_kind kind,
 struct bootmodule *boot_module_find_by_kind(bootmodule_kind kind);
 const char * __init boot_module_kind_as_string(bootmodule_kind kind);
 
+u32 device_tree_get_u32(const void *fdt, int node, const char *prop_name,
+                        u32 dflt);
+bool_t device_tree_type_matches(const void *fdt, int node, const char *match);
+bool_t device_tree_node_compatible(const void *fdt, int node,
+                                   const char *match);
 #endif
 /*
  * Local variables: