V4L/DVB: s2255drv: return if vdev not found
[safe/jmp/linux-2.6] / drivers / of / base.c
index 2ce58be..b5ad974 100644 (file)
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/spinlock.h>
+#include <linux/slab.h>
+#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.
@@ -37,7 +40,7 @@ int of_n_addr_cells(struct device_node *np)
                        np = np->parent;
                ip = of_get_property(np, "#address-cells", NULL);
                if (ip)
-                       return *ip;
+                       return be32_to_cpup(ip);
        } while (np->parent);
        /* No #address-cells property for the root node */
        return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
@@ -53,7 +56,7 @@ int of_n_size_cells(struct device_node *np)
                        np = np->parent;
                ip = of_get_property(np, "#size-cells", NULL);
                if (ip)
-                       return *ip;
+                       return be32_to_cpup(ip);
        } while (np->parent);
        /* No #size-cells property for the root node */
        return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
@@ -219,13 +222,13 @@ int of_device_is_compatible(const struct device_node *device,
 EXPORT_SYMBOL(of_device_is_compatible);
 
 /**
- * machine_is_compatible - Test root of device tree for a given compatible value
+ * of_machine_is_compatible - Test root of device tree for a given compatible value
  * @compat: compatible string to look for in root node's compatible property.
  *
  * Returns true if the root node has the given value in its
  * compatible property.
  */
-int machine_is_compatible(const char *compat)
+int of_machine_is_compatible(const char *compat)
 {
        struct device_node *root;
        int rc = 0;
@@ -237,7 +240,7 @@ int machine_is_compatible(const char *compat)
        }
        return rc;
 }
-EXPORT_SYMBOL(machine_is_compatible);
+EXPORT_SYMBOL(of_machine_is_compatible);
 
 /**
  *  of_device_is_available - check if a device is available for use
@@ -615,6 +618,27 @@ int of_modalias_node(struct device_node *node, char *modalias, int len)
 EXPORT_SYMBOL_GPL(of_modalias_node);
 
 /**
+ * of_find_node_by_phandle - Find a node given a phandle
+ * @handle:    phandle of the node to find
+ *
+ * Returns a node pointer with refcount incremented, use
+ * of_node_put() on it when done.
+ */
+struct device_node *of_find_node_by_phandle(phandle handle)
+{
+       struct device_node *np;
+
+       read_lock(&devtree_lock);
+       for (np = allnodes; np; np = np->allnext)
+               if (np->phandle == handle)
+                       break;
+       of_node_get(np);
+       read_unlock(&devtree_lock);
+       return np;
+}
+EXPORT_SYMBOL(of_find_node_by_phandle);
+
+/**
  * of_parse_phandle - Resolve a phandle property to a device_node pointer
  * @np: Pointer to device node holding phandle property
  * @phandle_name: Name of property holding a phandle value
@@ -674,8 +698,8 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
                                const void **out_args)
 {
        int ret = -EINVAL;
-       const u32 *list;
-       const u32 *list_end;
+       const __be32 *list;
+       const __be32 *list_end;
        int size;
        int cur_index = 0;
        struct device_node *node = NULL;
@@ -689,7 +713,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
        list_end = list + size / sizeof(*list);
 
        while (list < list_end) {
-               const u32 *cells;
+               const __be32 *cells;
                const phandle *phandle;
 
                phandle = list++;
@@ -713,7 +737,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
                        goto err1;
                }
 
-               list += *cells;
+               list += be32_to_cpup(cells);
                if (list > list_end) {
                        pr_debug("%s: insufficient arguments length\n",
                                 np->full_name);