2010-02-13 16:02:36

by Grant Likely

[permalink] [raw]
Subject: [PATCH 0/9] Random OF cleanups and merges

Here's another batch of cleanup patches from my test-devicetree branch.
A number of cleanups, corrections and minor merges of common code.
Also a patch from Jeremy to make the flat tree work on architectures
without LMB (arm).

Once I've collected acks on these, I'll move them over to my
next-devicetree branch on git://git.secretlab.ca/git/linux-2.6

Cheers,
g.

---

Grant Likely (6):
of: remove undefined request_OF_resource & release_OF_resource
of/sparc: Remove sparc-local declaration of allnodes and devtree_lock
of: move definition of of_chosen into common code.
of: remove unused extern reference to devtree_lock
of: put default string compare and #a/s-cell values into common header
of: Remove old and misplaced function declarations

Jeremy Kerr (3):
of/flattree: Don't assume HAVE_LMB
of: protect linux/of.h with CONFIG_OF
proc_devtree: fix THIS_MODULE without module.h


arch/microblaze/include/asm/prom.h | 15 ---------------
arch/microblaze/kernel/prom.c | 8 +++++---
arch/powerpc/include/asm/prom.h | 14 --------------
arch/powerpc/kernel/prom.c | 10 +++++-----
arch/sparc/kernel/prom.h | 3 ---
drivers/of/base.c | 1 +
drivers/of/fdt.c | 9 ++++++---
fs/proc/proc_devtree.c | 1 +
include/linux/of.h | 27 +++++++++++++++++++++++++++
include/linux/of_fdt.h | 11 +----------
10 files changed, 46 insertions(+), 53 deletions(-)


2010-02-13 16:02:38

by Grant Likely

[permalink] [raw]
Subject: [PATCH 1/9] of: Remove old and misplaced function declarations

The following functions don't exist:
finish_device_tree()
print_properties()
prom_n_intr_cells()
prom_get_irq_senses()

The following functions are in drivers/of/base.c, so the declaration
belongs in of.h instead of of_fdt.h
of_machine_is_compatible()
prom_add_property()
prom_remove_property()
prom_update_property()

Signed-off-by: Grant Likely <[email protected]>
---

include/linux/of.h | 8 ++++++++
include/linux/of_fdt.h | 10 ----------
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/include/linux/of.h b/include/linux/of.h
index fa5571b..5c7b6a6 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -180,6 +180,14 @@ extern int of_parse_phandles_with_args(struct device_node *np,
const char *list_name, const char *cells_name, int index,
struct device_node **out_node, const void **out_args);

+extern int of_machine_is_compatible(const char *compat);
+
+extern int prom_add_property(struct device_node* np, struct property* prop);
+extern int prom_remove_property(struct device_node *np, struct property *prop);
+extern int prom_update_property(struct device_node *np,
+ struct property *newprop,
+ struct property *oldprop);
+
#if defined(CONFIG_OF_DYNAMIC)
/* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *);
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 0007187..c9cb8a7 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -95,18 +95,8 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,
int depth, void *data);

/* Other Prototypes */
-extern void finish_device_tree(void);
extern void unflatten_device_tree(void);
extern void early_init_devtree(void *);
-extern int of_machine_is_compatible(const char *compat);
-extern void print_properties(struct device_node *node);
-extern int prom_n_intr_cells(struct device_node* np);
-extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
-extern int prom_add_property(struct device_node* np, struct property* prop);
-extern int prom_remove_property(struct device_node *np, struct property *prop);
-extern int prom_update_property(struct device_node *np,
- struct property *newprop,
- struct property *oldprop);

#endif /* __ASSEMBLY__ */
#endif /* _LINUX_OF_FDT_H */

2010-02-13 16:02:54

by Grant Likely

[permalink] [raw]
Subject: [PATCH 2/9] proc_devtree: fix THIS_MODULE without module.h

From: Jeremy Kerr <[email protected]>

Commit e22f628395432b967f2f505858c64450f7835365 introduced a build
breakage for ARM devtree work: the THIS_MODULE macro was added, but we
don't have module.h

This change adds the necessary #include to get THIS_MODULE defined.
While we could just replace it with NULL (PROC_FS is a bool, not a
tristate), using THIS_MODULE will prevent unexpected breakage if we
ever do compile this as a module.

Signed-off-by: Jeremy Kerr <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
---

fs/proc/proc_devtree.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index 0ec4511..f8650dc 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -11,6 +11,7 @@
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/of.h>
+#include <linux/module.h>
#include <asm/prom.h>
#include <asm/uaccess.h>
#include "internal.h"

2010-02-13 16:02:57

by Grant Likely

[permalink] [raw]
Subject: [PATCH 3/9] of: protect linux/of.h with CONFIG_OF

From: Jeremy Kerr <[email protected]>

For platforms that have CONFIG_OF optional, we need to make the contents
of linux/of.h conditional on CONFIG_OF.

Signed-off-by: Jeremy Kerr <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
---

include/linux/of.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/linux/of.h b/include/linux/of.h
index 5c7b6a6..48b0ee6 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -22,6 +22,8 @@

#include <asm/byteorder.h>

+#ifdef CONFIG_OF
+
typedef u32 phandle;
typedef u32 ihandle;

@@ -194,4 +196,5 @@ extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *);
#endif

+#endif /* CONFIG_OF */
#endif /* _LINUX_OF_H */

2010-02-13 16:03:17

by Grant Likely

[permalink] [raw]
Subject: [PATCH 8/9] of/sparc: Remove sparc-local declaration of allnodes and devtree_lock

Both allnodes and devtree_lock are defined in common code. The
extern declaration should be in the common header too so that the
compiler can type check. allnodes is already in of.h, but
devtree_lock should be declared there too.

This patch removes the SPARC declarations and uses decls in of.h instead.

Signed-off-by: Grant Likely <[email protected]>
---

arch/sparc/kernel/prom.h | 3 ---
include/linux/of.h | 2 ++
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
index 453397f..a8591ef 100644
--- a/arch/sparc/kernel/prom.h
+++ b/arch/sparc/kernel/prom.h
@@ -4,9 +4,6 @@
#include <linux/spinlock.h>
#include <asm/prom.h>

-extern struct device_node *allnodes; /* temporary while merging */
-extern rwlock_t devtree_lock; /* temporary while merging */
-
extern void * prom_early_alloc(unsigned long size);
extern void irq_trans_init(struct device_node *dp);

diff --git a/include/linux/of.h b/include/linux/of.h
index d34cc5d..f6d9cbc 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -19,6 +19,7 @@
#include <linux/bitops.h>
#include <linux/kref.h>
#include <linux/mod_devicetable.h>
+#include <linux/spinlock.h>

#include <asm/byteorder.h>

@@ -67,6 +68,7 @@ struct device_node {
/* Pointer for first entry in chain of all nodes. */
extern struct device_node *allnodes;
extern struct device_node *of_chosen;
+extern rwlock_t devtree_lock;

static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{

2010-02-13 16:03:14

by Grant Likely

[permalink] [raw]
Subject: [PATCH 7/9] of: move definition of of_chosen into common code.

Rather than defining of_chosen in each arch, it can be defined for all
in driver/of/base.c

Signed-off-by: Grant Likely <[email protected]>
---

arch/microblaze/include/asm/prom.h | 2 --
arch/microblaze/kernel/prom.c | 3 ---
arch/powerpc/include/asm/prom.h | 2 --
arch/powerpc/kernel/prom.c | 3 ---
drivers/of/base.c | 1 +
include/linux/of.h | 1 +
6 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index 8b1ebd3..aa1a437 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -26,8 +26,6 @@
#include <asm/irq.h>
#include <asm/atomic.h>

-extern struct device_node *of_chosen;
-
#define HAVE_ARCH_DEVTREE_FIXUPS

/* Other Prototypes */
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index a7dcaf0..a15ef6d 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -42,9 +42,6 @@
#include <asm/sections.h>
#include <asm/pci-bridge.h>

-/* export that to outside world */
-struct device_node *of_chosen;
-
void __init early_init_dt_scan_chosen_arch(unsigned long node)
{
/* No Microblaze specific code here */
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 4a5070e..7f9a50a 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -23,8 +23,6 @@
#include <asm/irq.h>
#include <asm/atomic.h>

-extern struct device_node *of_chosen;
-
#define HAVE_ARCH_DEVTREE_FIXUPS

#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 4869c93..43238b2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -67,9 +67,6 @@ int __initdata iommu_force_on;
unsigned long tce_alloc_start, tce_alloc_end;
#endif

-/* export that to outside world */
-struct device_node *of_chosen;
-
static int __init early_parse_mem(char *p)
{
if (!p)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 873479a..cb96888 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -23,6 +23,7 @@
#include <linux/proc_fs.h>

struct device_node *allnodes;
+struct device_node *of_chosen;

/* use when traversing tree through the allnext, child, sibling,
* or parent members of struct device_node.
diff --git a/include/linux/of.h b/include/linux/of.h
index 5cd2840..d34cc5d 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -66,6 +66,7 @@ struct device_node {

/* Pointer for first entry in chain of all nodes. */
extern struct device_node *allnodes;
+extern struct device_node *of_chosen;

static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{

2010-02-13 16:03:21

by Grant Likely

[permalink] [raw]
Subject: [PATCH 9/9] of: remove undefined request_OF_resource & release_OF_resource

Neither request_OF_resource or release_OF_resource are defined
anywhere. Remove the declarations.

Signed-off-by: Grant Likely <[email protected]>
---

arch/microblaze/include/asm/prom.h | 4 ----
arch/powerpc/include/asm/prom.h | 5 -----
2 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index aa1a437..03f45a9 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -31,10 +31,6 @@
/* Other Prototypes */
extern int early_uartlite_console(void);

-extern struct resource *request_OF_resource(struct device_node *node,
- int index, const char *name_postfix);
-extern int release_OF_resource(struct device_node *node, int index);
-
/*
* OF address retreival & translation
*/
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 7f9a50a..ddd408a 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -39,11 +39,6 @@ extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
extern void pci_create_OF_bus_map(void);
#endif

-extern struct resource *request_OF_resource(struct device_node* node,
- int index, const char* name_postfix);
-extern int release_OF_resource(struct device_node* node, int index);
-
-
/*
* OF address retreival & translation
*/

2010-02-13 16:03:54

by Grant Likely

[permalink] [raw]
Subject: [PATCH 4/9] of/flattree: Don't assume HAVE_LMB

From: Jeremy Kerr <[email protected]>

We don't always have lmb available, so make arches provide an
early_init_dt_alloc_memory_arch() to handle the allocation of
memory in the fdt code.

When we don't have lmb.h included, we need asm/page.h for __va.

Signed-off-by: Jeremy Kerr <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
---

arch/microblaze/kernel/prom.c | 5 +++++
arch/powerpc/kernel/prom.c | 5 +++++
drivers/of/fdt.c | 9 ++++++---
include/linux/of_fdt.h | 1 +
4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 050b799..a7dcaf0 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -55,6 +55,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
lmb_add(base, size);
}

+u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+ return lmb_alloc(size, align);
+}
+
#ifdef CONFIG_EARLY_PRINTK
/* MS this is Microblaze specifig function */
static int __init early_init_dt_scan_serial(unsigned long node,
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 43c78d7..5bbbdb2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -510,6 +510,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
memstart_addr = min((u64)memstart_addr, base);
}

+u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+ return lmb_alloc(size, align);
+}
+
#ifdef CONFIG_BLK_DEV_INITRD
void __init early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index b51f797..406757a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -10,16 +10,18 @@
*/

#include <linux/kernel.h>
-#include <linux/lmb.h>
#include <linux/initrd.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
-
+#include <linux/string.h>
+#include <linux/errno.h>

#ifdef CONFIG_PPC
#include <asm/machdep.h>
#endif /* CONFIG_PPC */

+#include <asm/page.h>
+
int __initdata dt_root_addr_cells;
int __initdata dt_root_size_cells;

@@ -560,7 +562,8 @@ void __init unflatten_device_tree(void)
pr_debug(" size is %lx, allocating...\n", size);

/* Allocate memory for the expanded device tree */
- mem = lmb_alloc(size + 4, __alignof__(struct device_node));
+ mem = early_init_dt_alloc_memory_arch(size + 4,
+ __alignof__(struct device_node));
mem = (unsigned long) __va(mem);

((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index c9cb8a7..a1ca92c 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -78,6 +78,7 @@ extern void early_init_dt_check_for_initrd(unsigned long node);
extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
int depth, void *data);
extern void early_init_dt_add_memory_arch(u64 base, u64 size);
+extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align);
extern u64 dt_mem_next_cell(int s, __be32 **cellp);

/*

2010-02-13 16:08:12

by Grant Likely

[permalink] [raw]
Subject: [PATCH 5/9] of: put default string compare and #a/s-cell values into common header

Most architectures don't need to change these. Put them into common
code to eliminate some duplication

Signed-off-by: Grant Likely <[email protected]>
---

arch/microblaze/include/asm/prom.h | 7 -------
arch/powerpc/include/asm/prom.h | 7 -------
include/linux/of.h | 13 +++++++++++++
3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index 6c6b386..ddc5c57 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -26,13 +26,6 @@
#include <asm/irq.h>
#include <asm/atomic.h>

-#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
-#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
-
-#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
-#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
-#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
-
extern struct device_node *of_chosen;

#define HAVE_ARCH_DEVTREE_FIXUPS
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index f384db8..4a5070e 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -23,13 +23,6 @@
#include <asm/irq.h>
#include <asm/atomic.h>

-#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
-#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
-
-#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
-#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
-#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
-
extern struct device_node *of_chosen;

#define HAVE_ARCH_DEVTREE_FIXUPS
diff --git a/include/linux/of.h b/include/linux/of.h
index 48b0ee6..5cd2840 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -116,6 +116,19 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)

#include <asm/prom.h>

+/* Default #address and #size cells. Allow arch asm/prom.h to override */
+#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT)
+#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
+#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
+#endif
+
+/* Default string compare functions, Allow arch asm/prom.h to override */
+#if !defined(of_compat_cmp)
+#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
+#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
+#endif
+
/* flag descriptions */
#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
#define OF_DETACHED 2 /* node has been detached from the device tree */

2010-02-13 16:11:10

by Grant Likely

[permalink] [raw]
Subject: [PATCH 6/9] of: remove unused extern reference to devtree_lock

Neither the powerpc nor the microblaze code use devtree_lock anymore.
Remove the extern reference.

Signed-off-by: Grant Likely <[email protected]>
---

arch/microblaze/include/asm/prom.h | 2 --
arch/powerpc/kernel/prom.c | 2 --
2 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index ddc5c57..8b1ebd3 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -30,8 +30,6 @@ extern struct device_node *of_chosen;

#define HAVE_ARCH_DEVTREE_FIXUPS

-extern rwlock_t devtree_lock; /* temporary while merging */
-
/* Other Prototypes */
extern int early_uartlite_console(void);

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 5bbbdb2..4869c93 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -67,8 +67,6 @@ int __initdata iommu_force_on;
unsigned long tce_alloc_start, tce_alloc_end;
#endif

-extern rwlock_t devtree_lock; /* temporary while merging */
-
/* export that to outside world */
struct device_node *of_chosen;

2010-02-14 06:10:21

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 2/9] proc_devtree: fix THIS_MODULE without module.h

On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
> From: Jeremy Kerr <[email protected]>
>
> Commit e22f628395432b967f2f505858c64450f7835365 introduced a build
> breakage for ARM devtree work: the THIS_MODULE macro was added, but we
> don't have module.h
>
> This change adds the necessary #include to get THIS_MODULE defined.
> While we could just replace it with NULL (PROC_FS is a bool, not a
> tristate), using THIS_MODULE will prevent unexpected breakage if we
> ever do compile this as a module.
>
> Signed-off-by: Jeremy Kerr <[email protected]>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

> ---
>
> fs/proc/proc_devtree.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
> index 0ec4511..f8650dc 100644
> --- a/fs/proc/proc_devtree.c
> +++ b/fs/proc/proc_devtree.c
> @@ -11,6 +11,7 @@
> #include <linux/stat.h>
> #include <linux/string.h>
> #include <linux/of.h>
> +#include <linux/module.h>
> #include <asm/prom.h>
> #include <asm/uaccess.h>
> #include "internal.h"

2010-02-14 06:10:12

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 1/9] of: Remove old and misplaced function declarations

On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
> The following functions don't exist:
> finish_device_tree()
> print_properties()
> prom_n_intr_cells()
> prom_get_irq_senses()
>
> The following functions are in drivers/of/base.c, so the declaration
> belongs in of.h instead of of_fdt.h
> of_machine_is_compatible()
> prom_add_property()
> prom_remove_property()
> prom_update_property()
>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

> ---
>
> include/linux/of.h | 8 ++++++++
> include/linux/of_fdt.h | 10 ----------
> 2 files changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/of.h b/include/linux/of.h
> index fa5571b..5c7b6a6 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -180,6 +180,14 @@ extern int of_parse_phandles_with_args(struct device_node *np,
> const char *list_name, const char *cells_name, int index,
> struct device_node **out_node, const void **out_args);
>
> +extern int of_machine_is_compatible(const char *compat);
> +
> +extern int prom_add_property(struct device_node* np, struct property* prop);
> +extern int prom_remove_property(struct device_node *np, struct property *prop);
> +extern int prom_update_property(struct device_node *np,
> + struct property *newprop,
> + struct property *oldprop);
> +
> #if defined(CONFIG_OF_DYNAMIC)
> /* For updating the device tree at runtime */
> extern void of_attach_node(struct device_node *);
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index 0007187..c9cb8a7 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -95,18 +95,8 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,
> int depth, void *data);
>
> /* Other Prototypes */
> -extern void finish_device_tree(void);
> extern void unflatten_device_tree(void);
> extern void early_init_devtree(void *);
> -extern int of_machine_is_compatible(const char *compat);
> -extern void print_properties(struct device_node *node);
> -extern int prom_n_intr_cells(struct device_node* np);
> -extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
> -extern int prom_add_property(struct device_node* np, struct property* prop);
> -extern int prom_remove_property(struct device_node *np, struct property *prop);
> -extern int prom_update_property(struct device_node *np,
> - struct property *newprop,
> - struct property *oldprop);
>
> #endif /* __ASSEMBLY__ */
> #endif /* _LINUX_OF_FDT_H */

2010-02-14 06:11:47

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 4/9] of/flattree: Don't assume HAVE_LMB

On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
> From: Jeremy Kerr <[email protected]>
>
> We don't always have lmb available, so make arches provide an
> early_init_dt_alloc_memory_arch() to handle the allocation of
> memory in the fdt code.
>
> When we don't have lmb.h included, we need asm/page.h for __va.
>
> Signed-off-by: Jeremy Kerr <[email protected]>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

> ---
>
> arch/microblaze/kernel/prom.c | 5 +++++
> arch/powerpc/kernel/prom.c | 5 +++++
> drivers/of/fdt.c | 9 ++++++---
> include/linux/of_fdt.h | 1 +
> 4 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
> index 050b799..a7dcaf0 100644
> --- a/arch/microblaze/kernel/prom.c
> +++ b/arch/microblaze/kernel/prom.c
> @@ -55,6 +55,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> lmb_add(base, size);
> }
>
> +u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
> +{
> + return lmb_alloc(size, align);
> +}
> +
> #ifdef CONFIG_EARLY_PRINTK
> /* MS this is Microblaze specifig function */
> static int __init early_init_dt_scan_serial(unsigned long node,
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 43c78d7..5bbbdb2 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -510,6 +510,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> memstart_addr = min((u64)memstart_addr, base);
> }
>
> +u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
> +{
> + return lmb_alloc(size, align);
> +}
> +
> #ifdef CONFIG_BLK_DEV_INITRD
> void __init early_init_dt_setup_initrd_arch(unsigned long start,
> unsigned long end)
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index b51f797..406757a 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -10,16 +10,18 @@
> */
>
> #include <linux/kernel.h>
> -#include <linux/lmb.h>
> #include <linux/initrd.h>
> #include <linux/of.h>
> #include <linux/of_fdt.h>
> -
> +#include <linux/string.h>
> +#include <linux/errno.h>
>
> #ifdef CONFIG_PPC
> #include <asm/machdep.h>
> #endif /* CONFIG_PPC */
>
> +#include <asm/page.h>
> +
> int __initdata dt_root_addr_cells;
> int __initdata dt_root_size_cells;
>
> @@ -560,7 +562,8 @@ void __init unflatten_device_tree(void)
> pr_debug(" size is %lx, allocating...\n", size);
>
> /* Allocate memory for the expanded device tree */
> - mem = lmb_alloc(size + 4, __alignof__(struct device_node));
> + mem = early_init_dt_alloc_memory_arch(size + 4,
> + __alignof__(struct device_node));
> mem = (unsigned long) __va(mem);
>
> ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index c9cb8a7..a1ca92c 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -78,6 +78,7 @@ extern void early_init_dt_check_for_initrd(unsigned long node);
> extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
> int depth, void *data);
> extern void early_init_dt_add_memory_arch(u64 base, u64 size);
> +extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align);
> extern u64 dt_mem_next_cell(int s, __be32 **cellp);
>
> /*

2010-02-14 06:12:18

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 5/9] of: put default string compare and #a/s-cell values into common header

On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
> Most architectures don't need to change these. Put them into common
> code to eliminate some duplication
>
> Signed-off-by: Grant Likely <[email protected]>
> ---

Acked-by: Benjamin Herrenschmidt <[email protected]>

>
> arch/microblaze/include/asm/prom.h | 7 -------
> arch/powerpc/include/asm/prom.h | 7 -------
> include/linux/of.h | 13 +++++++++++++
> 3 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
> index 6c6b386..ddc5c57 100644
> --- a/arch/microblaze/include/asm/prom.h
> +++ b/arch/microblaze/include/asm/prom.h
> @@ -26,13 +26,6 @@
> #include <asm/irq.h>
> #include <asm/atomic.h>
>
> -#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
> -#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
> -
> -#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
> -#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
> -#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
> -
> extern struct device_node *of_chosen;
>
> #define HAVE_ARCH_DEVTREE_FIXUPS
> diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
> index f384db8..4a5070e 100644
> --- a/arch/powerpc/include/asm/prom.h
> +++ b/arch/powerpc/include/asm/prom.h
> @@ -23,13 +23,6 @@
> #include <asm/irq.h>
> #include <asm/atomic.h>
>
> -#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
> -#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
> -
> -#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
> -#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
> -#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
> -
> extern struct device_node *of_chosen;
>
> #define HAVE_ARCH_DEVTREE_FIXUPS
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 48b0ee6..5cd2840 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -116,6 +116,19 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
>
> #include <asm/prom.h>
>
> +/* Default #address and #size cells. Allow arch asm/prom.h to override */
> +#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT)
> +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
> +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
> +#endif
> +
> +/* Default string compare functions, Allow arch asm/prom.h to override */
> +#if !defined(of_compat_cmp)
> +#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
> +#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
> +#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
> +#endif
> +
> /* flag descriptions */
> #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
> #define OF_DETACHED 2 /* node has been detached from the device tree */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2010-02-14 06:12:39

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 6/9] of: remove unused extern reference to devtree_lock

On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
> Neither the powerpc nor the microblaze code use devtree_lock anymore.
> Remove the extern reference.
>
> Signed-off-by: Grant Likely <[email protected]>
> ---

Acked-by: Benjamin Herrenschmidt <[email protected]>


> arch/microblaze/include/asm/prom.h | 2 --
> arch/powerpc/kernel/prom.c | 2 --
> 2 files changed, 0 insertions(+), 4 deletions(-)
>
> diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
> index ddc5c57..8b1ebd3 100644
> --- a/arch/microblaze/include/asm/prom.h
> +++ b/arch/microblaze/include/asm/prom.h
> @@ -30,8 +30,6 @@ extern struct device_node *of_chosen;
>
> #define HAVE_ARCH_DEVTREE_FIXUPS
>
> -extern rwlock_t devtree_lock; /* temporary while merging */
> -
> /* Other Prototypes */
> extern int early_uartlite_console(void);
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 5bbbdb2..4869c93 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -67,8 +67,6 @@ int __initdata iommu_force_on;
> unsigned long tce_alloc_start, tce_alloc_end;
> #endif
>
> -extern rwlock_t devtree_lock; /* temporary while merging */
> -
> /* export that to outside world */
> struct device_node *of_chosen;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2010-02-14 06:13:33

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 8/9] of/sparc: Remove sparc-local declaration of allnodes and devtree_lock

On Sat, 2010-02-13 at 09:03 -0700, Grant Likely wrote:
> Both allnodes and devtree_lock are defined in common code. The
> extern declaration should be in the common header too so that the
> compiler can type check. allnodes is already in of.h, but
> devtree_lock should be declared there too.
>
> This patch removes the SPARC declarations and uses decls in of.h instead.
>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

> ---
>
> arch/sparc/kernel/prom.h | 3 ---
> include/linux/of.h | 2 ++
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
> index 453397f..a8591ef 100644
> --- a/arch/sparc/kernel/prom.h
> +++ b/arch/sparc/kernel/prom.h
> @@ -4,9 +4,6 @@
> #include <linux/spinlock.h>
> #include <asm/prom.h>
>
> -extern struct device_node *allnodes; /* temporary while merging */
> -extern rwlock_t devtree_lock; /* temporary while merging */
> -
> extern void * prom_early_alloc(unsigned long size);
> extern void irq_trans_init(struct device_node *dp);
>
> diff --git a/include/linux/of.h b/include/linux/of.h
> index d34cc5d..f6d9cbc 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -19,6 +19,7 @@
> #include <linux/bitops.h>
> #include <linux/kref.h>
> #include <linux/mod_devicetable.h>
> +#include <linux/spinlock.h>
>
> #include <asm/byteorder.h>
>
> @@ -67,6 +68,7 @@ struct device_node {
> /* Pointer for first entry in chain of all nodes. */
> extern struct device_node *allnodes;
> extern struct device_node *of_chosen;
> +extern rwlock_t devtree_lock;
>
> static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
> {
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2010-02-14 06:15:21

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 9/9] of: remove undefined request_OF_resource & release_OF_resource

On Sat, 2010-02-13 at 09:03 -0700, Grant Likely wrote:
> Neither request_OF_resource or release_OF_resource are defined
> anywhere. Remove the declarations.
>
> Signed-off-by: Grant Likely <[email protected]>
> ---

Acked-by: Benjamin Herrenschmidt <[email protected]>

> arch/microblaze/include/asm/prom.h | 4 ----
> arch/powerpc/include/asm/prom.h | 5 -----
> 2 files changed, 0 insertions(+), 9 deletions(-)
>
> diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
> index aa1a437..03f45a9 100644
> --- a/arch/microblaze/include/asm/prom.h
> +++ b/arch/microblaze/include/asm/prom.h
> @@ -31,10 +31,6 @@
> /* Other Prototypes */
> extern int early_uartlite_console(void);
>
> -extern struct resource *request_OF_resource(struct device_node *node,
> - int index, const char *name_postfix);
> -extern int release_OF_resource(struct device_node *node, int index);
> -
> /*
> * OF address retreival & translation
> */
> diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
> index 7f9a50a..ddd408a 100644
> --- a/arch/powerpc/include/asm/prom.h
> +++ b/arch/powerpc/include/asm/prom.h
> @@ -39,11 +39,6 @@ extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
> extern void pci_create_OF_bus_map(void);
> #endif
>
> -extern struct resource *request_OF_resource(struct device_node* node,
> - int index, const char* name_postfix);
> -extern int release_OF_resource(struct device_node* node, int index);
> -
> -
> /*
> * OF address retreival & translation
> */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2010-02-14 06:32:55

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 7/9] of: move definition of of_chosen into common code.

On Sat, 2010-02-13 at 09:03 -0700, Grant Likely wrote:
> Rather than defining of_chosen in each arch, it can be defined for all
> in driver/of/base.c
>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

> ---
>
> arch/microblaze/include/asm/prom.h | 2 --
> arch/microblaze/kernel/prom.c | 3 ---
> arch/powerpc/include/asm/prom.h | 2 --
> arch/powerpc/kernel/prom.c | 3 ---
> drivers/of/base.c | 1 +
> include/linux/of.h | 1 +
> 6 files changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
> index 8b1ebd3..aa1a437 100644
> --- a/arch/microblaze/include/asm/prom.h
> +++ b/arch/microblaze/include/asm/prom.h
> @@ -26,8 +26,6 @@
> #include <asm/irq.h>
> #include <asm/atomic.h>
>
> -extern struct device_node *of_chosen;
> -
> #define HAVE_ARCH_DEVTREE_FIXUPS
>
> /* Other Prototypes */
> diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
> index a7dcaf0..a15ef6d 100644
> --- a/arch/microblaze/kernel/prom.c
> +++ b/arch/microblaze/kernel/prom.c
> @@ -42,9 +42,6 @@
> #include <asm/sections.h>
> #include <asm/pci-bridge.h>
>
> -/* export that to outside world */
> -struct device_node *of_chosen;
> -
> void __init early_init_dt_scan_chosen_arch(unsigned long node)
> {
> /* No Microblaze specific code here */
> diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
> index 4a5070e..7f9a50a 100644
> --- a/arch/powerpc/include/asm/prom.h
> +++ b/arch/powerpc/include/asm/prom.h
> @@ -23,8 +23,6 @@
> #include <asm/irq.h>
> #include <asm/atomic.h>
>
> -extern struct device_node *of_chosen;
> -
> #define HAVE_ARCH_DEVTREE_FIXUPS
>
> #ifdef CONFIG_PPC32
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 4869c93..43238b2 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -67,9 +67,6 @@ int __initdata iommu_force_on;
> unsigned long tce_alloc_start, tce_alloc_end;
> #endif
>
> -/* export that to outside world */
> -struct device_node *of_chosen;
> -
> static int __init early_parse_mem(char *p)
> {
> if (!p)
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 873479a..cb96888 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -23,6 +23,7 @@
> #include <linux/proc_fs.h>
>
> struct device_node *allnodes;
> +struct device_node *of_chosen;
>
> /* use when traversing tree through the allnext, child, sibling,
> * or parent members of struct device_node.
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 5cd2840..d34cc5d 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -66,6 +66,7 @@ struct device_node {
>
> /* Pointer for first entry in chain of all nodes. */
> extern struct device_node *allnodes;
> +extern struct device_node *of_chosen;
>
> static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
> {
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2010-02-14 06:36:22

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH 3/9] of: protect linux/of.h with CONFIG_OF

On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
> From: Jeremy Kerr <[email protected]>
>
> For platforms that have CONFIG_OF optional, we need to make the contents
> of linux/of.h conditional on CONFIG_OF.
>
> Signed-off-by: Jeremy Kerr <[email protected]>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: Benjamin Herrenschmidt <[email protected]>

For now...

In the long run, maybe we want some of the iterators to be empty inlines
returning NULL ?

Cheers,
Ben.

> ---
>
> include/linux/of.h | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 5c7b6a6..48b0ee6 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -22,6 +22,8 @@
>
> #include <asm/byteorder.h>
>
> +#ifdef CONFIG_OF
> +
> typedef u32 phandle;
> typedef u32 ihandle;
>
> @@ -194,4 +196,5 @@ extern void of_attach_node(struct device_node *);
> extern void of_detach_node(struct device_node *);
> #endif
>
> +#endif /* CONFIG_OF */
> #endif /* _LINUX_OF_H */

2010-02-14 14:03:08

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH 4/9] of/flattree: Don't assume HAVE_LMB

Grant Likely wrote:
> From: Jeremy Kerr <[email protected]>
>
> We don't always have lmb available, so make arches provide an
> early_init_dt_alloc_memory_arch() to handle the allocation of
> memory in the fdt code.
>
> When we don't have lmb.h included, we need asm/page.h for __va.
>
> Signed-off-by: Jeremy Kerr <[email protected]>
> Signed-off-by: Grant Likely <[email protected]>
> ---
>
> arch/microblaze/kernel/prom.c | 5 +++++
> arch/powerpc/kernel/prom.c | 5 +++++
> drivers/of/fdt.c | 9 ++++++---
> include/linux/of_fdt.h | 1 +
> 4 files changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
> index 050b799..a7dcaf0 100644
> --- a/arch/microblaze/kernel/prom.c
> +++ b/arch/microblaze/kernel/prom.c
> @@ -55,6 +55,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> lmb_add(base, size);
> }
>
> +u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
> +{
> + return lmb_alloc(size, align);
> +}
> +
> #ifdef CONFIG_EARLY_PRINTK
> /* MS this is Microblaze specifig function */
> static int __init early_init_dt_scan_serial(unsigned long node,
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 43c78d7..5bbbdb2 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -510,6 +510,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> memstart_addr = min((u64)memstart_addr, base);
> }
>
> +u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
> +{
> + return lmb_alloc(size, align);
> +}
> +
> #ifdef CONFIG_BLK_DEV_INITRD
> void __init early_init_dt_setup_initrd_arch(unsigned long start,
> unsigned long end)
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index b51f797..406757a 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -10,16 +10,18 @@
> */
>
> #include <linux/kernel.h>
> -#include <linux/lmb.h>
> #include <linux/initrd.h>
> #include <linux/of.h>
> #include <linux/of_fdt.h>
> -
> +#include <linux/string.h>
> +#include <linux/errno.h>
>
> #ifdef CONFIG_PPC
> #include <asm/machdep.h>
> #endif /* CONFIG_PPC */

It is not part of your patch but I think that will be great completely
remove this CONFIG_PPC part from generic OF file.
Would it be possible to include your asm/machdep.h through asm/page.h or
any other file?

Michal

>
> +#include <asm/page.h>
> +
> int __initdata dt_root_addr_cells;
> int __initdata dt_root_size_cells;
>
> @@ -560,7 +562,8 @@ void __init unflatten_device_tree(void)
> pr_debug(" size is %lx, allocating...\n", size);
>
> /* Allocate memory for the expanded device tree */
> - mem = lmb_alloc(size + 4, __alignof__(struct device_node));
> + mem = early_init_dt_alloc_memory_arch(size + 4,
> + __alignof__(struct device_node));
> mem = (unsigned long) __va(mem);
>
> ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index c9cb8a7..a1ca92c 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -78,6 +78,7 @@ extern void early_init_dt_check_for_initrd(unsigned long node);
> extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
> int depth, void *data);
> extern void early_init_dt_add_memory_arch(u64 base, u64 size);
> +extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align);
> extern u64 dt_mem_next_cell(int s, __be32 **cellp);
>
> /*
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/


--
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: http://www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663

2010-02-14 14:06:50

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 3/9] of: protect linux/of.h with CONFIG_OF

On Sat, Feb 13, 2010 at 11:10 PM, Benjamin Herrenschmidt
<[email protected]> wrote:
> On Sat, 2010-02-13 at 09:02 -0700, Grant Likely wrote:
>> From: Jeremy Kerr <[email protected]>
>>
>> For platforms that have CONFIG_OF optional, we need to make the contents
>> of linux/of.h conditional on CONFIG_OF.
>>
>> Signed-off-by: Jeremy Kerr <[email protected]>
>> Signed-off-by: Grant Likely <[email protected]>
>
> Acked-by: Benjamin Herrenschmidt <[email protected]>
>
> For now...
>
> In the long run, maybe we want some of the iterators to be empty inlines
> returning NULL ?

Yes. I'll add them as they are needed.

g.

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

2010-02-14 14:08:51

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH 0/9] Random OF cleanups and merges

Grant Likely wrote:
> Here's another batch of cleanup patches from my test-devicetree branch.
> A number of cleanups, corrections and minor merges of common code.
> Also a patch from Jeremy to make the flat tree work on architectures
> without LMB (arm).
>
> Once I've collected acks on these, I'll move them over to my
> next-devicetree branch on git://git.secretlab.ca/git/linux-2.6

All changes look ok. Please add them to linux-next which I am testing. I
don't expect any problem with it but anywya if any problems arise, I
will let you know.

I don't want to reply every email as Ben that's why one my big ACK
for that 9 patches.

Acked-by: Michal Simek <[email protected]>

>
> Cheers,
> g.
>
> ---
>
> Grant Likely (6):
> of: remove undefined request_OF_resource & release_OF_resource
> of/sparc: Remove sparc-local declaration of allnodes and devtree_lock
> of: move definition of of_chosen into common code.
> of: remove unused extern reference to devtree_lock
> of: put default string compare and #a/s-cell values into common header
> of: Remove old and misplaced function declarations
>
> Jeremy Kerr (3):
> of/flattree: Don't assume HAVE_LMB
> of: protect linux/of.h with CONFIG_OF
> proc_devtree: fix THIS_MODULE without module.h
>
>
> arch/microblaze/include/asm/prom.h | 15 ---------------
> arch/microblaze/kernel/prom.c | 8 +++++---
> arch/powerpc/include/asm/prom.h | 14 --------------
> arch/powerpc/kernel/prom.c | 10 +++++-----
> arch/sparc/kernel/prom.h | 3 ---
> drivers/of/base.c | 1 +
> drivers/of/fdt.c | 9 ++++++---
> fs/proc/proc_devtree.c | 1 +
> include/linux/of.h | 27 +++++++++++++++++++++++++++
> include/linux/of_fdt.h | 11 +----------
> 10 files changed, 46 insertions(+), 53 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/


--
Michal Simek, Ing. (M.Eng)
w: http://www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/
Microblaze U-BOOT custodian

2010-02-14 14:09:18

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH 4/9] of/flattree: Don't assume HAVE_LMB

On Sun, Feb 14, 2010 at 7:00 AM, Michal Simek
<[email protected]> wrote:
> Grant Likely wrote:
>>
>> From: Jeremy Kerr <[email protected]>
>>
>> We don't always have lmb available, so make arches provide an
>> early_init_dt_alloc_memory_arch() to handle the allocation of
>> memory in the fdt code.
>>
>> When we don't have lmb.h included, we need asm/page.h for __va.
>>
>> Signed-off-by: Jeremy Kerr <[email protected]>
>> Signed-off-by: Grant Likely <[email protected]>
>> ---
>>
>> ?arch/microblaze/kernel/prom.c | ? ?5 +++++
>> ?arch/powerpc/kernel/prom.c ? ?| ? ?5 +++++
>> ?drivers/of/fdt.c ? ? ? ? ? ? ?| ? ?9 ++++++---
>> ?include/linux/of_fdt.h ? ? ? ?| ? ?1 +
>> ?4 files changed, 17 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
>> index 050b799..a7dcaf0 100644
>> --- a/arch/microblaze/kernel/prom.c
>> +++ b/arch/microblaze/kernel/prom.c
>> @@ -55,6 +55,11 @@ void __init early_init_dt_add_memory_arch(u64 base, u64
>> size)
>> ? ? ? ?lmb_add(base, size);
>> ?}
>> ?+u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
>> +{
>> + ? ? ? return lmb_alloc(size, align);
>> +}
>> +
>> ?#ifdef CONFIG_EARLY_PRINTK
>> ?/* MS this is Microblaze specifig function */
>> ?static int __init early_init_dt_scan_serial(unsigned long node,
>> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
>> index 43c78d7..5bbbdb2 100644
>> --- a/arch/powerpc/kernel/prom.c
>> +++ b/arch/powerpc/kernel/prom.c
>> @@ -510,6 +510,11 @@ void __init early_init_dt_add_memory_arch(u64 base,
>> u64 size)
>> ? ? ? ?memstart_addr = min((u64)memstart_addr, base);
>> ?}
>> ?+u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
>> +{
>> + ? ? ? return lmb_alloc(size, align);
>> +}
>> +
>> ?#ifdef CONFIG_BLK_DEV_INITRD
>> ?void __init early_init_dt_setup_initrd_arch(unsigned long start,
>> ? ? ? ? ? ? ? ?unsigned long end)
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index b51f797..406757a 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -10,16 +10,18 @@
>> ?*/
>> ??#include <linux/kernel.h>
>> -#include <linux/lmb.h>
>> ?#include <linux/initrd.h>
>> ?#include <linux/of.h>
>> ?#include <linux/of_fdt.h>
>> -
>> +#include <linux/string.h>
>> +#include <linux/errno.h>
>> ??#ifdef CONFIG_PPC
>> ?#include <asm/machdep.h>
>> ?#endif /* CONFIG_PPC */
>
> It is not part of your patch but I think that will be great completely
> remove this CONFIG_PPC part from generic OF file.
> Would it be possible to include your asm/machdep.h through asm/page.h or any
> other file?

Yup. I'll get there unless someone else beats me to it. :-)

>
> Michal
>
>> ?+#include <asm/page.h>
>> +
>> ?int __initdata dt_root_addr_cells;
>> ?int __initdata dt_root_size_cells;
>> ?@@ -560,7 +562,8 @@ void __init unflatten_device_tree(void)
>> ? ? ? ?pr_debug(" ?size is %lx, allocating...\n", size);
>> ? ? ? ? ?/* Allocate memory for the expanded device tree */
>> - ? ? ? mem = lmb_alloc(size + 4, __alignof__(struct device_node));
>> + ? ? ? mem = early_init_dt_alloc_memory_arch(size + 4,
>> + ? ? ? ? ? ? ? ? ? ? ? __alignof__(struct device_node));
>> ? ? ? ?mem = (unsigned long) __va(mem);
>> ? ? ? ? ?((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
>> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
>> index c9cb8a7..a1ca92c 100644
>> --- a/include/linux/of_fdt.h
>> +++ b/include/linux/of_fdt.h
>> @@ -78,6 +78,7 @@ extern void early_init_dt_check_for_initrd(unsigned long
>> node);
>> ?extern int early_init_dt_scan_memory(unsigned long node, const char
>> *uname,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int depth, void *data);
>> ?extern void early_init_dt_add_memory_arch(u64 base, u64 size);
>> +extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align);
>> ?extern u64 dt_mem_next_cell(int s, __be32 **cellp);
>> ??/*
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to [email protected]
>> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at ?http://www.tux.org/lkml/
>
>
> --
> Michal Simek, Ing. (M.Eng)
> PetaLogix - Linux Solutions for a Reconfigurable World
> w: http://www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663
>



--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

2010-02-14 19:49:56

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 8/9] of/sparc: Remove sparc-local declaration of allnodes and devtree_lock

From: Grant Likely <[email protected]>
Date: Sat, 13 Feb 2010 09:03:09 -0700

> Both allnodes and devtree_lock are defined in common code. The
> extern declaration should be in the common header too so that the
> compiler can type check. allnodes is already in of.h, but
> devtree_lock should be declared there too.
>
> This patch removes the SPARC declarations and uses decls in of.h instead.
>
> Signed-off-by: Grant Likely <[email protected]>

Acked-by: David S. Miller <[email protected]>