@@ -364,18 +364,12 @@ extern const struct of_device_id *of_match_node(
364
364
const struct of_device_id * matches , const struct device_node * node );
365
365
extern int of_modalias_node (struct device_node * node , char * modalias , int len );
366
366
extern void of_print_phandle_args (const char * msg , const struct of_phandle_args * args );
367
- extern struct device_node * of_parse_phandle (const struct device_node * np ,
368
- const char * phandle_name ,
369
- int index );
370
- extern int of_parse_phandle_with_args (const struct device_node * np ,
371
- const char * list_name , const char * cells_name , int index ,
372
- struct of_phandle_args * out_args );
367
+ extern int __of_parse_phandle_with_args (const struct device_node * np ,
368
+ const char * list_name , const char * cells_name , int cell_count ,
369
+ int index , struct of_phandle_args * out_args );
373
370
extern int of_parse_phandle_with_args_map (const struct device_node * np ,
374
371
const char * list_name , const char * stem_name , int index ,
375
372
struct of_phandle_args * out_args );
376
- extern int of_parse_phandle_with_fixed_args (const struct device_node * np ,
377
- const char * list_name , int cells_count , int index ,
378
- struct of_phandle_args * out_args );
379
373
extern int of_count_phandle_with_args (const struct device_node * np ,
380
374
const char * list_name , const char * cells_name );
381
375
@@ -865,18 +859,12 @@ static inline int of_property_read_string_helper(const struct device_node *np,
865
859
return - ENOSYS ;
866
860
}
867
861
868
- static inline struct device_node * of_parse_phandle (const struct device_node * np ,
869
- const char * phandle_name ,
870
- int index )
871
- {
872
- return NULL ;
873
- }
874
-
875
- static inline int of_parse_phandle_with_args (const struct device_node * np ,
876
- const char * list_name ,
877
- const char * cells_name ,
878
- int index ,
879
- struct of_phandle_args * out_args )
862
+ static inline int __of_parse_phandle_with_args (const struct device_node * np ,
863
+ const char * list_name ,
864
+ const char * cells_name ,
865
+ int cell_count ,
866
+ int index ,
867
+ struct of_phandle_args * out_args )
880
868
{
881
869
return - ENOSYS ;
882
870
}
@@ -890,13 +878,6 @@ static inline int of_parse_phandle_with_args_map(const struct device_node *np,
890
878
return - ENOSYS ;
891
879
}
892
880
893
- static inline int of_parse_phandle_with_fixed_args (const struct device_node * np ,
894
- const char * list_name , int cells_count , int index ,
895
- struct of_phandle_args * out_args )
896
- {
897
- return - ENOSYS ;
898
- }
899
-
900
881
static inline int of_count_phandle_with_args (const struct device_node * np ,
901
882
const char * list_name ,
902
883
const char * cells_name )
@@ -1077,6 +1058,117 @@ static inline bool of_node_is_type(const struct device_node *np, const char *typ
1077
1058
return np && match && type && !strcmp (match , type );
1078
1059
}
1079
1060
1061
+ /**
1062
+ * of_parse_phandle - Resolve a phandle property to a device_node pointer
1063
+ * @np: Pointer to device node holding phandle property
1064
+ * @phandle_name: Name of property holding a phandle value
1065
+ * @index: For properties holding a table of phandles, this is the index into
1066
+ * the table
1067
+ *
1068
+ * Return: The device_node pointer with refcount incremented. Use
1069
+ * of_node_put() on it when done.
1070
+ */
1071
+ static inline struct device_node * of_parse_phandle (const struct device_node * np ,
1072
+ const char * phandle_name ,
1073
+ int index )
1074
+ {
1075
+ struct of_phandle_args args ;
1076
+
1077
+ if (__of_parse_phandle_with_args (np , phandle_name , NULL , 0 ,
1078
+ index , & args ))
1079
+ return NULL ;
1080
+
1081
+ return args .np ;
1082
+ }
1083
+
1084
+ /**
1085
+ * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
1086
+ * @np: pointer to a device tree node containing a list
1087
+ * @list_name: property name that contains a list
1088
+ * @cells_name: property name that specifies phandles' arguments count
1089
+ * @index: index of a phandle to parse out
1090
+ * @out_args: optional pointer to output arguments structure (will be filled)
1091
+ *
1092
+ * This function is useful to parse lists of phandles and their arguments.
1093
+ * Returns 0 on success and fills out_args, on error returns appropriate
1094
+ * errno value.
1095
+ *
1096
+ * Caller is responsible to call of_node_put() on the returned out_args->np
1097
+ * pointer.
1098
+ *
1099
+ * Example::
1100
+ *
1101
+ * phandle1: node1 {
1102
+ * #list-cells = <2>;
1103
+ * };
1104
+ *
1105
+ * phandle2: node2 {
1106
+ * #list-cells = <1>;
1107
+ * };
1108
+ *
1109
+ * node3 {
1110
+ * list = <&phandle1 1 2 &phandle2 3>;
1111
+ * };
1112
+ *
1113
+ * To get a device_node of the ``node2`` node you may call this:
1114
+ * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
1115
+ */
1116
+ static inline int of_parse_phandle_with_args (const struct device_node * np ,
1117
+ const char * list_name ,
1118
+ const char * cells_name ,
1119
+ int index ,
1120
+ struct of_phandle_args * out_args )
1121
+ {
1122
+ int cell_count = -1 ;
1123
+
1124
+ /* If cells_name is NULL we assume a cell count of 0 */
1125
+ if (!cells_name )
1126
+ cell_count = 0 ;
1127
+
1128
+ return __of_parse_phandle_with_args (np , list_name , cells_name ,
1129
+ cell_count , index , out_args );
1130
+ }
1131
+
1132
+ /**
1133
+ * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
1134
+ * @np: pointer to a device tree node containing a list
1135
+ * @list_name: property name that contains a list
1136
+ * @cell_count: number of argument cells following the phandle
1137
+ * @index: index of a phandle to parse out
1138
+ * @out_args: optional pointer to output arguments structure (will be filled)
1139
+ *
1140
+ * This function is useful to parse lists of phandles and their arguments.
1141
+ * Returns 0 on success and fills out_args, on error returns appropriate
1142
+ * errno value.
1143
+ *
1144
+ * Caller is responsible to call of_node_put() on the returned out_args->np
1145
+ * pointer.
1146
+ *
1147
+ * Example::
1148
+ *
1149
+ * phandle1: node1 {
1150
+ * };
1151
+ *
1152
+ * phandle2: node2 {
1153
+ * };
1154
+ *
1155
+ * node3 {
1156
+ * list = <&phandle1 0 2 &phandle2 2 3>;
1157
+ * };
1158
+ *
1159
+ * To get a device_node of the ``node2`` node you may call this:
1160
+ * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
1161
+ */
1162
+ static inline int of_parse_phandle_with_fixed_args (const struct device_node * np ,
1163
+ const char * list_name ,
1164
+ int cell_count ,
1165
+ int index ,
1166
+ struct of_phandle_args * out_args )
1167
+ {
1168
+ return __of_parse_phandle_with_args (np , list_name , NULL , cell_count ,
1169
+ index , out_args );
1170
+ }
1171
+
1080
1172
/**
1081
1173
* of_property_count_u8_elems - Count the number of u8 elements in a property
1082
1174
*
0 commit comments