mvebu: backport mainline patches from kernel 3.13
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0187-of-Add-helper-for-printing-an-of_phandle_args-struct.patch
1 From 061855025b6842debdf6ea2e8bfd86f50700e263 Mon Sep 17 00:00:00 2001
2 From: Grant Likely <grant.likely@linaro.org>
3 Date: Thu, 19 Dec 2013 09:30:58 -0300
4 Subject: [PATCH 187/203] of: Add helper for printing an of_phandle_args
5  structure
6
7 It is sometimes useful for debug to get the contents of an
8 of_phandle_args structure out into the kernel log.
9
10 Signed-off-by: Grant Likely <grant.likely@linaro.org>
11
12 Conflicts:
13         drivers/of/base.c
14 ---
15  drivers/of/base.c  | 9 +++++++++
16  drivers/of/irq.c   | 6 +++---
17  include/linux/of.h | 1 +
18  3 files changed, 13 insertions(+), 3 deletions(-)
19
20 --- a/drivers/of/base.c
21 +++ b/drivers/of/base.c
22 @@ -1136,6 +1136,15 @@ EXPORT_SYMBOL(of_parse_phandle);
23   * To get a device_node of the `node2' node you may call this:
24   * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
25   */
26 +void of_print_phandle_args(const char *msg, const struct of_phandle_args *args)
27 +{
28 +       int i;
29 +       printk("%s %s", msg, of_node_full_name(args->np));
30 +       for (i = 0; i < args->args_count; i++)
31 +               printk(i ? ",%08x" : ":%08x", args->args[i]);
32 +       printk("\n");
33 +}
34 +
35  static int __of_parse_phandle_with_args(const struct device_node *np,
36                                         const char *list_name,
37                                         const char *cells_name, int index,
38 --- a/drivers/of/irq.c
39 +++ b/drivers/of/irq.c
40 @@ -101,9 +101,9 @@ int of_irq_parse_raw(const __be32 *addr,
41         u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
42         int imaplen, match, i;
43  
44 -       pr_debug("of_irq_parse_raw: par=%s,intspec=[0x%08x 0x%08x...],ointsize=%d\n",
45 -                of_node_full_name(out_irq->np), out_irq->args[0], out_irq->args[1],
46 -                out_irq->args_count);
47 +#ifdef DEBUG
48 +       of_print_phandle_args("of_irq_parse_raw: ", out_irq);
49 +#endif
50  
51         ipar = of_node_get(out_irq->np);
52  
53 --- a/include/linux/of.h
54 +++ b/include/linux/of.h
55 @@ -274,6 +274,7 @@ extern int of_n_size_cells(struct device
56  extern const struct of_device_id *of_match_node(
57         const struct of_device_id *matches, const struct device_node *node);
58  extern int of_modalias_node(struct device_node *node, char *modalias, int len);
59 +extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
60  extern struct device_node *of_parse_phandle(const struct device_node *np,
61                                             const char *phandle_name,
62                                             int index);