aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-20 11:04:46 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-20 11:04:46 -0800
commitb3cdda2b4f541439ca4205793040aa2e1c852e3b (patch)
tree12f4249a75ba4348b6674c0d46581d959d1dc5c0 /include
parent3aad3f03b2b6d2d977b985c49274cdb78a1593e5 (diff)
parent02bbde7849e68e193cefaa1885fe0df0f03c9fcd (diff)
Merge tag 'dt-for-linus' of git://git.secretlab.ca/git/linux
Pull device tree changes from Grant Likely: "All around device tree changes destined for v3.8. Aside from the documentation updates the highlights in this branch include: - Kbuild changes for using CPP with .dts files - locking fix from preempt_rt patchset - include DT alias names in device uevent - Selftest bugfixes and improvements - New function for counting phandles stanzas in a property - constify argument to of_node_full_name() - Various bug fixes This tree did also contain a commit to use platform_device_add instead of open-coding the device add code, but it caused problems with amba devices and needed to be reverted." * tag 'dt-for-linus' of git://git.secretlab.ca/git/linux: (23 commits) Revert "of: use platform_device_add" kbuild: limit dtc+cpp include path gpio: Make of_count_named_gpios() use new of_count_phandle_with_args() of: Create function for counting number of phandles in a property of/base: Clean up exit paths for of_parse_phandle_with_args() of/selftest: Use selftest() macro throughout of/selftest: Fix GPIOs selftest to cover the 7th case of: fix recursive locking in of_get_next_available_child() documentation/devicetree: Fix a typo in exynos-dw-mshc.txt OF: convert devtree lock from rw_lock to raw spinlock of/exynos_g2d: Add Bindings for exynos G2D driver kbuild: create a rule to run the pre-processor on *.dts files input: Extend matrix-keypad device tree binding devicetree: Move NS2 LEDs binding into LEDs directory of: use platform_device_add powerpc/5200: Fix size to request_mem_region() call documentation/devicetree: Fix typos of: add 'const' to of_node_full_name parameter of: Output devicetree alias names in uevent DT: add vendor prefixes for Renesas and Toshiba ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/of.h13
-rw-r--r--include/linux/of_gpio.h40
2 files changed, 34 insertions, 19 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index 5ebcc5c8e42..a0f12928494 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -92,7 +92,7 @@ static inline void of_node_put(struct device_node *node) { }
extern struct device_node *of_allnodes;
extern struct device_node *of_chosen;
extern struct device_node *of_aliases;
-extern rwlock_t devtree_lock;
+extern raw_spinlock_t devtree_lock;
static inline bool of_have_populated_dt(void)
{
@@ -160,7 +160,7 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
#define OF_BAD_ADDR ((u64)-1)
-static inline const char* of_node_full_name(struct device_node *np)
+static inline const char *of_node_full_name(const struct device_node *np)
{
return np ? np->full_name : "<no-node>";
}
@@ -277,6 +277,8 @@ extern struct device_node *of_parse_phandle(const struct device_node *np,
extern int of_parse_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name, int index,
struct of_phandle_args *out_args);
+extern int of_count_phandle_with_args(const struct device_node *np,
+ const char *list_name, const char *cells_name);
extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
extern int of_alias_get_id(struct device_node *np, const char *stem);
@@ -467,6 +469,13 @@ static inline int of_parse_phandle_with_args(struct device_node *np,
return -ENOSYS;
}
+static inline int of_count_phandle_with_args(struct device_node *np,
+ const char *list_name,
+ const char *cells_name)
+{
+ return -ENOSYS;
+}
+
static inline int of_alias_get_id(struct device_node *np, const char *stem)
{
return -ENOSYS;
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h
index c454f579674..a83dc6f5008 100644
--- a/include/linux/of_gpio.h
+++ b/include/linux/of_gpio.h
@@ -50,9 +50,6 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
extern int of_get_named_gpio_flags(struct device_node *np,
const char *list_name, int index, enum of_gpio_flags *flags);
-extern unsigned int of_gpio_named_count(struct device_node *np,
- const char* propname);
-
extern int of_mm_gpiochip_add(struct device_node *np,
struct of_mm_gpio_chip *mm_gc);
@@ -71,12 +68,6 @@ static inline int of_get_named_gpio_flags(struct device_node *np,
return -ENOSYS;
}
-static inline unsigned int of_gpio_named_count(struct device_node *np,
- const char* propname)
-{
- return 0;
-}
-
static inline int of_gpio_simple_xlate(struct gpio_chip *gc,
const struct of_phandle_args *gpiospec,
u32 *flags)
@@ -90,22 +81,37 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { }
#endif /* CONFIG_OF_GPIO */
/**
- * of_gpio_count - Count GPIOs for a device
+ * of_gpio_named_count() - Count GPIOs for a device
* @np: device node to count GPIOs for
+ * @propname: property name containing gpio specifier(s)
*
* The function returns the count of GPIOs specified for a node.
+ * Note that the empty GPIO specifiers count too. Returns either
+ * Number of gpios defined in property,
+ * -EINVAL for an incorrectly formed gpios property, or
+ * -ENOENT for a missing gpios property
*
- * Note that the empty GPIO specifiers counts too. For example,
- *
+ * Example:
* gpios = <0
- * &pio1 1 2
+ * &gpio1 1 2
* 0
- * &pio2 3 4>;
+ * &gpio2 3 4>;
+ *
+ * The above example defines four GPIOs, two of which are not specified.
+ * This function will return '4'
+ */
+static inline int of_gpio_named_count(struct device_node *np, const char* propname)
+{
+ return of_count_phandle_with_args(np, propname, "#gpio-cells");
+}
+
+/**
+ * of_gpio_count() - Count GPIOs for a device
+ * @np: device node to count GPIOs for
*
- * defines four GPIOs (so this function will return 4), two of which
- * are not specified.
+ * Same as of_gpio_named_count, but hard coded to use the 'gpios' property
*/
-static inline unsigned int of_gpio_count(struct device_node *np)
+static inline int of_gpio_count(struct device_node *np)
{
return of_gpio_named_count(np, "gpios");
}