mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
@ 2014-06-26  8:49 Holger Schurig
  2014-06-26  9:37 ` Alexander Aring
  2014-06-26 20:42 ` Sascha Hauer
  0 siblings, 2 replies; 8+ messages in thread
From: Holger Schurig @ 2014-06-26  8:49 UTC (permalink / raw)
  To: barebox

... and it's defined only when CONFIG_OFTREE_MEM_GENERIC is on.

Signed-off-by: Holger Schurig <holgerschurig@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
 
 static struct device_node *of_chosen;
 static const char *of_model;
@@ -1739,7 +1741,9 @@ const struct of_device_id of_default_bus_match_table[] = {
 
 int of_probe(void)
 {
+#ifdef CONFIG_OFTREE_MEM_GENERIC
 	struct device_node *memory;
+#endif
 
 	if(!root_node)
 		return -ENODEV;
@@ -1750,9 +1754,11 @@ int of_probe(void)
 	if (of_model)
 		barebox_set_model(of_model);
 
+#ifdef CONFIG_OFTREE_MEM_GENERIC
 	memory = of_find_node_by_path("/memory");
 	if (memory)
 		of_add_memory(memory, false);
+#endif
 
 	of_platform_populate(root_node, of_default_bus_match_table, NULL);
 	of_clk_init(root_node, NULL);
-- 
1.7.10.4


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26  8:49 [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined Holger Schurig
@ 2014-06-26  9:37 ` Alexander Aring
  2014-06-26  9:39   ` Alexander Aring
                     ` (2 more replies)
  2014-06-26 20:42 ` Sascha Hauer
  1 sibling, 3 replies; 8+ messages in thread
From: Alexander Aring @ 2014-06-26  9:37 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26  9:37 ` Alexander Aring
@ 2014-06-26  9:39   ` Alexander Aring
  2014-06-26  9:43   ` Holger Schurig
  2014-06-26  9:43   ` Alexander Aring
  2 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2014-06-26  9:39 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26  9:37 ` Alexander Aring
  2014-06-26  9:39   ` Alexander Aring
@ 2014-06-26  9:43   ` Holger Schurig
  2014-06-26  9:48     ` Alexander Aring
  2014-06-26  9:43   ` Alexander Aring
  2 siblings, 1 reply; 8+ messages in thread
From: Holger Schurig @ 2014-06-26  9:43 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26  9:37 ` Alexander Aring
  2014-06-26  9:39   ` Alexander Aring
  2014-06-26  9:43   ` Holger Schurig
@ 2014-06-26  9:43   ` Alexander Aring
  2 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2014-06-26  9:43 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26  9:43   ` Holger Schurig
@ 2014-06-26  9:48     ` Alexander Aring
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2014-06-26  9:48 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26  8:49 [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined Holger Schurig
  2014-06-26  9:37 ` Alexander Aring
@ 2014-06-26 20:42 ` Sascha Hauer
  2014-06-27  7:28   ` Alexander Aring
  1 sibling, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2014-06-26 20:42 UTC (permalink / raw)
  To: Holger Schurig; +Cc: barebox

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 <holgerschurig@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-5555 |

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined
  2014-06-26 20:42 ` Sascha Hauer
@ 2014-06-27  7:28   ` Alexander Aring
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Aring @ 2014-06-27  7:28 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

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 <holgerschurig@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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-06-27  7:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-26  8:49 [PATCH 2/4] sandbox: only access of_add_memory_bank if it's defined Holger Schurig
2014-06-26  9:37 ` Alexander Aring
2014-06-26  9:39   ` Alexander Aring
2014-06-26  9:43   ` Holger Schurig
2014-06-26  9:48     ` Alexander Aring
2014-06-26  9:43   ` Alexander Aring
2014-06-26 20:42 ` Sascha Hauer
2014-06-27  7:28   ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox