This source file includes following definitions.
- pseries_of_derive_parent
- of_read_drc_info_cell
1
2 #include <linux/string.h>
3 #include <linux/err.h>
4 #include <linux/slab.h>
5 #include <linux/of.h>
6 #include <asm/prom.h>
7
8 #include "of_helpers.h"
9
10
11
12
13
14
15
16
17
18 struct device_node *pseries_of_derive_parent(const char *path)
19 {
20 struct device_node *parent;
21 char *parent_path = "/";
22 const char *tail;
23
24
25 tail = kbasename(path) - 1;
26
27
28 if (!strcmp(path, "/"))
29 return ERR_PTR(-EINVAL);
30
31 if (tail > path) {
32 parent_path = kstrndup(path, tail - path, GFP_KERNEL);
33 if (!parent_path)
34 return ERR_PTR(-ENOMEM);
35 }
36 parent = of_find_node_by_path(parent_path);
37 if (strcmp(parent_path, "/"))
38 kfree(parent_path);
39 return parent ? parent : ERR_PTR(-EINVAL);
40 }
41
42
43
44
45 int of_read_drc_info_cell(struct property **prop, const __be32 **curval,
46 struct of_drc_info *data)
47 {
48 const char *p;
49 const __be32 *p2;
50
51 if (!data)
52 return -EINVAL;
53
54
55 p = data->drc_type = (char*) (*curval);
56 p = of_prop_next_string(*prop, p);
57 if (!p)
58 return -EINVAL;
59
60
61 data->drc_name_prefix = (char *)p;
62 p = of_prop_next_string(*prop, p);
63 if (!p)
64 return -EINVAL;
65
66
67 p2 = (const __be32 *)p;
68 p2 = of_prop_next_u32(*prop, p2, &data->drc_index_start);
69 if (!p2)
70 return -EINVAL;
71
72
73 p2 = of_prop_next_u32(*prop, p2, &data->drc_name_suffix_start);
74 if (!p2)
75 return -EINVAL;
76
77
78 p2 = of_prop_next_u32(*prop, p2, &data->num_sequential_elems);
79 if (!p2)
80 return -EINVAL;
81
82
83 p2 = of_prop_next_u32(*prop, p2, &data->sequential_inc);
84 if (!p2)
85 return -EINVAL;
86
87
88 p2 = of_prop_next_u32(*prop, p2, &data->drc_power_domain);
89 if (!p2)
90 return -EINVAL;
91
92
93 (*curval) = (void *)p2;
94 data->last_drc_index = data->drc_index_start +
95 ((data->num_sequential_elems - 1) * data->sequential_inc);
96
97 return 0;
98 }
99 EXPORT_SYMBOL(of_read_drc_info_cell);