Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-27 Thread Alexander Aring
On Thu, Jun 26, 2014 at 10:42:32PM +0200, Sascha Hauer wrote:
 On Thu, Jun 26, 2014 at 10:49:15AM +0200, Holger Schurig wrote:
  ... and it's defined only when CONFIG_OFTREE_MEM_GENERIC is on.
  
  Signed-off-by: Holger Schurig holgerschu...@gmail.com
  ---
   drivers/of/base.c |6 ++
   1 file changed, 6 insertions(+)
  
  diff --git a/drivers/of/base.c b/drivers/of/base.c
  index c440a69..818d76e 100644
  --- a/drivers/of/base.c
  +++ b/drivers/of/base.c
  @@ -1697,6 +1697,7 @@ int of_set_property(struct device_node *np, const 
  char *name, const void *val, i
  return 0;
   }
   
  +#ifdef CONFIG_OFTREE_MEM_GENERIC
   int of_add_memory(struct device_node *node, bool dump)
   {
  const char *device_type;
  @@ -1720,6 +1721,7 @@ int of_add_memory(struct device_node *node, bool dump)
   
  return 0;
   }
  +#endif
 
 This will break MIPS support. MIPS has it's own implementation of
 of_add_memory_bank (see ./arch/mips/boot/dtb.c), so in MIPS case
 the Kconfig options means I have my own version of of_add_memory_bank
 

Then maybe, move this implementation to drivers/of/mem_generic.c. This
function doesn't use any static function of this file (What I see,
currently).

Then make a own header with dummy implementation:

#ifdef CONFIG_OFTREE_MEM_GENERIC
int of_add_memory(struct device_node *node, bool dump)
{
...
}
#else 
int of_add_memory(struct device_node *node, bool dump)
{
return -EOPNOTSUPP;
}
#endif

The file drivers/of/mem_generic.c depends on PPC || ARM, so let
the buildsystem do the rest.

- Alex

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-26 Thread Alexander Aring
Hi Holger,

can you please check if this is also a solution for this?

diff --git a/include/of.h b/include/of.h
index e6993fd..76845e7 100644
--- a/include/of.h
+++ b/include/of.h
@@ -227,7 +227,14 @@ int of_parse_partitions(struct cdev *cdev, struct 
device_node *node);
 int of_device_is_stdout_path(struct device_d *dev);
 const char *of_get_model(void);
 void *of_flatten_dtb(struct device_node *node);
+#ifdef CONFIG_OFTREE_MEM_GENERIC
 int of_add_memory(struct device_node *node, bool dump);
+#else
+static inline int of_add_memory(struct device_node *node, bool dump)
+{
+   return -EINVAL;
+}
+#endif
 void of_add_memory_bank(struct device_node *node, bool dump, int r,
u64 base, u64 size);
 struct device_d *of_find_device_by_node_path(const char *path);



If this works for you then this is missing. Maybe there are some other related
function which depends on CONFIG_OFTREE_MEM_GENERIC, I didn't check it.

I think this would be a better solution, if it works...

- Alex

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-26 Thread Alexander Aring
On Thu, Jun 26, 2014 at 11:37:01AM +0200, Alexander Aring wrote:
 Hi Holger,
 
 can you please check if this is also a solution for this?
 
 diff --git a/include/of.h b/include/of.h
 index e6993fd..76845e7 100644
 --- a/include/of.h
 +++ b/include/of.h
 @@ -227,7 +227,14 @@ int of_parse_partitions(struct cdev *cdev, struct 
 device_node *node);
  int of_device_is_stdout_path(struct device_d *dev);
  const char *of_get_model(void);
  void *of_flatten_dtb(struct device_node *node);
 +#ifdef CONFIG_OFTREE_MEM_GENERIC
  int of_add_memory(struct device_node *node, bool dump);
 +#else
 +static inline int of_add_memory(struct device_node *node, bool dump)
 +{
 +   return -EINVAL;

mhh, the errno of these function if it's not defined should be changed
to -EOPNOTSUPP.

- Alex

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-26 Thread Holger Schurig
Your patch alone isn't all that's needed, the definition must still be
uncommented. Otherwise we'll get:

drivers/of/base.c:1700:5: error: redefinition of 'of_add_memory'
include/of.h:233:50: note: previous definition of 'of_add_memory' was here

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-26 Thread Alexander Aring
On Thu, Jun 26, 2014 at 11:37:01AM +0200, Alexander Aring wrote:
 Hi Holger,
 
 can you please check if this is also a solution for this?
 
 diff --git a/include/of.h b/include/of.h
 index e6993fd..76845e7 100644
 --- a/include/of.h
 +++ b/include/of.h
 @@ -227,7 +227,14 @@ int of_parse_partitions(struct cdev *cdev, struct 
 device_node *node);
  int of_device_is_stdout_path(struct device_d *dev);
  const char *of_get_model(void);
  void *of_flatten_dtb(struct device_node *node);
 +#ifdef CONFIG_OFTREE_MEM_GENERIC
  int of_add_memory(struct device_node *node, bool dump);
 +#else
 +static inline int of_add_memory(struct device_node *node, bool dump)
 +{
 +   return -EINVAL;
 +}
 +#endif
  void of_add_memory_bank(struct device_node *node, bool dump, int r,
 u64 base, u64 size);
  struct device_d *of_find_device_by_node_path(const char *path);
 
 
 

Okay the implementation #ifdef CONFIG_OFTREE_MEM_GENERIC for function
of_add_memory, need to be there.

Other option would be to put this function in a separete file which
depends on CONFIG_OFTREE_MEM_GENERIC and do in the header file the above
solution one. Don't know if this is better. Then you could drop the
#ifdef CONFIG_OFTREE_MEM_GENERIC from the implementation.

- Alex

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-26 Thread Alexander Aring
On Thu, Jun 26, 2014 at 11:43:10AM +0200, Holger Schurig wrote:
 Your patch alone isn't all that's needed, the definition must still be
 uncommented. Otherwise we'll get:
 
 drivers/of/base.c:1700:5: error: redefinition of 'of_add_memory'
 include/of.h:233:50: note: previous definition of 'of_add_memory' was here

Yep you are right. Sorry :-)

Another solution would be to move the implementation for mem_generic in
a seperate file which depends on CONFIG_OFTREE_MEM_GENERIC. This would
work, but I don't know if we really need that to solve that, I think not.

- Alex

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined

2014-06-26 Thread Sascha Hauer
On Thu, Jun 26, 2014 at 10:49:15AM +0200, Holger Schurig wrote:
 ... and it's defined only when CONFIG_OFTREE_MEM_GENERIC is on.
 
 Signed-off-by: Holger Schurig holgerschu...@gmail.com
 ---
  drivers/of/base.c |6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/drivers/of/base.c b/drivers/of/base.c
 index c440a69..818d76e 100644
 --- a/drivers/of/base.c
 +++ b/drivers/of/base.c
 @@ -1697,6 +1697,7 @@ int of_set_property(struct device_node *np, const char 
 *name, const void *val, i
   return 0;
  }
  
 +#ifdef CONFIG_OFTREE_MEM_GENERIC
  int of_add_memory(struct device_node *node, bool dump)
  {
   const char *device_type;
 @@ -1720,6 +1721,7 @@ int of_add_memory(struct device_node *node, bool dump)
  
   return 0;
  }
 +#endif

This will break MIPS support. MIPS has it's own implementation of
of_add_memory_bank (see ./arch/mips/boot/dtb.c), so in MIPS case
the Kconfig options means I have my own version of of_add_memory_bank

I currently don't know a good way out of this situation.

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox