* [PATCH 10/11] of: remove special case definition of of_read_ulong()
From: Grant Likely @ 2009-11-05 7:47 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Special case of of_read_ulong() was defined for PPC32 to toss away
all but the last 32 bits when a large number value was read, and the
'normal' version for ppc64 just #defined of_read_ulong to of_read_number
which causes compiler warnings on MicroBlaze and other 32 bit
architectures because it returns a u64 instead of a ulong.
This patch fixes the problem by defining a common implementation of
of_read_ulong() that works everywhere.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
include/linux/of.h | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index bec2157..d4c014a 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -113,14 +113,11 @@ static inline u64 of_read_number(const u32 *cell, int size)
}
/* Like of_read_number, but we want an unsigned long result */
-#ifdef CONFIG_PPC32
static inline unsigned long of_read_ulong(const u32 *cell, int size)
{
- return cell[size-1];
+ /* toss away upper bits if unsigned long is smaller than u64 */
+ return of_read_number(cell, size);
}
-#else
-#define of_read_ulong(cell, size) of_read_number(cell, size)
-#endif
#include <asm/prom.h>
^ permalink raw reply related
* [PATCH 09/11] of: merge prom_{add,remove,modify}_property
From: Grant Likely @ 2009-11-05 7:47 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and MicroBlaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/microblaze/kernel/prom.c | 113 ----------------------------------------
arch/powerpc/kernel/prom.c | 114 ----------------------------------------
drivers/of/base.c | 116 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 116 insertions(+), 227 deletions(-)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 901d538..a38e373 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -606,119 +606,6 @@ out_unlock:
write_unlock_irqrestore(&devtree_lock, flags);
}
-/*
- * Add a property to a node
- */
-int prom_add_property(struct device_node *np, struct property *prop)
-{
- struct property **next;
- unsigned long flags;
-
- prop->next = NULL;
- write_lock_irqsave(&devtree_lock, flags);
- next = &np->properties;
- while (*next) {
- if (strcmp(prop->name, (*next)->name) == 0) {
- /* duplicate ! don't insert it */
- write_unlock_irqrestore(&devtree_lock, flags);
- return -1;
- }
- next = &(*next)->next;
- }
- *next = prop;
- write_unlock_irqrestore(&devtree_lock, flags);
-
-#ifdef CONFIG_PROC_DEVICETREE
- /* try to add to proc as well if it was initialized */
- if (np->pde)
- proc_device_tree_add_prop(np->pde, prop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
- return 0;
-}
-
-/*
- * Remove a property from a node. Note that we don't actually
- * remove it, since we have given out who-knows-how-many pointers
- * to the data using get-property. Instead we just move the property
- * to the "dead properties" list, so it won't be found any more.
- */
-int prom_remove_property(struct device_node *np, struct property *prop)
-{
- struct property **next;
- unsigned long flags;
- int found = 0;
-
- write_lock_irqsave(&devtree_lock, flags);
- next = &np->properties;
- while (*next) {
- if (*next == prop) {
- /* found the node */
- *next = prop->next;
- prop->next = np->deadprops;
- np->deadprops = prop;
- found = 1;
- break;
- }
- next = &(*next)->next;
- }
- write_unlock_irqrestore(&devtree_lock, flags);
-
- if (!found)
- return -ENODEV;
-
-#ifdef CONFIG_PROC_DEVICETREE
- /* try to remove the proc node as well */
- if (np->pde)
- proc_device_tree_remove_prop(np->pde, prop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
- return 0;
-}
-
-/*
- * Update a property in a node. Note that we don't actually
- * remove it, since we have given out who-knows-how-many pointers
- * to the data using get-property. Instead we just move the property
- * to the "dead properties" list, and add the new property to the
- * property list
- */
-int prom_update_property(struct device_node *np,
- struct property *newprop,
- struct property *oldprop)
-{
- struct property **next;
- unsigned long flags;
- int found = 0;
-
- write_lock_irqsave(&devtree_lock, flags);
- next = &np->properties;
- while (*next) {
- if (*next == oldprop) {
- /* found the node */
- newprop->next = oldprop->next;
- *next = newprop;
- oldprop->next = np->deadprops;
- np->deadprops = oldprop;
- found = 1;
- break;
- }
- next = &(*next)->next;
- }
- write_unlock_irqrestore(&devtree_lock, flags);
-
- if (!found)
- return -ENODEV;
-
-#ifdef CONFIG_PROC_DEVICETREE
- /* try to add to proc as well if it was initialized */
- if (np->pde)
- proc_device_tree_update_prop(np->pde, newprop, oldprop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
- return 0;
-}
-
#if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
static struct debugfs_blob_wrapper flat_dt_blob;
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1280f34..7f88566 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1130,120 +1130,6 @@ static int __init prom_reconfig_setup(void)
__initcall(prom_reconfig_setup);
#endif
-/*
- * Add a property to a node
- */
-int prom_add_property(struct device_node* np, struct property* prop)
-{
- struct property **next;
- unsigned long flags;
-
- prop->next = NULL;
- write_lock_irqsave(&devtree_lock, flags);
- next = &np->properties;
- while (*next) {
- if (strcmp(prop->name, (*next)->name) == 0) {
- /* duplicate ! don't insert it */
- write_unlock_irqrestore(&devtree_lock, flags);
- return -1;
- }
- next = &(*next)->next;
- }
- *next = prop;
- write_unlock_irqrestore(&devtree_lock, flags);
-
-#ifdef CONFIG_PROC_DEVICETREE
- /* try to add to proc as well if it was initialized */
- if (np->pde)
- proc_device_tree_add_prop(np->pde, prop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
- return 0;
-}
-
-/*
- * Remove a property from a node. Note that we don't actually
- * remove it, since we have given out who-knows-how-many pointers
- * to the data using get-property. Instead we just move the property
- * to the "dead properties" list, so it won't be found any more.
- */
-int prom_remove_property(struct device_node *np, struct property *prop)
-{
- struct property **next;
- unsigned long flags;
- int found = 0;
-
- write_lock_irqsave(&devtree_lock, flags);
- next = &np->properties;
- while (*next) {
- if (*next == prop) {
- /* found the node */
- *next = prop->next;
- prop->next = np->deadprops;
- np->deadprops = prop;
- found = 1;
- break;
- }
- next = &(*next)->next;
- }
- write_unlock_irqrestore(&devtree_lock, flags);
-
- if (!found)
- return -ENODEV;
-
-#ifdef CONFIG_PROC_DEVICETREE
- /* try to remove the proc node as well */
- if (np->pde)
- proc_device_tree_remove_prop(np->pde, prop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
- return 0;
-}
-
-/*
- * Update a property in a node. Note that we don't actually
- * remove it, since we have given out who-knows-how-many pointers
- * to the data using get-property. Instead we just move the property
- * to the "dead properties" list, and add the new property to the
- * property list
- */
-int prom_update_property(struct device_node *np,
- struct property *newprop,
- struct property *oldprop)
-{
- struct property **next;
- unsigned long flags;
- int found = 0;
-
- write_lock_irqsave(&devtree_lock, flags);
- next = &np->properties;
- while (*next) {
- if (*next == oldprop) {
- /* found the node */
- newprop->next = oldprop->next;
- *next = newprop;
- oldprop->next = np->deadprops;
- np->deadprops = oldprop;
- found = 1;
- break;
- }
- next = &(*next)->next;
- }
- write_unlock_irqrestore(&devtree_lock, flags);
-
- if (!found)
- return -ENODEV;
-
-#ifdef CONFIG_PROC_DEVICETREE
- /* try to add to proc as well if it was initialized */
- if (np->pde)
- proc_device_tree_update_prop(np->pde, newprop, oldprop);
-#endif /* CONFIG_PROC_DEVICETREE */
-
- return 0;
-}
-
-
/* Find the device node for a given logical cpu number, also returns the cpu
* local thread number (index in ibm,interrupt-server#s) if relevant and
* asked for (non NULL)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index e6627b2..ec56739 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -658,3 +658,119 @@ err0:
return ret;
}
EXPORT_SYMBOL(of_parse_phandles_with_args);
+
+/**
+ * prom_add_property - Add a property to a node
+ */
+int prom_add_property(struct device_node *np, struct property *prop)
+{
+ struct property **next;
+ unsigned long flags;
+
+ prop->next = NULL;
+ write_lock_irqsave(&devtree_lock, flags);
+ next = &np->properties;
+ while (*next) {
+ if (strcmp(prop->name, (*next)->name) == 0) {
+ /* duplicate ! don't insert it */
+ write_unlock_irqrestore(&devtree_lock, flags);
+ return -1;
+ }
+ next = &(*next)->next;
+ }
+ *next = prop;
+ write_unlock_irqrestore(&devtree_lock, flags);
+
+#ifdef CONFIG_PROC_DEVICETREE
+ /* try to add to proc as well if it was initialized */
+ if (np->pde)
+ proc_device_tree_add_prop(np->pde, prop);
+#endif /* CONFIG_PROC_DEVICETREE */
+
+ return 0;
+}
+
+/**
+ * prom_remove_property - Remove a property from a node.
+ *
+ * Note that we don't actually remove it, since we have given out
+ * who-knows-how-many pointers to the data using get-property.
+ * Instead we just move the property to the "dead properties"
+ * list, so it won't be found any more.
+ */
+int prom_remove_property(struct device_node *np, struct property *prop)
+{
+ struct property **next;
+ unsigned long flags;
+ int found = 0;
+
+ write_lock_irqsave(&devtree_lock, flags);
+ next = &np->properties;
+ while (*next) {
+ if (*next == prop) {
+ /* found the node */
+ *next = prop->next;
+ prop->next = np->deadprops;
+ np->deadprops = prop;
+ found = 1;
+ break;
+ }
+ next = &(*next)->next;
+ }
+ write_unlock_irqrestore(&devtree_lock, flags);
+
+ if (!found)
+ return -ENODEV;
+
+#ifdef CONFIG_PROC_DEVICETREE
+ /* try to remove the proc node as well */
+ if (np->pde)
+ proc_device_tree_remove_prop(np->pde, prop);
+#endif /* CONFIG_PROC_DEVICETREE */
+
+ return 0;
+}
+
+/*
+ * prom_update_property - Update a property in a node.
+ *
+ * Note that we don't actually remove it, since we have given out
+ * who-knows-how-many pointers to the data using get-property.
+ * Instead we just move the property to the "dead properties" list,
+ * and add the new property to the property list
+ */
+int prom_update_property(struct device_node *np,
+ struct property *newprop,
+ struct property *oldprop)
+{
+ struct property **next;
+ unsigned long flags;
+ int found = 0;
+
+ write_lock_irqsave(&devtree_lock, flags);
+ next = &np->properties;
+ while (*next) {
+ if (*next == oldprop) {
+ /* found the node */
+ newprop->next = oldprop->next;
+ *next = newprop;
+ oldprop->next = np->deadprops;
+ np->deadprops = oldprop;
+ found = 1;
+ break;
+ }
+ next = &(*next)->next;
+ }
+ write_unlock_irqrestore(&devtree_lock, flags);
+
+ if (!found)
+ return -ENODEV;
+
+#ifdef CONFIG_PROC_DEVICETREE
+ /* try to add to proc as well if it was initialized */
+ if (np->pde)
+ proc_device_tree_update_prop(np->pde, newprop, oldprop);
+#endif /* CONFIG_PROC_DEVICETREE */
+
+ return 0;
+}
^ permalink raw reply related
* [PATCH 08/11] of/flattree: Merge unflatten_device_tree
From: Grant Likely @ 2009-11-05 7:46 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and MicroBlaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/microblaze/include/asm/prom.h | 1 -
arch/microblaze/kernel/prom.c | 49 ----------------------------------
arch/powerpc/kernel/prom.c | 50 -----------------------------------
drivers/of/fdt.c | 52 ++++++++++++++++++++++++++++++++++++
include/linux/of.h | 3 ++
include/linux/of_fdt.h | 4 ---
6 files changed, 55 insertions(+), 104 deletions(-)
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h
index ef3ec1d..07d1063 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -37,7 +37,6 @@ extern struct device_node *of_chosen;
#define HAVE_ARCH_DEVTREE_FIXUPS
-extern struct device_node *allnodes; /* temporary while merging */
extern rwlock_t devtree_lock; /* temporary while merging */
/* For updating the device tree at runtime */
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 021770a..901d538 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,55 +50,6 @@ typedef u32 cell_t;
/* export that to outside world */
struct device_node *of_chosen;
-/**
- * unflattens the device-tree passed by the firmware, creating the
- * tree of struct device_node. It also fills the "name" and "type"
- * pointers of the nodes so the normal device-tree walking functions
- * can be used (this used to be done by finish_device_tree)
- */
-void __init unflatten_device_tree(void)
-{
- unsigned long start, mem, size;
- struct device_node **allnextp = &allnodes;
-
- pr_debug(" -> unflatten_device_tree()\n");
-
- /* First pass, scan for size */
- start = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
- size = unflatten_dt_node(0, &start, NULL, NULL, 0);
- size = (size | 3) + 1;
-
- 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 = (unsigned long) __va(mem);
-
- ((u32 *)mem)[size / 4] = 0xdeadbeef;
-
- pr_debug(" unflattening %lx...\n", mem);
-
- /* Second pass, do actual unflattening */
- start = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
- unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
- if (*((u32 *)start) != OF_DT_END)
- printk(KERN_WARNING "Weird tag at end of tree: %08x\n",
- *((u32 *)start));
- if (((u32 *)mem)[size / 4] != 0xdeadbeef)
- printk(KERN_WARNING "End of tree marker overwritten: %08x\n",
- ((u32 *)mem)[size / 4]);
- *allnextp = NULL;
-
- /* Get pointer to OF "/chosen" node for use everywhere */
- of_chosen = of_find_node_by_path("/chosen");
- if (of_chosen == NULL)
- of_chosen = of_find_node_by_path("/chosen@0");
-
- pr_debug(" <- unflatten_device_tree()\n");
-}
-
#define early_init_dt_scan_drconf_memory(node) 0
static int __init early_init_dt_scan_cpus(unsigned long node,
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index a102a0a..1280f34 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -73,8 +73,6 @@ unsigned long tce_alloc_start, tce_alloc_end;
typedef u32 cell_t;
-extern struct device_node *allnodes; /* temporary while merging */
-
extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
@@ -119,54 +117,6 @@ static void __init move_device_tree(void)
DBG("<- move_device_tree\n");
}
-/**
- * unflattens the device-tree passed by the firmware, creating the
- * tree of struct device_node. It also fills the "name" and "type"
- * pointers of the nodes so the normal device-tree walking functions
- * can be used (this used to be done by finish_device_tree)
- */
-void __init unflatten_device_tree(void)
-{
- unsigned long start, mem, size;
- struct device_node **allnextp = &allnodes;
-
- DBG(" -> unflatten_device_tree()\n");
-
- /* First pass, scan for size */
- start = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
- size = unflatten_dt_node(0, &start, NULL, NULL, 0);
- size = (size | 3) + 1;
-
- DBG(" size is %lx, allocating...\n", size);
-
- /* Allocate memory for the expanded device tree */
- mem = lmb_alloc(size + 4, __alignof__(struct device_node));
- mem = (unsigned long) __va(mem);
-
- ((u32 *)mem)[size / 4] = 0xdeadbeef;
-
- DBG(" unflattening %lx...\n", mem);
-
- /* Second pass, do actual unflattening */
- start = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
- unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
- if (*((u32 *)start) != OF_DT_END)
- printk(KERN_WARNING "Weird tag at end of tree: %08x\n", *((u32 *)start));
- if (((u32 *)mem)[size / 4] != 0xdeadbeef)
- printk(KERN_WARNING "End of tree marker overwritten: %08x\n",
- ((u32 *)mem)[size / 4] );
- *allnextp = NULL;
-
- /* Get pointer to OF "/chosen" node for use everywhere */
- of_chosen = of_find_node_by_path("/chosen");
- if (of_chosen == NULL)
- of_chosen = of_find_node_by_path("/chosen@0");
-
- DBG(" <- unflatten_device_tree()\n");
-}
-
/*
* ibm,pa-features is a per-cpu property that contains a string of
* attribute descriptors, each of which has a 2 byte header plus up
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index df1ac8d..ad3a2b6 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -9,6 +9,8 @@
* version 2 as published by the Free Software Foundation.
*/
+#include <linux/kernel.h>
+#include <linux/lmb.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
@@ -367,3 +369,53 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
*p += 4;
return mem;
}
+
+/**
+ * unflatten_device_tree - create tree of device_nodes from flat blob
+ *
+ * unflattens the device-tree passed by the firmware, creating the
+ * tree of struct device_node. It also fills the "name" and "type"
+ * pointers of the nodes so the normal device-tree walking functions
+ * can be used.
+ */
+void __init unflatten_device_tree(void)
+{
+ unsigned long start, mem, size;
+ struct device_node **allnextp = &allnodes;
+
+ pr_debug(" -> unflatten_device_tree()\n");
+
+ /* First pass, scan for size */
+ start = ((unsigned long)initial_boot_params) +
+ initial_boot_params->off_dt_struct;
+ size = unflatten_dt_node(0, &start, NULL, NULL, 0);
+ size = (size | 3) + 1;
+
+ 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 = (unsigned long) __va(mem);
+
+ ((u32 *)mem)[size / 4] = 0xdeadbeef;
+
+ pr_debug(" unflattening %lx...\n", mem);
+
+ /* Second pass, do actual unflattening */
+ start = ((unsigned long)initial_boot_params) +
+ initial_boot_params->off_dt_struct;
+ unflatten_dt_node(mem, &start, NULL, &allnextp, 0);
+ if (*((u32 *)start) != OF_DT_END)
+ pr_warning("Weird tag at end of tree: %08x\n", *((u32 *)start));
+ if (((u32 *)mem)[size / 4] != 0xdeadbeef)
+ pr_warning("End of tree marker overwritten: %08x\n",
+ ((u32 *)mem)[size / 4]);
+ *allnextp = NULL;
+
+ /* Get pointer to OF "/chosen" node for use everywhere */
+ of_chosen = of_find_node_by_path("/chosen");
+ if (of_chosen == NULL)
+ of_chosen = of_find_node_by_path("/chosen@0");
+
+ pr_debug(" <- unflatten_device_tree()\n");
+}
diff --git a/include/linux/of.h b/include/linux/of.h
index e7facd8..bec2157 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -63,6 +63,9 @@ struct device_node {
#endif
};
+/* Pointer for first entry in chain of all nodes. */
+extern struct device_node *allnodes;
+
static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{
return test_bit(flag, &n->_flags);
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index ace9068..81231e0 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -69,10 +69,6 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long of_get_flat_dt_root(void);
-extern unsigned long unflatten_dt_node(unsigned long mem, unsigned long *p,
- struct device_node *dad,
- struct device_node ***allnextpp,
- unsigned long fpsize);
/* Other Prototypes */
extern void finish_device_tree(void);
^ permalink raw reply related
* [PATCH 07/11] of/flattree: Merge unflatten_dt_node
From: Grant Likely @ 2009-11-05 7:46 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and MicroBlaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/microblaze/kernel/prom.c | 195 ----------------------------------------
arch/powerpc/kernel/prom.c | 194 ----------------------------------------
drivers/of/fdt.c | 200 +++++++++++++++++++++++++++++++++++++++++
include/linux/of_fdt.h | 4 +
4 files changed, 204 insertions(+), 389 deletions(-)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index eb27bd3..021770a 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,201 +50,6 @@ typedef u32 cell_t;
/* export that to outside world */
struct device_node *of_chosen;
-static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
- unsigned long align)
-{
- void *res;
-
- *mem = _ALIGN(*mem, align);
- res = (void *)*mem;
- *mem += size;
-
- return res;
-}
-
-static unsigned long __init unflatten_dt_node(unsigned long mem,
- unsigned long *p,
- struct device_node *dad,
- struct device_node ***allnextpp,
- unsigned long fpsize)
-{
- struct device_node *np;
- struct property *pp, **prev_pp = NULL;
- char *pathp;
- u32 tag;
- unsigned int l, allocl;
- int has_name = 0;
- int new_format = 0;
-
- tag = *((u32 *)(*p));
- if (tag != OF_DT_BEGIN_NODE) {
- printk("Weird tag at start of node: %x\n", tag);
- return mem;
- }
- *p += 4;
- pathp = (char *)*p;
- l = allocl = strlen(pathp) + 1;
- *p = _ALIGN(*p + l, 4);
-
- /* version 0x10 has a more compact unit name here instead of the full
- * path. we accumulate the full path size using "fpsize", we'll rebuild
- * it later. We detect this because the first character of the name is
- * not '/'.
- */
- if ((*pathp) != '/') {
- new_format = 1;
- if (fpsize == 0) {
- /* root node: special case. fpsize accounts for path
- * plus terminating zero. root node only has '/', so
- * fpsize should be 2, but we want to avoid the first
- * level nodes to have two '/' so we use fpsize 1 here
- */
- fpsize = 1;
- allocl = 2;
- } else {
- /* account for '/' and path size minus terminal 0
- * already in 'l'
- */
- fpsize += l;
- allocl = fpsize;
- }
- }
-
- np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
- __alignof__(struct device_node));
- if (allnextpp) {
- memset(np, 0, sizeof(*np));
- np->full_name = ((char *)np) + sizeof(struct device_node);
- if (new_format) {
- char *p2 = np->full_name;
- /* rebuild full path for new format */
- if (dad && dad->parent) {
- strcpy(p2, dad->full_name);
-#ifdef DEBUG
- if ((strlen(p2) + l + 1) != allocl) {
- pr_debug("%s: p: %d, l: %d, a: %d\n",
- pathp, (int)strlen(p2),
- l, allocl);
- }
-#endif
- p2 += strlen(p2);
- }
- *(p2++) = '/';
- memcpy(p2, pathp, l);
- } else
- memcpy(np->full_name, pathp, l);
- prev_pp = &np->properties;
- **allnextpp = np;
- *allnextpp = &np->allnext;
- if (dad != NULL) {
- np->parent = dad;
- /* we temporarily use the next field as `last_child'*/
- if (dad->next == NULL)
- dad->child = np;
- else
- dad->next->sibling = np;
- dad->next = np;
- }
- kref_init(&np->kref);
- }
- while (1) {
- u32 sz, noff;
- char *pname;
-
- tag = *((u32 *)(*p));
- if (tag == OF_DT_NOP) {
- *p += 4;
- continue;
- }
- if (tag != OF_DT_PROP)
- break;
- *p += 4;
- sz = *((u32 *)(*p));
- noff = *((u32 *)((*p) + 4));
- *p += 8;
- if (initial_boot_params->version < 0x10)
- *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
-
- pname = find_flat_dt_string(noff);
- if (pname == NULL) {
- printk(KERN_INFO
- "Can't find property name in list !\n");
- break;
- }
- if (strcmp(pname, "name") == 0)
- has_name = 1;
- l = strlen(pname) + 1;
- pp = unflatten_dt_alloc(&mem, sizeof(struct property),
- __alignof__(struct property));
- if (allnextpp) {
- if (strcmp(pname, "linux,phandle") == 0) {
- np->node = *((u32 *)*p);
- if (np->linux_phandle == 0)
- np->linux_phandle = np->node;
- }
- if (strcmp(pname, "ibm,phandle") == 0)
- np->linux_phandle = *((u32 *)*p);
- pp->name = pname;
- pp->length = sz;
- pp->value = (void *)*p;
- *prev_pp = pp;
- prev_pp = &pp->next;
- }
- *p = _ALIGN((*p) + sz, 4);
- }
- /* with version 0x10 we may not have the name property, recreate
- * it here from the unit name if absent
- */
- if (!has_name) {
- char *p1 = pathp, *ps = pathp, *pa = NULL;
- int sz;
-
- while (*p1) {
- if ((*p1) == '@')
- pa = p1;
- if ((*p1) == '/')
- ps = p1 + 1;
- p1++;
- }
- if (pa < ps)
- pa = p1;
- sz = (pa - ps) + 1;
- pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
- __alignof__(struct property));
- if (allnextpp) {
- pp->name = "name";
- pp->length = sz;
- pp->value = pp + 1;
- *prev_pp = pp;
- prev_pp = &pp->next;
- memcpy(pp->value, ps, sz - 1);
- ((char *)pp->value)[sz - 1] = 0;
- pr_debug("fixed up name for %s -> %s\n", pathp,
- (char *)pp->value);
- }
- }
- if (allnextpp) {
- *prev_pp = NULL;
- np->name = of_get_property(np, "name", NULL);
- np->type = of_get_property(np, "device_type", NULL);
-
- if (!np->name)
- np->name = "<NULL>";
- if (!np->type)
- np->type = "<NULL>";
- }
- while (tag == OF_DT_BEGIN_NODE) {
- mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
- tag = *((u32 *)(*p));
- }
- if (tag != OF_DT_END_NODE) {
- printk(KERN_INFO "Weird tag at end of node: %x\n", tag);
- return mem;
- }
- *p += 4;
- return mem;
-}
-
/**
* unflattens the device-tree passed by the firmware, creating the
* tree of struct device_node. It also fills the "name" and "type"
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 413e608..a102a0a 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -80,200 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
struct device_node *of_chosen;
-static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
- unsigned long align)
-{
- void *res;
-
- *mem = _ALIGN(*mem, align);
- res = (void *)*mem;
- *mem += size;
-
- return res;
-}
-
-static unsigned long __init unflatten_dt_node(unsigned long mem,
- unsigned long *p,
- struct device_node *dad,
- struct device_node ***allnextpp,
- unsigned long fpsize)
-{
- struct device_node *np;
- struct property *pp, **prev_pp = NULL;
- char *pathp;
- u32 tag;
- unsigned int l, allocl;
- int has_name = 0;
- int new_format = 0;
-
- tag = *((u32 *)(*p));
- if (tag != OF_DT_BEGIN_NODE) {
- printk("Weird tag at start of node: %x\n", tag);
- return mem;
- }
- *p += 4;
- pathp = (char *)*p;
- l = allocl = strlen(pathp) + 1;
- *p = _ALIGN(*p + l, 4);
-
- /* version 0x10 has a more compact unit name here instead of the full
- * path. we accumulate the full path size using "fpsize", we'll rebuild
- * it later. We detect this because the first character of the name is
- * not '/'.
- */
- if ((*pathp) != '/') {
- new_format = 1;
- if (fpsize == 0) {
- /* root node: special case. fpsize accounts for path
- * plus terminating zero. root node only has '/', so
- * fpsize should be 2, but we want to avoid the first
- * level nodes to have two '/' so we use fpsize 1 here
- */
- fpsize = 1;
- allocl = 2;
- } else {
- /* account for '/' and path size minus terminal 0
- * already in 'l'
- */
- fpsize += l;
- allocl = fpsize;
- }
- }
-
-
- np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
- __alignof__(struct device_node));
- if (allnextpp) {
- memset(np, 0, sizeof(*np));
- np->full_name = ((char*)np) + sizeof(struct device_node);
- if (new_format) {
- char *p = np->full_name;
- /* rebuild full path for new format */
- if (dad && dad->parent) {
- strcpy(p, dad->full_name);
-#ifdef DEBUG
- if ((strlen(p) + l + 1) != allocl) {
- DBG("%s: p: %d, l: %d, a: %d\n",
- pathp, (int)strlen(p), l, allocl);
- }
-#endif
- p += strlen(p);
- }
- *(p++) = '/';
- memcpy(p, pathp, l);
- } else
- memcpy(np->full_name, pathp, l);
- prev_pp = &np->properties;
- **allnextpp = np;
- *allnextpp = &np->allnext;
- if (dad != NULL) {
- np->parent = dad;
- /* we temporarily use the next field as `last_child'*/
- if (dad->next == 0)
- dad->child = np;
- else
- dad->next->sibling = np;
- dad->next = np;
- }
- kref_init(&np->kref);
- }
- while(1) {
- u32 sz, noff;
- char *pname;
-
- tag = *((u32 *)(*p));
- if (tag == OF_DT_NOP) {
- *p += 4;
- continue;
- }
- if (tag != OF_DT_PROP)
- break;
- *p += 4;
- sz = *((u32 *)(*p));
- noff = *((u32 *)((*p) + 4));
- *p += 8;
- if (initial_boot_params->version < 0x10)
- *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
-
- pname = find_flat_dt_string(noff);
- if (pname == NULL) {
- printk("Can't find property name in list !\n");
- break;
- }
- if (strcmp(pname, "name") == 0)
- has_name = 1;
- l = strlen(pname) + 1;
- pp = unflatten_dt_alloc(&mem, sizeof(struct property),
- __alignof__(struct property));
- if (allnextpp) {
- if (strcmp(pname, "linux,phandle") == 0) {
- np->node = *((u32 *)*p);
- if (np->linux_phandle == 0)
- np->linux_phandle = np->node;
- }
- if (strcmp(pname, "ibm,phandle") == 0)
- np->linux_phandle = *((u32 *)*p);
- pp->name = pname;
- pp->length = sz;
- pp->value = (void *)*p;
- *prev_pp = pp;
- prev_pp = &pp->next;
- }
- *p = _ALIGN((*p) + sz, 4);
- }
- /* with version 0x10 we may not have the name property, recreate
- * it here from the unit name if absent
- */
- if (!has_name) {
- char *p = pathp, *ps = pathp, *pa = NULL;
- int sz;
-
- while (*p) {
- if ((*p) == '@')
- pa = p;
- if ((*p) == '/')
- ps = p + 1;
- p++;
- }
- if (pa < ps)
- pa = p;
- sz = (pa - ps) + 1;
- pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
- __alignof__(struct property));
- if (allnextpp) {
- pp->name = "name";
- pp->length = sz;
- pp->value = pp + 1;
- *prev_pp = pp;
- prev_pp = &pp->next;
- memcpy(pp->value, ps, sz - 1);
- ((char *)pp->value)[sz - 1] = 0;
- DBG("fixed up name for %s -> %s\n", pathp,
- (char *)pp->value);
- }
- }
- if (allnextpp) {
- *prev_pp = NULL;
- np->name = of_get_property(np, "name", NULL);
- np->type = of_get_property(np, "device_type", NULL);
-
- if (!np->name)
- np->name = "<NULL>";
- if (!np->type)
- np->type = "<NULL>";
- }
- while (tag == OF_DT_BEGIN_NODE) {
- mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
- tag = *((u32 *)(*p));
- }
- if (tag != OF_DT_END_NODE) {
- printk("Weird tag at end of node: %x\n", tag);
- return mem;
- }
- *p += 4;
- return mem;
-}
-
static int __init early_parse_mem(char *p)
{
if (!p)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 01a7f5f..df1ac8d 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -167,3 +167,203 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
return 0;
}
+static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
+ unsigned long align)
+{
+ void *res;
+
+ *mem = _ALIGN(*mem, align);
+ res = (void *)*mem;
+ *mem += size;
+
+ return res;
+}
+
+/**
+ * unflatten_dt_node - Alloc and populate a device_node from the flat tree
+ * @p: pointer to node in flat tree
+ * @dad: Parent struct device_node
+ * @allnextpp: pointer to ->allnext from last allocated device_node
+ * @fpsize: Size of the node path up at the current depth.
+ */
+unsigned long __init unflatten_dt_node(unsigned long mem,
+ unsigned long *p,
+ struct device_node *dad,
+ struct device_node ***allnextpp,
+ unsigned long fpsize)
+{
+ struct device_node *np;
+ struct property *pp, **prev_pp = NULL;
+ char *pathp;
+ u32 tag;
+ unsigned int l, allocl;
+ int has_name = 0;
+ int new_format = 0;
+
+ tag = *((u32 *)(*p));
+ if (tag != OF_DT_BEGIN_NODE) {
+ printk("Weird tag at start of node: %x\n", tag);
+ return mem;
+ }
+ *p += 4;
+ pathp = (char *)*p;
+ l = allocl = strlen(pathp) + 1;
+ *p = _ALIGN(*p + l, 4);
+
+ /* version 0x10 has a more compact unit name here instead of the full
+ * path. we accumulate the full path size using "fpsize", we'll rebuild
+ * it later. We detect this because the first character of the name is
+ * not '/'.
+ */
+ if ((*pathp) != '/') {
+ new_format = 1;
+ if (fpsize == 0) {
+ /* root node: special case. fpsize accounts for path
+ * plus terminating zero. root node only has '/', so
+ * fpsize should be 2, but we want to avoid the first
+ * level nodes to have two '/' so we use fpsize 1 here
+ */
+ fpsize = 1;
+ allocl = 2;
+ } else {
+ /* account for '/' and path size minus terminal 0
+ * already in 'l'
+ */
+ fpsize += l;
+ allocl = fpsize;
+ }
+ }
+
+ np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
+ __alignof__(struct device_node));
+ if (allnextpp) {
+ memset(np, 0, sizeof(*np));
+ np->full_name = ((char *)np) + sizeof(struct device_node);
+ if (new_format) {
+ char *fn = np->full_name;
+ /* rebuild full path for new format */
+ if (dad && dad->parent) {
+ strcpy(fn, dad->full_name);
+#ifdef DEBUG
+ if ((strlen(fn) + l + 1) != allocl) {
+ pr_debug("%s: p: %d, l: %d, a: %d\n",
+ pathp, (int)strlen(fn),
+ l, allocl);
+ }
+#endif
+ fn += strlen(fn);
+ }
+ *(fn++) = '/';
+ memcpy(fn, pathp, l);
+ } else
+ memcpy(np->full_name, pathp, l);
+ prev_pp = &np->properties;
+ **allnextpp = np;
+ *allnextpp = &np->allnext;
+ if (dad != NULL) {
+ np->parent = dad;
+ /* we temporarily use the next field as `last_child'*/
+ if (dad->next == NULL)
+ dad->child = np;
+ else
+ dad->next->sibling = np;
+ dad->next = np;
+ }
+ kref_init(&np->kref);
+ }
+ while (1) {
+ u32 sz, noff;
+ char *pname;
+
+ tag = *((u32 *)(*p));
+ if (tag == OF_DT_NOP) {
+ *p += 4;
+ continue;
+ }
+ if (tag != OF_DT_PROP)
+ break;
+ *p += 4;
+ sz = *((u32 *)(*p));
+ noff = *((u32 *)((*p) + 4));
+ *p += 8;
+ if (initial_boot_params->version < 0x10)
+ *p = _ALIGN(*p, sz >= 8 ? 8 : 4);
+
+ pname = find_flat_dt_string(noff);
+ if (pname == NULL) {
+ pr_info("Can't find property name in list !\n");
+ break;
+ }
+ if (strcmp(pname, "name") == 0)
+ has_name = 1;
+ l = strlen(pname) + 1;
+ pp = unflatten_dt_alloc(&mem, sizeof(struct property),
+ __alignof__(struct property));
+ if (allnextpp) {
+ if (strcmp(pname, "linux,phandle") == 0) {
+ np->node = *((u32 *)*p);
+ if (np->linux_phandle == 0)
+ np->linux_phandle = np->node;
+ }
+ if (strcmp(pname, "ibm,phandle") == 0)
+ np->linux_phandle = *((u32 *)*p);
+ pp->name = pname;
+ pp->length = sz;
+ pp->value = (void *)*p;
+ *prev_pp = pp;
+ prev_pp = &pp->next;
+ }
+ *p = _ALIGN((*p) + sz, 4);
+ }
+ /* with version 0x10 we may not have the name property, recreate
+ * it here from the unit name if absent
+ */
+ if (!has_name) {
+ char *p1 = pathp, *ps = pathp, *pa = NULL;
+ int sz;
+
+ while (*p1) {
+ if ((*p1) == '@')
+ pa = p1;
+ if ((*p1) == '/')
+ ps = p1 + 1;
+ p1++;
+ }
+ if (pa < ps)
+ pa = p1;
+ sz = (pa - ps) + 1;
+ pp = unflatten_dt_alloc(&mem, sizeof(struct property) + sz,
+ __alignof__(struct property));
+ if (allnextpp) {
+ pp->name = "name";
+ pp->length = sz;
+ pp->value = pp + 1;
+ *prev_pp = pp;
+ prev_pp = &pp->next;
+ memcpy(pp->value, ps, sz - 1);
+ ((char *)pp->value)[sz - 1] = 0;
+ pr_debug("fixed up name for %s -> %s\n", pathp,
+ (char *)pp->value);
+ }
+ }
+ if (allnextpp) {
+ *prev_pp = NULL;
+ np->name = of_get_property(np, "name", NULL);
+ np->type = of_get_property(np, "device_type", NULL);
+
+ if (!np->name)
+ np->name = "<NULL>";
+ if (!np->type)
+ np->type = "<NULL>";
+ }
+ while (tag == OF_DT_BEGIN_NODE) {
+ mem = unflatten_dt_node(mem, p, np, allnextpp, fpsize);
+ tag = *((u32 *)(*p));
+ }
+ if (tag != OF_DT_END_NODE) {
+ printk("Weird tag at end of node: %x\n", tag);
+ return mem;
+ }
+ *p += 4;
+ return mem;
+}
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 81231e0..ace9068 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -69,6 +69,10 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long of_get_flat_dt_root(void);
+extern unsigned long unflatten_dt_node(unsigned long mem, unsigned long *p,
+ struct device_node *dad,
+ struct device_node ***allnextpp,
+ unsigned long fpsize);
/* Other Prototypes */
extern void finish_device_tree(void);
^ permalink raw reply related
* [PATCH 06/11] of/flattree: Merge of_flat_dt_is_compatible
From: Grant Likely @ 2009-11-05 7:46 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and Microblaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/microblaze/kernel/prom.c | 19 -------------------
arch/powerpc/kernel/prom.c | 19 -------------------
drivers/of/fdt.c | 24 ++++++++++++++++++++++++
3 files changed, 24 insertions(+), 38 deletions(-)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index d75c625..eb27bd3 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,25 +50,6 @@ typedef u32 cell_t;
/* export that to outside world */
struct device_node *of_chosen;
-int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
-{
- const char *cp;
- unsigned long cplen, l;
-
- cp = of_get_flat_dt_prop(node, "compatible", &cplen);
- if (cp == NULL)
- return 0;
- while (cplen > 0) {
- if (strncasecmp(cp, compat, strlen(compat)) == 0)
- return 1;
- l = strlen(cp) + 1;
- cp += l;
- cplen -= l;
- }
-
- return 0;
-}
-
static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
unsigned long align)
{
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index cd0a2bf..413e608 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -80,25 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
struct device_node *of_chosen;
-int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
-{
- const char* cp;
- unsigned long cplen, l;
-
- cp = of_get_flat_dt_prop(node, "compatible", &cplen);
- if (cp == NULL)
- return 0;
- while (cplen > 0) {
- if (strncasecmp(cp, compat, strlen(compat)) == 0)
- return 1;
- l = strlen(cp) + 1;
- cp += l;
- cplen -= l;
- }
-
- return 0;
-}
-
static void *__init unflatten_dt_alloc(unsigned long *mem, unsigned long size,
unsigned long align)
{
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7a51343..01a7f5f 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -143,3 +143,27 @@ void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
} while (1);
}
+/**
+ * of_flat_dt_is_compatible - Return true if given node has compat in compatible list
+ * @node: node to test
+ * @compat: compatible string to compare with compatible list.
+ */
+int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
+{
+ const char *cp;
+ unsigned long cplen, l;
+
+ cp = of_get_flat_dt_prop(node, "compatible", &cplen);
+ if (cp == NULL)
+ return 0;
+ while (cplen > 0) {
+ if (strncasecmp(cp, compat, strlen(compat)) == 0)
+ return 1;
+ l = strlen(cp) + 1;
+ cp += l;
+ cplen -= l;
+ }
+
+ return 0;
+}
+
^ permalink raw reply related
* [PATCH 05/11] of/flattree: merge of_get_flat_dt_prop
From: Grant Likely @ 2009-11-05 7:46 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and Microblaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/microblaze/kernel/prom.c | 42 ----------------------------------------
arch/powerpc/kernel/prom.c | 42 ----------------------------------------
drivers/of/fdt.c | 43 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 84 deletions(-)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 7eb6f8b..d75c625 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,48 +50,6 @@ typedef u32 cell_t;
/* export that to outside world */
struct device_node *of_chosen;
-/**
- * This function can be used within scan_flattened_dt callback to get
- * access to properties
- */
-void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
- unsigned long *size)
-{
- unsigned long p = node;
-
- do {
- u32 tag = *((u32 *)p);
- u32 sz, noff;
- const char *nstr;
-
- p += 4;
- if (tag == OF_DT_NOP)
- continue;
- if (tag != OF_DT_PROP)
- return NULL;
-
- sz = *((u32 *)p);
- noff = *((u32 *)(p + 4));
- p += 8;
- if (initial_boot_params->version < 0x10)
- p = _ALIGN(p, sz >= 8 ? 8 : 4);
-
- nstr = find_flat_dt_string(noff);
- if (nstr == NULL) {
- printk(KERN_WARNING "Can't find property index"
- " name !\n");
- return NULL;
- }
- if (strcmp(name, nstr) == 0) {
- if (size)
- *size = sz;
- return (void *)p;
- }
- p += sz;
- p = _ALIGN(p, 4);
- } while (1);
-}
-
int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
{
const char *cp;
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index b5d5f85..cd0a2bf 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -80,48 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
struct device_node *of_chosen;
-/**
- * This function can be used within scan_flattened_dt callback to get
- * access to properties
- */
-void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
- unsigned long *size)
-{
- unsigned long p = node;
-
- do {
- u32 tag = *((u32 *)p);
- u32 sz, noff;
- const char *nstr;
-
- p += 4;
- if (tag == OF_DT_NOP)
- continue;
- if (tag != OF_DT_PROP)
- return NULL;
-
- sz = *((u32 *)p);
- noff = *((u32 *)(p + 4));
- p += 8;
- if (initial_boot_params->version < 0x10)
- p = _ALIGN(p, sz >= 8 ? 8 : 4);
-
- nstr = find_flat_dt_string(noff);
- if (nstr == NULL) {
- printk(KERN_WARNING "Can't find property index"
- " name !\n");
- return NULL;
- }
- if (strcmp(name, nstr) == 0) {
- if (size)
- *size = sz;
- return (void *)p;
- }
- p += sz;
- p = _ALIGN(p, 4);
- } while(1);
-}
-
int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
{
const char* cp;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a6e869e..7a51343 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -100,3 +100,46 @@ unsigned long __init of_get_flat_dt_root(void)
return _ALIGN(p + strlen((char *)p) + 1, 4);
}
+/**
+ * of_get_flat_dt_prop - Given a node in the flat blob, return the property pointer
+ *
+ * This function can be used within scan_flattened_dt callback to get
+ * access to properties
+ */
+void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
+ unsigned long *size)
+{
+ unsigned long p = node;
+
+ do {
+ u32 tag = *((u32 *)p);
+ u32 sz, noff;
+ const char *nstr;
+
+ p += 4;
+ if (tag == OF_DT_NOP)
+ continue;
+ if (tag != OF_DT_PROP)
+ return NULL;
+
+ sz = *((u32 *)p);
+ noff = *((u32 *)(p + 4));
+ p += 8;
+ if (initial_boot_params->version < 0x10)
+ p = _ALIGN(p, sz >= 8 ? 8 : 4);
+
+ nstr = find_flat_dt_string(noff);
+ if (nstr == NULL) {
+ pr_warning("Can't find property index name !\n");
+ return NULL;
+ }
+ if (strcmp(name, nstr) == 0) {
+ if (size)
+ *size = sz;
+ return (void *)p;
+ }
+ p += sz;
+ p = _ALIGN(p, 4);
+ } while (1);
+}
+
^ permalink raw reply related
* [PATCH 04/11] of/flattree: remove __init annotations from the header file
From: Grant Likely @ 2009-11-05 7:46 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
__init annotation belongs in the .c file, not the header.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
include/linux/of_fdt.h | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index d1a79f3..81231e0 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -62,15 +62,13 @@ extern struct boot_param_header *initial_boot_params;
/* For scanning the flat device-tree at boot time */
extern char *find_flat_dt_string(u32 offset);
-extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
- const char *uname, int depth,
- void *data),
- void *data);
-extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name,
- unsigned long *size);
-extern int __init of_flat_dt_is_compatible(unsigned long node,
- const char *name);
-extern unsigned long __init of_get_flat_dt_root(void);
+extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
+ int depth, void *data),
+ void *data);
+extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
+ unsigned long *size);
+extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
+extern unsigned long of_get_flat_dt_root(void);
/* Other Prototypes */
extern void finish_device_tree(void);
^ permalink raw reply related
* [PATCH 03/11] of/flattree: merge of_get_flat_dt_root
From: Grant Likely @ 2009-11-05 7:45 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and MicroBlaze
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/microblaze/kernel/prom.c | 12 ------------
arch/powerpc/kernel/prom.c | 12 ------------
drivers/of/fdt.c | 16 ++++++++++++++++
3 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 0db8ee6..7eb6f8b 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,18 +50,6 @@ typedef u32 cell_t;
/* export that to outside world */
struct device_node *of_chosen;
-unsigned long __init of_get_flat_dt_root(void)
-{
- unsigned long p = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
-
- while (*((u32 *)p) == OF_DT_NOP)
- p += 4;
- BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
- p += 4;
- return _ALIGN(p + strlen((char *)p) + 1, 4);
-}
-
/**
* This function can be used within scan_flattened_dt callback to get
* access to properties
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 14a07b9..b5d5f85 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -80,18 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
struct device_node *of_chosen;
-unsigned long __init of_get_flat_dt_root(void)
-{
- unsigned long p = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
-
- while(*((u32 *)p) == OF_DT_NOP)
- p += 4;
- BUG_ON (*((u32 *)p) != OF_DT_BEGIN_NODE);
- p += 4;
- return _ALIGN(p + strlen((char *)p) + 1, 4);
-}
-
/**
* This function can be used within scan_flattened_dt callback to get
* access to properties
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7c3c13c..a6e869e 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -84,3 +84,19 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
return rc;
}
+
+/**
+ * of_get_flat_dt_root - find the root node in the flat blob
+ */
+unsigned long __init of_get_flat_dt_root(void)
+{
+ unsigned long p = ((unsigned long)initial_boot_params) +
+ initial_boot_params->off_dt_struct;
+
+ while (*((u32 *)p) == OF_DT_NOP)
+ p += 4;
+ BUG_ON(*((u32 *)p) != OF_DT_BEGIN_NODE);
+ p += 4;
+ return _ALIGN(p + strlen((char *)p) + 1, 4);
+}
+
^ permalink raw reply related
* [PATCH 02/11] of/flattree: merge of_scan_flat_dt
From: Grant Likely @ 2009-11-05 7:45 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between PowerPC and Microblaze
---
arch/microblaze/kernel/prom.c | 61 --------------------------------------
arch/powerpc/kernel/prom.c | 61 --------------------------------------
drivers/of/fdt.c | 65 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 65 insertions(+), 122 deletions(-)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 06d620a..0db8ee6 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,67 +50,6 @@ typedef u32 cell_t;
/* export that to outside world */
struct device_node *of_chosen;
-/**
- * This function is used to scan the flattened device-tree, it is
- * used to extract the memory informations at boot before we can
- * unflatten the tree
- */
-int __init of_scan_flat_dt(int (*it)(unsigned long node,
- const char *uname, int depth,
- void *data),
- void *data)
-{
- unsigned long p = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
- int rc = 0;
- int depth = -1;
-
- do {
- u32 tag = *((u32 *)p);
- char *pathp;
-
- p += 4;
- if (tag == OF_DT_END_NODE) {
- depth--;
- continue;
- }
- if (tag == OF_DT_NOP)
- continue;
- if (tag == OF_DT_END)
- break;
- if (tag == OF_DT_PROP) {
- u32 sz = *((u32 *)p);
- p += 8;
- if (initial_boot_params->version < 0x10)
- p = _ALIGN(p, sz >= 8 ? 8 : 4);
- p += sz;
- p = _ALIGN(p, 4);
- continue;
- }
- if (tag != OF_DT_BEGIN_NODE) {
- printk(KERN_WARNING "Invalid tag %x scanning flattened"
- " device tree !\n", tag);
- return -EINVAL;
- }
- depth++;
- pathp = (char *)p;
- p = _ALIGN(p + strlen(pathp) + 1, 4);
- if ((*pathp) == '/') {
- char *lp, *np;
- for (lp = NULL, np = pathp; *np; np++)
- if ((*np) == '/')
- lp = np+1;
- if (lp != NULL)
- pathp = lp;
- }
- rc = it(p, pathp, depth, data);
- if (rc != 0)
- break;
- } while (1);
-
- return rc;
-}
-
unsigned long __init of_get_flat_dt_root(void)
{
unsigned long p = ((unsigned long)initial_boot_params) +
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index fccf7e4..14a07b9 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -80,67 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
struct device_node *of_chosen;
-/**
- * This function is used to scan the flattened device-tree, it is
- * used to extract the memory informations at boot before we can
- * unflatten the tree
- */
-int __init of_scan_flat_dt(int (*it)(unsigned long node,
- const char *uname, int depth,
- void *data),
- void *data)
-{
- unsigned long p = ((unsigned long)initial_boot_params) +
- initial_boot_params->off_dt_struct;
- int rc = 0;
- int depth = -1;
-
- do {
- u32 tag = *((u32 *)p);
- char *pathp;
-
- p += 4;
- if (tag == OF_DT_END_NODE) {
- depth --;
- continue;
- }
- if (tag == OF_DT_NOP)
- continue;
- if (tag == OF_DT_END)
- break;
- if (tag == OF_DT_PROP) {
- u32 sz = *((u32 *)p);
- p += 8;
- if (initial_boot_params->version < 0x10)
- p = _ALIGN(p, sz >= 8 ? 8 : 4);
- p += sz;
- p = _ALIGN(p, 4);
- continue;
- }
- if (tag != OF_DT_BEGIN_NODE) {
- printk(KERN_WARNING "Invalid tag %x scanning flattened"
- " device tree !\n", tag);
- return -EINVAL;
- }
- depth++;
- pathp = (char *)p;
- p = _ALIGN(p + strlen(pathp) + 1, 4);
- if ((*pathp) == '/') {
- char *lp, *np;
- for (lp = NULL, np = pathp; *np; np++)
- if ((*np) == '/')
- lp = np+1;
- if (lp != NULL)
- pathp = lp;
- }
- rc = it(p, pathp, depth, data);
- if (rc != 0)
- break;
- } while(1);
-
- return rc;
-}
-
unsigned long __init of_get_flat_dt_root(void)
{
unsigned long p = ((unsigned long)initial_boot_params) +
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 9faa9a5..7c3c13c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -19,3 +19,68 @@ char *find_flat_dt_string(u32 offset)
return ((char *)initial_boot_params) +
initial_boot_params->off_dt_strings + offset;
}
+
+/**
+ * of_scan_flat_dt - scan flattend tree blob and call callback on each.
+ * @it: callback function
+ * @data: context data pointer
+ *
+ * This function is used to scan the flattened device-tree, it is
+ * used to extract the memory informations at boot before we can
+ * unflatten the tree
+ */
+int __init of_scan_flat_dt(int (*it)(unsigned long node,
+ const char *uname, int depth,
+ void *data),
+ void *data)
+{
+ unsigned long p = ((unsigned long)initial_boot_params) +
+ initial_boot_params->off_dt_struct;
+ int rc = 0;
+ int depth = -1;
+
+ do {
+ u32 tag = *((u32 *)p);
+ char *pathp;
+
+ p += 4;
+ if (tag == OF_DT_END_NODE) {
+ depth--;
+ continue;
+ }
+ if (tag == OF_DT_NOP)
+ continue;
+ if (tag == OF_DT_END)
+ break;
+ if (tag == OF_DT_PROP) {
+ u32 sz = *((u32 *)p);
+ p += 8;
+ if (initial_boot_params->version < 0x10)
+ p = _ALIGN(p, sz >= 8 ? 8 : 4);
+ p += sz;
+ p = _ALIGN(p, 4);
+ continue;
+ }
+ if (tag != OF_DT_BEGIN_NODE) {
+ printk(KERN_WARNING "Invalid tag %x scanning flattened"
+ " device tree !\n", tag);
+ return -EINVAL;
+ }
+ depth++;
+ pathp = (char *)p;
+ p = _ALIGN(p + strlen(pathp) + 1, 4);
+ if ((*pathp) == '/') {
+ char *lp, *np;
+ for (lp = NULL, np = pathp; *np; np++)
+ if ((*np) == '/')
+ lp = np+1;
+ if (lp != NULL)
+ pathp = lp;
+ }
+ rc = it(p, pathp, depth, data);
+ if (rc != 0)
+ break;
+ } while (1);
+
+ return rc;
+}
^ permalink raw reply related
* [PATCH 01/11] of/flattree: merge find_flat_dt_string and initial_boot_params
From: Grant Likely @ 2009-11-05 7:45 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
In-Reply-To: <20091105073728.10460.6061.stgit@angua>
Merge common code between Microblaze and PowerPC. Also move instance of
---
arch/microblaze/Kconfig | 1 +
arch/microblaze/kernel/prom.c | 8 --------
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/prom.c | 12 ------------
drivers/of/Kconfig | 4 ++++
drivers/of/Makefile | 1 +
drivers/of/fdt.c | 21 +++++++++++++++++++++
include/linux/of_fdt.h | 4 ++++
8 files changed, 32 insertions(+), 20 deletions(-)
create mode 100644 drivers/of/fdt.c
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index bbd8327..f39c927 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -111,6 +111,7 @@ config CMDLINE_FORCE
config OF
def_bool y
+ select OF_FLATTREE
config PROC_DEVICETREE
bool "Support for device tree in /proc"
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index b817df1..06d620a 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -47,17 +47,9 @@ static int __initdata dt_root_size_cells;
typedef u32 cell_t;
-static struct boot_param_header *initial_boot_params;
-
/* export that to outside world */
struct device_node *of_chosen;
-static inline char *find_flat_dt_string(u32 offset)
-{
- return ((char *)initial_boot_params) +
- initial_boot_params->off_dt_strings + offset;
-}
-
/**
* This function is used to scan the flattened device-tree, it is
* used to extract the memory informations at boot before we can
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 10a0a54..5f6eed9 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -163,6 +163,7 @@ config PPC_OF
config OF
def_bool y
+ select OF_FLATTREE
config PPC_UDBG_16550
bool
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 4ec3008..fccf7e4 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -73,12 +73,6 @@ unsigned long tce_alloc_start, tce_alloc_end;
typedef u32 cell_t;
-#if 0
-static struct boot_param_header *initial_boot_params __initdata;
-#else
-struct boot_param_header *initial_boot_params;
-#endif
-
extern struct device_node *allnodes; /* temporary while merging */
extern rwlock_t devtree_lock; /* temporary while merging */
@@ -86,12 +80,6 @@ extern rwlock_t devtree_lock; /* temporary while merging */
/* export that to outside world */
struct device_node *of_chosen;
-static inline char *find_flat_dt_string(u32 offset)
-{
- return ((char *)initial_boot_params) +
- initial_boot_params->off_dt_strings + offset;
-}
-
/**
* This function is used to scan the flattened device-tree, it is
* used to extract the memory informations at boot before we can
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index d2fa27c..462825e 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -1,3 +1,7 @@
+config OF_FLATTREE
+ bool
+ depends on OF
+
config OF_DEVICE
def_bool y
depends on OF && (SPARC || PPC_OF || MICROBLAZE)
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index bdfb5f5..f232cc9 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,4 +1,5 @@
obj-y = base.o
+obj-$(CONFIG_OF_FLATTREE) += fdt.o
obj-$(CONFIG_OF_DEVICE) += device.o platform.o
obj-$(CONFIG_OF_GPIO) += gpio.o
obj-$(CONFIG_OF_I2C) += of_i2c.o
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
new file mode 100644
index 0000000..9faa9a5
--- /dev/null
+++ b/drivers/of/fdt.c
@@ -0,0 +1,21 @@
+/*
+ * Functions for working with the Flattened Device Tree data format
+ *
+ * Copyright 2009 Benjamin Herrenschmidt, IBM Corp
+ * benh@kernel.crashing.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+struct boot_param_header *initial_boot_params;
+
+char *find_flat_dt_string(u32 offset)
+{
+ return ((char *)initial_boot_params) +
+ initial_boot_params->off_dt_strings + offset;
+}
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 41d432b..d1a79f3 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -57,7 +57,11 @@ struct boot_param_header {
u32 dt_struct_size; /* size of the DT structure block */
};
+/* TBD: Temporary export of fdt globals - remove when code fully merged */
+extern struct boot_param_header *initial_boot_params;
+
/* For scanning the flat device-tree at boot time */
+extern char *find_flat_dt_string(u32 offset);
extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
const char *uname, int depth,
void *data),
^ permalink raw reply related
* [PATCH 00/11] More OF merge patches
From: Grant Likely @ 2009-11-05 7:45 UTC (permalink / raw)
To: linuxppc-dev, devicetree-discuss, benh, sfr, davem, sparclinux,
monstr, microblaze-uclinux
Round 2. Here is my 2nd set of merging OF code between PowerPC and
Microblaze (no SPARC changes this time). Compile tested on ppc,
microblaze and sparc. Boot tested on MPC5200 powerpc platform.
I've also pushed this series out to the test-devicetree branch on my
git server if anyone cares to pull and test:
git://git.secretlab.ca/git/linux-2.6 test-devicetree
This is based on the next-devicetree branch which contains the first
round of patches and is being pulled into linux-next.
Cheers,
g.
---
Grant Likely (11):
of/flattree: Merge early_init_dt_check_for_initrd()
of: remove special case definition of of_read_ulong()
of: merge prom_{add,remove,modify}_property
of/flattree: Merge unflatten_device_tree
of/flattree: Merge unflatten_dt_node
of/flattree: Merge of_flat_dt_is_compatible
of/flattree: merge of_get_flat_dt_prop
of/flattree: remove __init annotations from the header file
of/flattree: merge of_get_flat_dt_root
of/flattree: merge of_scan_flat_dt
of/flattree: merge find_flat_dt_string and initial_boot_params
arch/microblaze/Kconfig | 1
arch/microblaze/include/asm/prom.h | 1
arch/microblaze/kernel/prom.c | 531 ------------------------------------
arch/powerpc/Kconfig | 1
arch/powerpc/kernel/prom.c | 534 ------------------------------------
drivers/of/Kconfig | 4
drivers/of/Makefile | 1
drivers/of/base.c | 116 ++++++++
drivers/of/fdt.c | 458 +++++++++++++++++++++++++++++++
include/linux/of.h | 10 -
include/linux/of_fdt.h | 21 +
11 files changed, 598 insertions(+), 1080 deletions(-)
create mode 100644 drivers/of/fdt.c
^ permalink raw reply
* [git pull] Please pull powerpc.git merge branch
From: Benjamin Herrenschmidt @ 2009-11-05 7:07 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Andrew Morton, linuxppc-dev list, Linux Kernel list
Hi Linus !
Here are some small bits for .32
The Kconfig cleanup you asked for hugetlbfs selection, a few regression
fixes and an actual bug fix that I decided was worth putting in now
(the RTC dates thingy)
Cheers,
Ben.
The following changes since commit 2e2ec952350f25242f2e0539db16b1e46f9eb01b:
Linus Torvalds (1):
Merge branch 'bugfix' of git://git.kernel.org/.../jeremy/xen
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc.git merge
Andre Detsch (1):
powerpc/pci: Fix regression in powerpc MSI-X
Benjamin Herrenschmidt (4):
powerpc: Cleanup Kconfig selection of hugetlbfs support
powerpc/mm: Remove debug context clamping from nohash code
powerpc: Avoid giving out RTC dates below EPOCH
powerpc/kvm: Remove problematic BUILD_BUG_ON statement
arch/powerpc/Kconfig | 4 ++++
arch/powerpc/kernel/time.c | 15 ++++++++++++++-
arch/powerpc/kvm/timing.h | 4 ++++
arch/powerpc/mm/mmu_context_nohash.c | 4 ++--
arch/powerpc/platforms/pseries/msi.c | 2 --
arch/powerpc/platforms/pseries/xics.c | 9 +++++++++
fs/Kconfig | 2 +-
7 files changed, 34 insertions(+), 6 deletions(-)
^ permalink raw reply
* Re: [PATCH] BUILD_BUG_ON: make it handle more cases
From: Stephen Rothwell @ 2009-11-05 6:38 UTC (permalink / raw)
To: Rusty Russell
Cc: Hollis Blanchard, linux-kernel, kvm-ppc, linux-next, Jan Beulich,
akpm, linuxppc-dev
In-Reply-To: <200911051658.36265.rusty@rustcorp.com.au>
[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]
Hi Rusty,
On Thu, 5 Nov 2009 16:58:36 +1030 Rusty Russell <rusty@rustcorp.com.au> wrote:
>
> Huh? virtio_has_feature does:
>
> if (__builtin_constant_p(fbit))
> BUILD_BUG_ON(fbit >= 32);
> else
> BUG_ON(fbit >= 32);
In Linus' tree (and linux-next) it looks like this:
static inline bool virtio_has_feature(const struct virtio_device *vdev,
unsigned int fbit)
{
/* Did you forget to fix assumptions on max features? */
MAYBE_BUILD_BUG_ON(fbit >= 32);
if (fbit < VIRTIO_TRANSPORT_F_START)
virtio_check_driver_offered_feature(vdev, fbit);
return test_bit(fbit, vdev->features);
}
> So, if it's not a constant, gcc should throw away that first branch. If it
> is, it should optimize it away (and no, these are not real bugs AFAICT).
Your version above may well fix the problem. Alternatively marking it
__always_inline way work as well.
> I did a 4.3.3 allmodconfig with this patch on 64-bit a few days back and all
> was fine. Will try 4.4.0 now.
4.4 is more problematic.
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [PATCH] BUILD_BUG_ON: make it handle more cases
From: Rusty Russell @ 2009-11-05 6:37 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Hollis Blanchard, linux-kernel, kvm-ppc, linux-next, Jan Beulich,
akpm, linuxppc-dev
In-Reply-To: <200911051658.36265.rusty@rustcorp.com.au>
On Thu, 5 Nov 2009 04:58:36 pm Rusty Russell wrote:
> I did a 4.3.3 allmodconfig with this patch on 64-bit a few days back and all
> was fine. Will try 4.4.0 now.
4.4.1 seems OK (Ubuntu).
This is annoying. But I'll withdraw the patches; if there's another reason
that 4.4.0 is bad, we can ban it and reintroduce this. I don't think that
breaking this hack is enough to declare 4.4.0 verboten.
Thanks,
Rusty.
^ permalink raw reply
* Re: [PATCH] BUILD_BUG_ON: make it handle more cases
From: Rusty Russell @ 2009-11-05 6:28 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Hollis Blanchard, linux-kernel, kvm-ppc, linux-next, Jan Beulich,
akpm, linuxppc-dev
In-Reply-To: <20091105112020.33f02552.sfr@canb.auug.org.au>
On Thu, 5 Nov 2009 10:50:20 am Stephen Rothwell wrote:
> Hi Rusty,
>
> On Tue, 20 Oct 2009 14:15:33 +1030 Rusty Russell <rusty@rustcorp.com.au> wrote:
> >
> > +#ifndef __OPTIMIZE__
> > +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
> > +#else
> > +extern int __build_bug_on_failed;
> > +#define BUILD_BUG_ON(condition) \
> > + do { \
> > + ((void)sizeof(char[1 - 2*!!(condition)])); \
> > + if (condition) __build_bug_on_failed = 1; \
> > + } while(0)
> > +#endif
> > +#define MAYBE_BUILD_BUG_ON(condition) BUILD_BUG_ON(condition)
> > +
>
> I decided to try this in linux-next, but an x86_64 allmodconfig build
> gave this (gcc 4.4.0):
>
> ERROR: "__build_bug_on_failed" [drivers/net/virtio_net.ko] undefined!
> ERROR: "__build_bug_on_failed" [drivers/block/virtio_blk.ko] undefined!
>
> I assume that this is caused by the "MAYBE_BUILD_BUG_ON(fbit >= 32)" in
> virtio_has_feature() (in include/linux/virtio_config.h) which is called
> all over the place. Unfortunately, virtio_has_feature() gets uninlined
> in those two files ...
Huh? virtio_has_feature does:
if (__builtin_constant_p(fbit))
BUILD_BUG_ON(fbit >= 32);
else
BUG_ON(fbit >= 32);
So, if it's not a constant, gcc should throw away that first branch. If it
is, it should optimize it away (and no, these are not real bugs AFAICT).
I did a 4.3.3 allmodconfig with this patch on 64-bit a few days back and all
was fine. Will try 4.4.0 now.
Thanks,
Rusty.
^ permalink raw reply
* [PATCH] powerpc/kvm: Fix non-modular build
From: Benjamin Herrenschmidt @ 2009-11-05 6:18 UTC (permalink / raw)
To: kvmppc, linuxppc-dev; +Cc: Hollis Blanchard
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/kvm/timing.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/kvm/timing.c b/arch/powerpc/kvm/timing.c
index 2aa371e..7037855 100644
--- a/arch/powerpc/kvm/timing.c
+++ b/arch/powerpc/kvm/timing.c
@@ -23,6 +23,7 @@
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <linux/uaccess.h>
+#include <linux/module.h>
#include <asm/time.h>
#include <asm-generic/div64.h>
^ permalink raw reply related
* [PATCH] powerpc/kvm: Remove problematic BUILD_BUG_ON statement
From: Benjamin Herrenschmidt @ 2009-11-05 6:12 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Hollis Blanchard, kvm-ppc
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
I'm going to stick this into my -merge branch and send it to Linus today
until we fix it for real
diff --git a/arch/powerpc/kvm/timing.h b/arch/powerpc/kvm/timing.h
index bb13b1f..806ef67 100644
--- a/arch/powerpc/kvm/timing.h
+++ b/arch/powerpc/kvm/timing.h
@@ -48,7 +48,11 @@ static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
{
/* type has to be known at build time for optimization */
+
+ /* The BUILD_BUG_ON below breaks in funny ways, commented out
+ * for now ... -BenH
BUILD_BUG_ON(__builtin_constant_p(type));
+ */
switch (type) {
case EXT_INTR_EXITS:
vcpu->stat.ext_intr_exits++;
^ permalink raw reply related
* 2.6.33 -next tree
From: Grant Likely @ 2009-11-05 6:10 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Andrew Morton, linuxppc-dev; +Cc: David Brownell
Hi Ben, Stephen.
I just prepared my next branch for 2.6.33:
git://git.secretlab.ca/git/linux-2.6 next
Steven, can you please add this tree to your linux-next pull list?
This is the branch where I put stuff that gets fed up to Ben. This is
separate from the branch that I'm using to collect OF related changes
and that you are already pulling in.
Ben, can you please pull this branch into your -next tree for 2.6.33?
Andrew & David, you'll notice that I've also got some SPI and MMC
changes in this branch (PPC and OF related stuff) since there is no
current MMC maintainer, and some of these SPI patches have been
hanging around for a while now. Let me know if you object to me
pushing these changes personally instead of going through another
maintainer.
Thanks,
g.
The following changes since commit b419148e567728f6af0c3b01965c1cc141e3e13a=
:
Linus Torvalds (1):
Linux 2.6.32-rc6
are available in the git repository at:
git://git.secretlab.ca/git/linux-2.6 next
Albrecht Dre=DF (1):
powerpc: tiny memcpy_(to|from)io optimisation
Grant Likely (4):
spi/mpc5200: Register SPI devices described in device tree
powerpc/5200: Add mpc5200-spi (non-PSC) device driver
powerpc/5200: add general purpose timer API for the MPC5200
mmc: fix missing module license declaration in of_mmc_spi.c
John Bonesio (1):
powerpc/5200: add LocalPlus bus FIFO device driver
John Linn (1):
Xilinx: SPI: Fix bits_per_word for transfers
Wolfram Sang (2):
spi/mpc52xx-psc-spi: check for valid PSC
spi/mpc52xx: replace printk with dev_err
arch/powerpc/include/asm/mpc52xx.h | 46 ++
arch/powerpc/kernel/io.c | 4 +-
arch/powerpc/platforms/52xx/Kconfig | 5 +
arch/powerpc/platforms/52xx/Makefile | 1 +
arch/powerpc/platforms/52xx/mpc52xx_gpt.c | 133 ++++++-
arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c | 560 +++++++++++++++++++++=
++++
drivers/mmc/host/of_mmc_spi.c | 2 +
drivers/spi/Kconfig | 8 +
drivers/spi/Makefile | 1 +
drivers/spi/mpc52xx_psc_spi.c | 25 +-
drivers/spi/mpc52xx_spi.c | 520 +++++++++++++++++++++=
++
drivers/spi/xilinx_spi.c | 3 +-
include/linux/spi/mpc52xx_spi.h | 10 +
13 files changed, 1297 insertions(+), 21 deletions(-)
create mode 100644 arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c
create mode 100644 drivers/spi/mpc52xx_spi.c
create mode 100644 include/linux/spi/mpc52xx_spi.h
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply
* Re: [PATCH 00/27] Add KVM support for Book3s_64 (PPC64) hosts v6
From: Benjamin Herrenschmidt @ 2009-11-05 6:03 UTC (permalink / raw)
To: Alexander Graf
Cc: Kevin Wolf, Arnd Bergmann, Hollis Blanchard, Marcelo Tosatti,
kvm-ppc, linuxppc-dev, Avi Kivity, kvm, bphilips, Olof Johansson
In-Reply-To: <1256917647-6200-1-git-send-email-agraf@suse.de>
On Fri, 2009-10-30 at 16:47 +0100, Alexander Graf wrote:
> KVM for PowerPC only supports embedded cores at the moment.
>
> While it makes sense to virtualize on small machines, it's even more fun
> to do so on big boxes. So I figured we need KVM for PowerPC64 as well.
I get that with exit timing enabled:
arch/powerpc/kvm/timing.c:205: error: ‘THIS_MODULE’ undeclared here (not in a function)
I'll stick a fixup patch in my tree (just adding #include <linux/module.h>)
Cheers,
Ben.
^ permalink raw reply
* Re: [PATCH] BUILD_BUG_ON: make it handle more cases
From: Benjamin Herrenschmidt @ 2009-11-05 6:01 UTC (permalink / raw)
To: Rusty Russell
Cc: sfr, Hollis Blanchard, linux-kernel, kvm-ppc, linux-next,
Jan Beulich, akpm, linuxppc-dev
In-Reply-To: <200910201415.34361.rusty@rustcorp.com.au>
On Tue, 2009-10-20 at 14:15 +1030, Rusty Russell wrote:
> BUILD_BUG_ON used to use the optimizer to do code elimination or fail
> at link time; it was changed to first the size of a negative array (a
> nicer compile time error), then (in
> 8c87df457cb58fe75b9b893007917cf8095660a0) to a bitfield.
What's the status with this patch ? The lack of it breaks my KVM stuff
in powerpc...
Cheers,
Ben.
> bitfields: needs a literal constant at parse time, and can't be put under
> "if (__builtin_constant_p(x))" for example.
> negative array: can handle anything, but if the compiler can't tell it's
> a constant, silently has no effect.
> link time: breaks link if the compiler can't determine the value, but the
> linker output is not usually as informative as a compiler error.
>
> If we use the negative-array-size method *and* the link time trick,
> we get the ability to use BUILD_BUG_ON() under __builtin_constant_p()
> branches, and maximal ability for the compiler to detect errors at
> build time.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -683,12 +683,6 @@ struct sysinfo {
> char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
> };
>
> -/* Force a compilation error if condition is true */
> -#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
> -
> -/* Force a compilation error if condition is constant and true */
> -#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
> -
> /* Force a compilation error if condition is true, but also produce a
> result (of value 0 and type size_t), so the expression can be used
> e.g. in a structure initializer (or where-ever else comma expressions
> @@ -696,6 +690,33 @@ struct sysinfo {
> #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
> #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
>
> +/**
> + * BUILD_BUG_ON - break compile if a condition is true.
> + * @cond: the condition which the compiler should know is false.
> + *
> + * If you have some code which relies on certain constants being equal, or
> + * other compile-time-evaluated condition, you should use BUILD_BUG_ON to
> + * detect if someone changes it.
> + *
> + * The implementation uses gcc's reluctance to create a negative array, but
> + * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
> + * to inline functions). So as a fallback we use the optimizer; if it can't
> + * prove the condition is false, it will cause a link error on the undefined
> + * "__build_bug_on_failed". This error message can be harder to track down
> + * though, hence the two different methods.
> + */
> +#ifndef __OPTIMIZE__
> +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
> +#else
> +extern int __build_bug_on_failed;
> +#define BUILD_BUG_ON(condition) \
> + do { \
> + ((void)sizeof(char[1 - 2*!!(condition)])); \
> + if (condition) __build_bug_on_failed = 1; \
> + } while(0)
> +#endif
> +#define MAYBE_BUILD_BUG_ON(condition) BUILD_BUG_ON(condition)
> +
> /* Trap pasters of __FUNCTION__ at compile-time */
> #define __FUNCTION__ (__func__)
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply
* Re: [PATCH] PCI: Fix regression in powerpc MSI-X
From: Benjamin Herrenschmidt @ 2009-11-05 5:43 UTC (permalink / raw)
To: Andre Detsch; +Cc: linuxppc-dev
In-Reply-To: <200911041303.19695.adetsch@br.ibm.com>
On Wed, 2009-11-04 at 13:03 -0200, Andre Detsch wrote:
> Patch f598282f5145036312d90875d0ed5c14b49fd8a7 exposed a problem in
> powerpc MSI-X functionality, making network interfaces such as ixgbe
> and cxgb3 stop to work when MSI-X is enabled. RX interrupts were not
> being generated.
>
> The problem was caused because MSI irq was not being effectively
> unmasked after device initialization.
Patch is wrapped...
Ben.
> Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
>
> Index: linux-2.6/arch/powerpc/platforms/pseries/msi.c
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/platforms/pseries/msi.c 2009-11-04
> 06:35:39.000000000 -0700
> +++ linux-2.6/arch/powerpc/platforms/pseries/msi.c 2009-11-04
> 07:23:27.000000000 -0700
> @@ -432,8 +432,6 @@ static int rtas_setup_msi_irqs(struct pc
> /* Read config space back so we can restore after reset */
> read_msi_msg(virq, &msg);
> entry->msg = msg;
> -
> - unmask_msi_irq(virq);
> }
>
> return 0;
> Index: linux-2.6/arch/powerpc/platforms/pseries/xics.c
> ===================================================================
> --- linux-2.6.orig/arch/powerpc/platforms/pseries/xics.c 2009-11-04
> 06:35:39.000000000 -0700
> +++ linux-2.6/arch/powerpc/platforms/pseries/xics.c 2009-11-04
> 07:23:27.000000000 -0700
> @@ -18,6 +18,7 @@
> #include <linux/init.h>
> #include <linux/radix-tree.h>
> #include <linux/cpu.h>
> +#include <linux/msi.h>
> #include <linux/of.h>
>
> #include <asm/firmware.h>
> @@ -219,6 +220,14 @@ static void xics_unmask_irq(unsigned int
>
> static unsigned int xics_startup(unsigned int virq)
> {
> + /*
> + * The generic MSI code returns with the interrupt disabled on the
> + * card, using the MSI mask bits. Firmware doesn't appear to unmask
> + * at that level, so we do it here by hand.
> + */
> + if (irq_to_desc(virq)->msi_desc)
> + unmask_msi_irq(virq);
> +
> /* unmask it */
> xics_unmask_irq(virq);
> return 0;
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply
* RE: [PATCH 1/3] fsl_pq_mdio: Fix compiler/sparse warnings (part 1)
From: Kumar Gopalpet-B05799 @ 2009-11-05 5:41 UTC (permalink / raw)
To: Kumar Gopalpet-B05799, Anton Vorontsov
Cc: netdev, Fleming Andy-AFLEMING, David Miller, linuxppc-dev
In-Reply-To: <20091104225256.GA29537@oksana.dev.rtsoft.ru>
=20
>-----Original Message-----
>From: Kumar Gopalpet-B05799=20
>Sent: Thursday, November 05, 2009 10:31 AM
>To: 'Anton Vorontsov'
>Cc: Fleming Andy-AFLEMING; netdev@vger.kernel.org;=20
>linuxppc-dev@ozlabs.org; David Miller
>Subject: RE: [PATCH 1/3] fsl_pq_mdio: Fix compiler/sparse=20
>warnings (part 1)
>
>=20
>
>>-----Original Message-----
>>From: Anton Vorontsov [mailto:avorontsov@ru.mvista.com]
>>Sent: Thursday, November 05, 2009 4:23 AM
>>To: David Miller
>>Cc: Fleming Andy-AFLEMING; Kumar Gopalpet-B05799;=20
>>netdev@vger.kernel.org; linuxppc-dev@ozlabs.org
>>Subject: [PATCH 1/3] fsl_pq_mdio: Fix compiler/sparse=20
>warnings (part 1)
>>
>>commit 1d2397d742b7a2b39b2f09dd9da3b9d1463f55e9 ("fsl_pq_mdio:=20
>>Add Suport for etsec2.0 devices") introduced the following warnings:
>>
>> CHECK fsl_pq_mdio.c
>>fsl_pq_mdio.c:287:22: warning: incorrect type in initializer=20
>(different=20
>>base types)
>>fsl_pq_mdio.c:287:22: expected unknown type 11 const *__mptr
>>fsl_pq_mdio.c:287:22: got unsigned long long [unsigned]=20
>>[assigned] [usertype] addr
>>fsl_pq_mdio.c:287:19: warning: incorrect type in assignment=20
>(different=20
>>base types)
>>fsl_pq_mdio.c:287:19: expected unsigned long long=20
>>[unsigned] [usertype] ioremap_miimcfg
>>fsl_pq_mdio.c:287:19: got struct fsl_pq_mdio *<noident>
>> CC fsl_pq_mdio.o
>>fsl_pq_mdio.c: In function 'fsl_pq_mdio_probe':
>>fsl_pq_mdio.c:287: warning: initialization makes pointer from integer=20
>>without a cast
>>fsl_pq_mdio.c:287: warning: assignment makes integer from pointer=20
>>without a cast
>>
>>These warnings are not easy to fix without ugly __force casts.=20
>>So, instead of introducing the casts, rework the code to=20
>substitute an=20
>>offset from an already mapped area. This makes the code a lot simpler=20
>>and less duplicated.
>>
>>Plus, from now on we don't actually map reserved registers on=20
>>non-etsec2.0 devices, so we have more chances to catch programming=20
>>errors.
>>
>>Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>>---
>> drivers/net/fsl_pq_mdio.c | 31 ++++++++++++-------------------
>> 1 files changed, 12 insertions(+), 19 deletions(-)
>>
>>diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c=20
>>index 4065b7c..fb8c8d9 100644
>>--- a/drivers/net/fsl_pq_mdio.c
>>+++ b/drivers/net/fsl_pq_mdio.c
>>@@ -262,10 +262,11 @@ static int fsl_pq_mdio_probe(struct of_device=20
>>*ofdev,
>> struct device_node *np =3D ofdev->node;
>> struct device_node *tbi;
>> struct fsl_pq_mdio __iomem *regs =3D NULL;
>>+ void __iomem *map;
>> u32 __iomem *tbipa;
>> struct mii_bus *new_bus;
>> int tbiaddr =3D -1;
>>- u64 addr =3D 0, size =3D 0, ioremap_miimcfg =3D 0;
>>+ u64 addr =3D 0, size =3D 0;
>> int err =3D 0;
>>=20
>> new_bus =3D mdiobus_alloc();
>>@@ -279,28 +280,20 @@ static int fsl_pq_mdio_probe(struct of_device=20
>>*ofdev,
>> fsl_pq_mdio_bus_name(new_bus->id, np);
>>=20
>> /* Set the PHY base address */
>>- if (of_device_is_compatible(np,"fsl,gianfar-mdio") ||
>>- of_device_is_compatible(np, "fsl,gianfar-tbi") ||
>>- of_device_is_compatible(np, "fsl,ucc-mdio") ||
>>- of_device_is_compatible(np,"ucc_geth_phy" )) {
>>- addr =3D of_translate_address(np,=20
>>of_get_address(np, 0, &size, NULL));
>>- ioremap_miimcfg =3D container_of(addr, struct=20
>>fsl_pq_mdio, miimcfg);
>>- regs =3D ioremap(ioremap_miimcfg, size +
>>- offsetof(struct fsl_pq_mdio, miimcfg));
>>- } else if (of_device_is_compatible(np,"fsl,etsec2-mdio") ||
>>- of_device_is_compatible(np, "fsl,etsec2-tbi")) {
>>- addr =3D of_translate_address(np,=20
>>of_get_address(np, 0, &size, NULL));
>>- regs =3D ioremap(addr, size);
>>- } else {
>>- err =3D -EINVAL;
>>- goto err_free_bus;
>>- }
>>-
>>- if (NULL =3D=3D regs) {
>>+ addr =3D of_translate_address(np, of_get_address(np, 0,
>>&size, NULL));
>>+ map =3D ioremap(addr, size);
>>+ if (!map) {
>> err =3D -ENOMEM;
>> goto err_free_bus;
>> }
>>=20
>>+ if (of_device_is_compatible(np, "fsl,gianfar-mdio") ||
>>+ of_device_is_compatible(np,
>>"fsl,gianfar-tbi") ||
>>+ of_device_is_compatible(np, "fsl,ucc-mdio") ||
>>+ of_device_is_compatible(np, "ucc_geth_phy"))
>>+ map -=3D offsetof(struct fsl_pq_mdio, miimcfg);
>>+ regs =3D map;
>>+
>> new_bus->priv =3D (void __force *)regs;
>>=20
>> new_bus->irq =3D kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
>>--
>
>HI Anton, thanks for the changes. I have only one concern, has=20
>this code been tried for ucc_geth ? I remember I had some=20
>issues with getting the ucc_geth mdio also working. I will=20
>take in these changes and try at my end for ucc_geth.
Sorry, if my earlier statement was confusing. What I meant was with
similar changes as Anton's changes
I had some issues with ucc_geth mdio ( may be Anton's changes don't have
that issue).
--
Thanks
Sandeep
^ permalink raw reply
* Re: [PATCH] powerpc/mm: Remove debug context clamping from nohash code
From: Benjamin Herrenschmidt @ 2009-11-05 5:21 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev
In-Reply-To: <6BAA37ED-F9DB-43A6-867B-B63D65926185@kernel.crashing.org>
On Wed, 2009-11-04 at 23:16 -0600, Kumar Gala wrote:
> On Nov 4, 2009, at 5:39 PM, Benjamin Herrenschmidt wrote:
>
> > I inadvertently left that debug code enabled, causing the number of
> > contexts to be clamped to 31 which is going to slow things down on
> > 4xx and just plain breaks 8xx
> >
> > Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > ---
> > arch/powerpc/mm/mmu_context_nohash.c | 4 ++--
> > 1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/
> > mmu_context_nohash.c
> > index c2f93dc..be4f34c 100644
> > --- a/arch/powerpc/mm/mmu_context_nohash.c
> > +++ b/arch/powerpc/mm/mmu_context_nohash.c
> > @@ -25,8 +25,8 @@
> > * also clear mm->cpu_vm_mask bits when processes are migrated
> > */
> >
> > -#define DEBUG_MAP_CONSISTENCY
> > -#define DEBUG_CLAMP_LAST_CONTEXT 31
> > +//#define DEBUG_MAP_CONSISTENCY
> > +//#define DEBUG_CLAMP_LAST_CONTEXT 31
> > //#define DEBUG_HARDER
> >
> > /* We don't use DEBUG because it tends to be compiled in always
> > nowadays
>
> Can you send this to stable.
No need. .31 doesn't have the clamp, it went in afterward afaik
(my bad) though stable does have DEBUG_MAP_CONSISTENCY which you
may want to remove for perfs.
Cheers,
Ben.
^ permalink raw reply
* Re: [PATCH] powerpc/mm: Remove debug context clamping from nohash code
From: Kumar Gala @ 2009-11-05 5:16 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
In-Reply-To: <1257377992.13611.77.camel@pasglop>
On Nov 4, 2009, at 5:39 PM, Benjamin Herrenschmidt wrote:
> I inadvertently left that debug code enabled, causing the number of
> contexts to be clamped to 31 which is going to slow things down on
> 4xx and just plain breaks 8xx
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/mm/mmu_context_nohash.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/
> mmu_context_nohash.c
> index c2f93dc..be4f34c 100644
> --- a/arch/powerpc/mm/mmu_context_nohash.c
> +++ b/arch/powerpc/mm/mmu_context_nohash.c
> @@ -25,8 +25,8 @@
> * also clear mm->cpu_vm_mask bits when processes are migrated
> */
>
> -#define DEBUG_MAP_CONSISTENCY
> -#define DEBUG_CLAMP_LAST_CONTEXT 31
> +//#define DEBUG_MAP_CONSISTENCY
> +//#define DEBUG_CLAMP_LAST_CONTEXT 31
> //#define DEBUG_HARDER
>
> /* We don't use DEBUG because it tends to be compiled in always
> nowadays
Can you send this to stable.
- k
^ permalink raw reply
* RE: [PATCH 1/3] fsl_pq_mdio: Fix compiler/sparse warnings (part 1)
From: Kumar Gopalpet-B05799 @ 2009-11-05 5:01 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: netdev, Fleming Andy-AFLEMING, David Miller, linuxppc-dev
In-Reply-To: <20091104225256.GA29537@oksana.dev.rtsoft.ru>
=20
>-----Original Message-----
>From: Anton Vorontsov [mailto:avorontsov@ru.mvista.com]=20
>Sent: Thursday, November 05, 2009 4:23 AM
>To: David Miller
>Cc: Fleming Andy-AFLEMING; Kumar Gopalpet-B05799;=20
>netdev@vger.kernel.org; linuxppc-dev@ozlabs.org
>Subject: [PATCH 1/3] fsl_pq_mdio: Fix compiler/sparse warnings (part 1)
>
>commit 1d2397d742b7a2b39b2f09dd9da3b9d1463f55e9 ("fsl_pq_mdio:=20
>Add Suport for etsec2.0 devices") introduced the following warnings:
>
> CHECK fsl_pq_mdio.c
>fsl_pq_mdio.c:287:22: warning: incorrect type in initializer=20
>(different base types)
>fsl_pq_mdio.c:287:22: expected unknown type 11 const *__mptr
>fsl_pq_mdio.c:287:22: got unsigned long long [unsigned]=20
>[assigned] [usertype] addr
>fsl_pq_mdio.c:287:19: warning: incorrect type in assignment=20
>(different base types)
>fsl_pq_mdio.c:287:19: expected unsigned long long=20
>[unsigned] [usertype] ioremap_miimcfg
>fsl_pq_mdio.c:287:19: got struct fsl_pq_mdio *<noident>
> CC fsl_pq_mdio.o
>fsl_pq_mdio.c: In function 'fsl_pq_mdio_probe':
>fsl_pq_mdio.c:287: warning: initialization makes pointer from=20
>integer without a cast
>fsl_pq_mdio.c:287: warning: assignment makes integer from=20
>pointer without a cast
>
>These warnings are not easy to fix without ugly __force casts.=20
>So, instead of introducing the casts, rework the code to=20
>substitute an offset from an already mapped area. This makes=20
>the code a lot simpler and less duplicated.
>
>Plus, from now on we don't actually map reserved registers on=20
>non-etsec2.0 devices, so we have more chances to catch=20
>programming errors.
>
>Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>---
> drivers/net/fsl_pq_mdio.c | 31 ++++++++++++-------------------
> 1 files changed, 12 insertions(+), 19 deletions(-)
>
>diff --git a/drivers/net/fsl_pq_mdio.c=20
>b/drivers/net/fsl_pq_mdio.c index 4065b7c..fb8c8d9 100644
>--- a/drivers/net/fsl_pq_mdio.c
>+++ b/drivers/net/fsl_pq_mdio.c
>@@ -262,10 +262,11 @@ static int fsl_pq_mdio_probe(struct=20
>of_device *ofdev,
> struct device_node *np =3D ofdev->node;
> struct device_node *tbi;
> struct fsl_pq_mdio __iomem *regs =3D NULL;
>+ void __iomem *map;
> u32 __iomem *tbipa;
> struct mii_bus *new_bus;
> int tbiaddr =3D -1;
>- u64 addr =3D 0, size =3D 0, ioremap_miimcfg =3D 0;
>+ u64 addr =3D 0, size =3D 0;
> int err =3D 0;
>=20
> new_bus =3D mdiobus_alloc();
>@@ -279,28 +280,20 @@ static int fsl_pq_mdio_probe(struct=20
>of_device *ofdev,
> fsl_pq_mdio_bus_name(new_bus->id, np);
>=20
> /* Set the PHY base address */
>- if (of_device_is_compatible(np,"fsl,gianfar-mdio") ||
>- of_device_is_compatible(np, "fsl,gianfar-tbi") ||
>- of_device_is_compatible(np, "fsl,ucc-mdio") ||
>- of_device_is_compatible(np,"ucc_geth_phy" )) {
>- addr =3D of_translate_address(np,=20
>of_get_address(np, 0, &size, NULL));
>- ioremap_miimcfg =3D container_of(addr, struct=20
>fsl_pq_mdio, miimcfg);
>- regs =3D ioremap(ioremap_miimcfg, size +
>- offsetof(struct fsl_pq_mdio, miimcfg));
>- } else if (of_device_is_compatible(np,"fsl,etsec2-mdio") ||
>- of_device_is_compatible(np, "fsl,etsec2-tbi")) {
>- addr =3D of_translate_address(np,=20
>of_get_address(np, 0, &size, NULL));
>- regs =3D ioremap(addr, size);
>- } else {
>- err =3D -EINVAL;
>- goto err_free_bus;
>- }
>-
>- if (NULL =3D=3D regs) {
>+ addr =3D of_translate_address(np, of_get_address(np, 0,=20
>&size, NULL));
>+ map =3D ioremap(addr, size);
>+ if (!map) {
> err =3D -ENOMEM;
> goto err_free_bus;
> }
>=20
>+ if (of_device_is_compatible(np, "fsl,gianfar-mdio") ||
>+ of_device_is_compatible(np,=20
>"fsl,gianfar-tbi") ||
>+ of_device_is_compatible(np, "fsl,ucc-mdio") ||
>+ of_device_is_compatible(np, "ucc_geth_phy"))
>+ map -=3D offsetof(struct fsl_pq_mdio, miimcfg);
>+ regs =3D map;
>+
> new_bus->priv =3D (void __force *)regs;
>=20
> new_bus->irq =3D kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
>--
HI Anton, thanks for the changes. I have only one concern, has this code
been tried for ucc_geth ? I remember I had some issues with getting the
ucc_geth mdio also working. I will take in these changes and try at my
end for ucc_geth.
-Thanks
Sandeep=20
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox