Patchwork [U-Boot,RFC,2/4,v1] fdt_decode: make more available.

login
register
mail settings
Submitter u-boot@lakedaemon.net
Date Sept. 15, 2011, 1:54 p.m.
Message ID <fef1470e6caf1c87aa1c383d726a7c9379d041e5.1316092940.git.u-boot@lakedaemon.net>
Download mbox | patch
Permalink /patch/114789/
State RFC
Headers show

Comments

u-boot@lakedaemon.net - Sept. 15, 2011, 1:54 p.m.
Signed-off-by: Jason Cooper <u-boot@lakedaemon.net>
---
 common/fdt_decode.c  |   11 +++++------
 include/fdt_decode.h |   13 +++++++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)
Simon Glass - Sept. 15, 2011, 7:18 p.m.
Hi Jason,

On Thu, Sep 15, 2011 at 6:54 AM, Jason Cooper <u-boot@lakedaemon.net> wrote:
>
> Signed-off-by: Jason Cooper <u-boot@lakedaemon.net>
> ---
>  common/fdt_decode.c  |   11 +++++------
>  include/fdt_decode.h |   13 +++++++++++++
>  2 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/common/fdt_decode.c b/common/fdt_decode.c
> index cd7a071..0f13089 100644
> --- a/common/fdt_decode.c
> +++ b/common/fdt_decode.c
> @@ -33,7 +33,7 @@
>  * turn this into a sparse list later, and keeps the ID with the name.
>  */
>  #define COMPAT(id, name) name
> -static const char *compat_names[COMPAT_COUNT] = {
> +const char *compat_names[COMPAT_COUNT] = {
>  };
>
>  /**
> @@ -43,7 +43,7 @@ static const char *compat_names[COMPAT_COUNT] = {
>  * @param name alias name to look up
>  * @return node offset if found, or an error code < 0 otherwise
>  */
> -static int find_alias_node(const void *blob, const char *name)
> +int find_alias_node(const void *blob, const char *name)

If we are going to export these (which I agree we must if we are to
move this code into drivers), then it should have the fdt_decode_
prefix.

Perhaps this is too verbose? I would be happy with
fdtdec_find_alias_node() if that sounds better?

>  {
>        const char *path;
>        int alias_node;
> @@ -68,7 +68,7 @@ static int find_alias_node(const void *blob, const char *name)
>  * @param prop_name    name of property to find
>  * @return address, if found, or ADDR_T_NONE if not
>  */
> -static addr_t get_addr(const void *blob, int node, const char *prop_name)
> +addr_t get_addr(const void *blob, int node, const char *prop_name)
>  {
>        const addr_t *cell;
>        int len;
> @@ -91,7 +91,7 @@ static addr_t get_addr(const void *blob, int node, const char *prop_name)
>  * @param default_val  default value to return if the property is not found
>  * @return integer value, if found, or default_val if not
>  */
> -static s32 get_int(const void *blob, int node, const char *prop_name,
> +s32 get_int(const void *blob, int node, const char *prop_name,
>                s32 default_val)
>  {
>        const s32 *cell;
> @@ -115,7 +115,7 @@ static s32 get_int(const void *blob, int node, const char *prop_name,
>  * @param default_val  default value to return if no 'status' property exists
>  * @return integer value 0/1, if found, or default_val if not
>  */
> -static int get_is_enabled(const void *blob, int node, int default_val)
> +int get_is_enabled(const void *blob, int node, int default_val)
>  {
>        const char *cell;
>
> @@ -160,4 +160,3 @@ int fdt_decode_next_alias(const void *blob, const char *name,
>                return err;
>        return err ? -FDT_ERR_MISSING : node;
>  }
> -
> diff --git a/include/fdt_decode.h b/include/fdt_decode.h
> index ba3c15b..4264e3b 100644
> --- a/include/fdt_decode.h
> +++ b/include/fdt_decode.h
> @@ -19,6 +19,8 @@
>  * MA 02111-1307 USA
>  */
>
> +#ifndef _FDT_DECODE_H_
> +#define _FDT_DECODE_H_
>
>  /*
>  * This file contains convenience functions for decoding useful and
> @@ -55,4 +57,15 @@ enum fdt_compat_id {
>        COMPAT_COUNT,
>  };
>
> +int find_alias_node(const void *blob, const char *name);
> +addr_t get_addr(const void *blob, int node, const char *prop_name);
> +s32 get_int(const void *blob, int node, const char *prop_name,
> +       s32 default_val);
> +int get_is_enabled(const void *blob, int node, int default_val);
> +enum fdt_compat_id fdt_decode_lookup(const void *blob, int node);
> +int fdt_decode_next_compatible(const void *blob, int node,
> +               enum fdt_compat_id id);
> +int fdt_decode_next_alias(const void *blob, const char *name,
> +               enum fdt_compat_id id, int *upto);
>
> +#endif
> --
> 1.7.0.4
>
>
u-boot@lakedaemon.net - Sept. 15, 2011, 7:48 p.m.
On Thu, Sep 15, 2011 at 12:18:00PM -0700, Simon Glass wrote:
> On Thu, Sep 15, 2011 at 6:54 AM, Jason Cooper <u-boot@lakedaemon.net> wrote:
> >
> > Signed-off-by: Jason Cooper <u-boot@lakedaemon.net>
> > ---
> >  common/fdt_decode.c  |   11 +++++------
> >  include/fdt_decode.h |   13 +++++++++++++
> >  2 files changed, 18 insertions(+), 6 deletions(-)
> >
> > diff --git a/common/fdt_decode.c b/common/fdt_decode.c
> > index cd7a071..0f13089 100644
> > --- a/common/fdt_decode.c
> > +++ b/common/fdt_decode.c
> > @@ -33,7 +33,7 @@
> >  * turn this into a sparse list later, and keeps the ID with the name.
> >  */
> >  #define COMPAT(id, name) name
> > -static const char *compat_names[COMPAT_COUNT] = {
> > +const char *compat_names[COMPAT_COUNT] = {
> >  };
> >
> >  /**
> > @@ -43,7 +43,7 @@ static const char *compat_names[COMPAT_COUNT] = {
> >  * @param name alias name to look up
> >  * @return node offset if found, or an error code < 0 otherwise
> >  */
> > -static int find_alias_node(const void *blob, const char *name)
> > +int find_alias_node(const void *blob, const char *name)
> 
> If we are going to export these (which I agree we must if we are to
> move this code into drivers), then it should have the fdt_decode_
> prefix.
> 
> Perhaps this is too verbose? I would be happy with
> fdtdec_find_alias_node() if that sounds better?

I like this.

> >  {
> >        const char *path;
> >        int alias_node;
> > @@ -68,7 +68,7 @@ static int find_alias_node(const void *blob, const char *name)
> >  * @param prop_name    name of property to find
> >  * @return address, if found, or ADDR_T_NONE if not
> >  */
> > -static addr_t get_addr(const void *blob, int node, const char *prop_name)
> > +addr_t get_addr(const void *blob, int node, const char *prop_name)
> >  {
> >        const addr_t *cell;
> >        int len;
> > @@ -91,7 +91,7 @@ static addr_t get_addr(const void *blob, int node, const char *prop_name)
> >  * @param default_val  default value to return if the property is not found
> >  * @return integer value, if found, or default_val if not
> >  */
> > -static s32 get_int(const void *blob, int node, const char *prop_name,
> > +s32 get_int(const void *blob, int node, const char *prop_name,
> >                s32 default_val)
> >  {
> >        const s32 *cell;
> > @@ -115,7 +115,7 @@ static s32 get_int(const void *blob, int node, const char *prop_name,
> >  * @param default_val  default value to return if no 'status' property exists
> >  * @return integer value 0/1, if found, or default_val if not
> >  */
> > -static int get_is_enabled(const void *blob, int node, int default_val)
> > +int get_is_enabled(const void *blob, int node, int default_val)
> >  {
> >        const char *cell;
> >
> > @@ -160,4 +160,3 @@ int fdt_decode_next_alias(const void *blob, const char *name,
> >                return err;
> >        return err ? -FDT_ERR_MISSING : node;
> >  }
> > -
> > diff --git a/include/fdt_decode.h b/include/fdt_decode.h
> > index ba3c15b..4264e3b 100644
> > --- a/include/fdt_decode.h
> > +++ b/include/fdt_decode.h
> > @@ -19,6 +19,8 @@
> >  * MA 02111-1307 USA
> >  */
> >
> > +#ifndef _FDT_DECODE_H_
> > +#define _FDT_DECODE_H_
> >
> >  /*
> >  * This file contains convenience functions for decoding useful and
> > @@ -55,4 +57,15 @@ enum fdt_compat_id {
> >        COMPAT_COUNT,
> >  };
> >
> > +int find_alias_node(const void *blob, const char *name);
> > +addr_t get_addr(const void *blob, int node, const char *prop_name);
> > +s32 get_int(const void *blob, int node, const char *prop_name,
> > +       s32 default_val);
> > +int get_is_enabled(const void *blob, int node, int default_val);
> > +enum fdt_compat_id fdt_decode_lookup(const void *blob, int node);
> > +int fdt_decode_next_compatible(const void *blob, int node,
> > +               enum fdt_compat_id id);
> > +int fdt_decode_next_alias(const void *blob, const char *name,
> > +               enum fdt_compat_id id, int *upto);
> >
> > +#endif
> > --
> > 1.7.0.4
> >
> >

Patch

diff --git a/common/fdt_decode.c b/common/fdt_decode.c
index cd7a071..0f13089 100644
--- a/common/fdt_decode.c
+++ b/common/fdt_decode.c
@@ -33,7 +33,7 @@ 
  * turn this into a sparse list later, and keeps the ID with the name.
  */
 #define COMPAT(id, name) name
-static const char *compat_names[COMPAT_COUNT] = {
+const char *compat_names[COMPAT_COUNT] = {
 };
 
 /**
@@ -43,7 +43,7 @@  static const char *compat_names[COMPAT_COUNT] = {
  * @param name	alias name to look up
  * @return node offset if found, or an error code < 0 otherwise
  */
-static int find_alias_node(const void *blob, const char *name)
+int find_alias_node(const void *blob, const char *name)
 {
 	const char *path;
 	int alias_node;
@@ -68,7 +68,7 @@  static int find_alias_node(const void *blob, const char *name)
  * @param prop_name	name of property to find
  * @return address, if found, or ADDR_T_NONE if not
  */
-static addr_t get_addr(const void *blob, int node, const char *prop_name)
+addr_t get_addr(const void *blob, int node, const char *prop_name)
 {
 	const addr_t *cell;
 	int len;
@@ -91,7 +91,7 @@  static addr_t get_addr(const void *blob, int node, const char *prop_name)
  * @param default_val	default value to return if the property is not found
  * @return integer value, if found, or default_val if not
  */
-static s32 get_int(const void *blob, int node, const char *prop_name,
+s32 get_int(const void *blob, int node, const char *prop_name,
 		s32 default_val)
 {
 	const s32 *cell;
@@ -115,7 +115,7 @@  static s32 get_int(const void *blob, int node, const char *prop_name,
  * @param default_val	default value to return if no 'status' property exists
  * @return integer value 0/1, if found, or default_val if not
  */
-static int get_is_enabled(const void *blob, int node, int default_val)
+int get_is_enabled(const void *blob, int node, int default_val)
 {
 	const char *cell;
 
@@ -160,4 +160,3 @@  int fdt_decode_next_alias(const void *blob, const char *name,
 		return err;
 	return err ? -FDT_ERR_MISSING : node;
 }
-
diff --git a/include/fdt_decode.h b/include/fdt_decode.h
index ba3c15b..4264e3b 100644
--- a/include/fdt_decode.h
+++ b/include/fdt_decode.h
@@ -19,6 +19,8 @@ 
  * MA 02111-1307 USA
  */
 
+#ifndef _FDT_DECODE_H_
+#define _FDT_DECODE_H_
 
 /*
  * This file contains convenience functions for decoding useful and
@@ -55,4 +57,15 @@  enum fdt_compat_id {
 	COMPAT_COUNT,
 };
 
+int find_alias_node(const void *blob, const char *name);
+addr_t get_addr(const void *blob, int node, const char *prop_name);
+s32 get_int(const void *blob, int node, const char *prop_name,
+	s32 default_val);
+int get_is_enabled(const void *blob, int node, int default_val);
+enum fdt_compat_id fdt_decode_lookup(const void *blob, int node);
+int fdt_decode_next_compatible(const void *blob, int node,
+		enum fdt_compat_id id);
+int fdt_decode_next_alias(const void *blob, const char *name,
+		enum fdt_compat_id id, int *upto);
 
+#endif