@@ -25,19 +25,25 @@ struct property_set {
25
25
const struct property_entry * properties ;
26
26
};
27
27
28
- static inline bool is_pset_node (struct fwnode_handle * fwnode )
29
- {
30
- return !IS_ERR_OR_NULL (fwnode ) && fwnode -> type == FWNODE_PDATA ;
31
- }
28
+ static const struct fwnode_operations pset_fwnode_ops ;
32
29
33
- static inline struct property_set * to_pset_node ( struct fwnode_handle * fwnode )
30
+ static inline bool is_pset_node ( const struct fwnode_handle * fwnode )
34
31
{
35
- return is_pset_node (fwnode ) ?
36
- container_of (fwnode , struct property_set , fwnode ) : NULL ;
32
+ return !IS_ERR_OR_NULL (fwnode ) && fwnode -> ops == & pset_fwnode_ops ;
37
33
}
38
34
39
- static const struct property_entry * pset_prop_get (struct property_set * pset ,
40
- const char * name )
35
+ #define to_pset_node (__fwnode ) \
36
+ ({ \
37
+ typeof(__fwnode) __to_pset_node_fwnode = __fwnode; \
38
+ \
39
+ is_pset_node(__to_pset_node_fwnode) ? \
40
+ container_of(__to_pset_node_fwnode, \
41
+ struct property_set, fwnode) : \
42
+ NULL; \
43
+ })
44
+
45
+ static const struct property_entry *
46
+ pset_prop_get (const struct property_set * pset , const char * name )
41
47
{
42
48
const struct property_entry * prop ;
43
49
@@ -51,7 +57,7 @@ static const struct property_entry *pset_prop_get(struct property_set *pset,
51
57
return NULL ;
52
58
}
53
59
54
- static const void * pset_prop_find (struct property_set * pset ,
60
+ static const void * pset_prop_find (const struct property_set * pset ,
55
61
const char * propname , size_t length )
56
62
{
57
63
const struct property_entry * prop ;
@@ -71,7 +77,7 @@ static const void *pset_prop_find(struct property_set *pset,
71
77
return pointer ;
72
78
}
73
79
74
- static int pset_prop_read_u8_array (struct property_set * pset ,
80
+ static int pset_prop_read_u8_array (const struct property_set * pset ,
75
81
const char * propname ,
76
82
u8 * values , size_t nval )
77
83
{
@@ -86,7 +92,7 @@ static int pset_prop_read_u8_array(struct property_set *pset,
86
92
return 0 ;
87
93
}
88
94
89
- static int pset_prop_read_u16_array (struct property_set * pset ,
95
+ static int pset_prop_read_u16_array (const struct property_set * pset ,
90
96
const char * propname ,
91
97
u16 * values , size_t nval )
92
98
{
@@ -101,7 +107,7 @@ static int pset_prop_read_u16_array(struct property_set *pset,
101
107
return 0 ;
102
108
}
103
109
104
- static int pset_prop_read_u32_array (struct property_set * pset ,
110
+ static int pset_prop_read_u32_array (const struct property_set * pset ,
105
111
const char * propname ,
106
112
u32 * values , size_t nval )
107
113
{
@@ -116,7 +122,7 @@ static int pset_prop_read_u32_array(struct property_set *pset,
116
122
return 0 ;
117
123
}
118
124
119
- static int pset_prop_read_u64_array (struct property_set * pset ,
125
+ static int pset_prop_read_u64_array (const struct property_set * pset ,
120
126
const char * propname ,
121
127
u64 * values , size_t nval )
122
128
{
@@ -131,7 +137,7 @@ static int pset_prop_read_u64_array(struct property_set *pset,
131
137
return 0 ;
132
138
}
133
139
134
- static int pset_prop_count_elems_of_size (struct property_set * pset ,
140
+ static int pset_prop_count_elems_of_size (const struct property_set * pset ,
135
141
const char * propname , size_t length )
136
142
{
137
143
const struct property_entry * prop ;
@@ -143,7 +149,7 @@ static int pset_prop_count_elems_of_size(struct property_set *pset,
143
149
return prop -> length / length ;
144
150
}
145
151
146
- static int pset_prop_read_string_array (struct property_set * pset ,
152
+ static int pset_prop_read_string_array (const struct property_set * pset ,
147
153
const char * propname ,
148
154
const char * * strings , size_t nval )
149
155
{
@@ -187,18 +193,18 @@ struct fwnode_handle *dev_fwnode(struct device *dev)
187
193
}
188
194
EXPORT_SYMBOL_GPL (dev_fwnode );
189
195
190
- static bool pset_fwnode_property_present (struct fwnode_handle * fwnode ,
196
+ static bool pset_fwnode_property_present (const struct fwnode_handle * fwnode ,
191
197
const char * propname )
192
198
{
193
199
return !!pset_prop_get (to_pset_node (fwnode ), propname );
194
200
}
195
201
196
- static int pset_fwnode_read_int_array (struct fwnode_handle * fwnode ,
202
+ static int pset_fwnode_read_int_array (const struct fwnode_handle * fwnode ,
197
203
const char * propname ,
198
204
unsigned int elem_size , void * val ,
199
205
size_t nval )
200
206
{
201
- struct property_set * node = to_pset_node (fwnode );
207
+ const struct property_set * node = to_pset_node (fwnode );
202
208
203
209
if (!val )
204
210
return pset_prop_count_elems_of_size (node , propname , elem_size );
@@ -217,9 +223,10 @@ static int pset_fwnode_read_int_array(struct fwnode_handle *fwnode,
217
223
return - ENXIO ;
218
224
}
219
225
220
- static int pset_fwnode_property_read_string_array (struct fwnode_handle * fwnode ,
221
- const char * propname ,
222
- const char * * val , size_t nval )
226
+ static int
227
+ pset_fwnode_property_read_string_array (const struct fwnode_handle * fwnode ,
228
+ const char * propname ,
229
+ const char * * val , size_t nval )
223
230
{
224
231
return pset_prop_read_string_array (to_pset_node (fwnode ), propname ,
225
232
val , nval );
@@ -249,7 +256,8 @@ EXPORT_SYMBOL_GPL(device_property_present);
249
256
* @fwnode: Firmware node whose property to check
250
257
* @propname: Name of the property
251
258
*/
252
- bool fwnode_property_present (struct fwnode_handle * fwnode , const char * propname )
259
+ bool fwnode_property_present (const struct fwnode_handle * fwnode ,
260
+ const char * propname )
253
261
{
254
262
bool ret ;
255
263
@@ -431,7 +439,7 @@ int device_property_match_string(struct device *dev, const char *propname,
431
439
}
432
440
EXPORT_SYMBOL_GPL (device_property_match_string );
433
441
434
- static int fwnode_property_read_int_array (struct fwnode_handle * fwnode ,
442
+ static int fwnode_property_read_int_array (const struct fwnode_handle * fwnode ,
435
443
const char * propname ,
436
444
unsigned int elem_size , void * val ,
437
445
size_t nval )
@@ -467,7 +475,7 @@ static int fwnode_property_read_int_array(struct fwnode_handle *fwnode,
467
475
* %-EOVERFLOW if the size of the property is not as expected,
468
476
* %-ENXIO if no suitable firmware interface is present.
469
477
*/
470
- int fwnode_property_read_u8_array (struct fwnode_handle * fwnode ,
478
+ int fwnode_property_read_u8_array (const struct fwnode_handle * fwnode ,
471
479
const char * propname , u8 * val , size_t nval )
472
480
{
473
481
return fwnode_property_read_int_array (fwnode , propname , sizeof (u8 ),
@@ -493,7 +501,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u8_array);
493
501
* %-EOVERFLOW if the size of the property is not as expected,
494
502
* %-ENXIO if no suitable firmware interface is present.
495
503
*/
496
- int fwnode_property_read_u16_array (struct fwnode_handle * fwnode ,
504
+ int fwnode_property_read_u16_array (const struct fwnode_handle * fwnode ,
497
505
const char * propname , u16 * val , size_t nval )
498
506
{
499
507
return fwnode_property_read_int_array (fwnode , propname , sizeof (u16 ),
@@ -519,7 +527,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u16_array);
519
527
* %-EOVERFLOW if the size of the property is not as expected,
520
528
* %-ENXIO if no suitable firmware interface is present.
521
529
*/
522
- int fwnode_property_read_u32_array (struct fwnode_handle * fwnode ,
530
+ int fwnode_property_read_u32_array (const struct fwnode_handle * fwnode ,
523
531
const char * propname , u32 * val , size_t nval )
524
532
{
525
533
return fwnode_property_read_int_array (fwnode , propname , sizeof (u32 ),
@@ -545,7 +553,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u32_array);
545
553
* %-EOVERFLOW if the size of the property is not as expected,
546
554
* %-ENXIO if no suitable firmware interface is present.
547
555
*/
548
- int fwnode_property_read_u64_array (struct fwnode_handle * fwnode ,
556
+ int fwnode_property_read_u64_array (const struct fwnode_handle * fwnode ,
549
557
const char * propname , u64 * val , size_t nval )
550
558
{
551
559
return fwnode_property_read_int_array (fwnode , propname , sizeof (u64 ),
@@ -571,7 +579,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u64_array);
571
579
* %-EOVERFLOW if the size of the property is not as expected,
572
580
* %-ENXIO if no suitable firmware interface is present.
573
581
*/
574
- int fwnode_property_read_string_array (struct fwnode_handle * fwnode ,
582
+ int fwnode_property_read_string_array (const struct fwnode_handle * fwnode ,
575
583
const char * propname , const char * * val ,
576
584
size_t nval )
577
585
{
@@ -603,7 +611,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
603
611
* %-EPROTO or %-EILSEQ if the property is not a string,
604
612
* %-ENXIO if no suitable firmware interface is present.
605
613
*/
606
- int fwnode_property_read_string (struct fwnode_handle * fwnode ,
614
+ int fwnode_property_read_string (const struct fwnode_handle * fwnode ,
607
615
const char * propname , const char * * val )
608
616
{
609
617
int ret = fwnode_property_read_string_array (fwnode , propname , val , 1 );
@@ -627,7 +635,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_string);
627
635
* %-EPROTO if the property is not an array of strings,
628
636
* %-ENXIO if no suitable firmware interface is present.
629
637
*/
630
- int fwnode_property_match_string (struct fwnode_handle * fwnode ,
638
+ int fwnode_property_match_string (const struct fwnode_handle * fwnode ,
631
639
const char * propname , const char * string )
632
640
{
633
641
const char * * values ;
@@ -657,6 +665,34 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode,
657
665
}
658
666
EXPORT_SYMBOL_GPL (fwnode_property_match_string );
659
667
668
+ /**
669
+ * fwnode_property_get_reference_args() - Find a reference with arguments
670
+ * @fwnode: Firmware node where to look for the reference
671
+ * @prop: The name of the property
672
+ * @nargs_prop: The name of the property telling the number of
673
+ * arguments in the referred node. NULL if @nargs is known,
674
+ * otherwise @nargs is ignored. Only relevant on OF.
675
+ * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
676
+ * @index: Index of the reference, from zero onwards.
677
+ * @args: Result structure with reference and integer arguments.
678
+ *
679
+ * Obtain a reference based on a named property in an fwnode, with
680
+ * integer arguments.
681
+ *
682
+ * Caller is responsible to call fwnode_handle_put() on the returned
683
+ * args->fwnode pointer.
684
+ *
685
+ */
686
+ int fwnode_property_get_reference_args (const struct fwnode_handle * fwnode ,
687
+ const char * prop , const char * nargs_prop ,
688
+ unsigned int nargs , unsigned int index ,
689
+ struct fwnode_reference_args * args )
690
+ {
691
+ return fwnode_call_int_op (fwnode , get_reference_args , prop , nargs_prop ,
692
+ nargs , index , args );
693
+ }
694
+ EXPORT_SYMBOL_GPL (fwnode_property_get_reference_args );
695
+
660
696
static int property_copy_string_array (struct property_entry * dst ,
661
697
const struct property_entry * src )
662
698
{
@@ -900,7 +936,6 @@ int device_add_properties(struct device *dev,
900
936
if (IS_ERR (p ))
901
937
return PTR_ERR (p );
902
938
903
- p -> fwnode .type = FWNODE_PDATA ;
904
939
p -> fwnode .ops = & pset_fwnode_ops ;
905
940
set_secondary_fwnode (dev , & p -> fwnode );
906
941
return 0 ;
@@ -935,7 +970,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_parent);
935
970
* Return parent firmware node of the given node if possible or %NULL if no
936
971
* parent was available.
937
972
*/
938
- struct fwnode_handle * fwnode_get_parent (struct fwnode_handle * fwnode )
973
+ struct fwnode_handle * fwnode_get_parent (const struct fwnode_handle * fwnode )
939
974
{
940
975
return fwnode_call_ptr_op (fwnode , get_parent );
941
976
}
@@ -946,8 +981,9 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);
946
981
* @fwnode: Firmware node to find the next child node for.
947
982
* @child: Handle to one of the node's child nodes or a %NULL handle.
948
983
*/
949
- struct fwnode_handle * fwnode_get_next_child_node (struct fwnode_handle * fwnode ,
950
- struct fwnode_handle * child )
984
+ struct fwnode_handle *
985
+ fwnode_get_next_child_node (const struct fwnode_handle * fwnode ,
986
+ struct fwnode_handle * child )
951
987
{
952
988
return fwnode_call_ptr_op (fwnode , get_next_child_node , child );
953
989
}
@@ -978,8 +1014,9 @@ EXPORT_SYMBOL_GPL(device_get_next_child_node);
978
1014
* @fwnode: Firmware node to find the named child node for.
979
1015
* @childname: String to match child node name against.
980
1016
*/
981
- struct fwnode_handle * fwnode_get_named_child_node (struct fwnode_handle * fwnode ,
982
- const char * childname )
1017
+ struct fwnode_handle *
1018
+ fwnode_get_named_child_node (const struct fwnode_handle * fwnode ,
1019
+ const char * childname )
983
1020
{
984
1021
return fwnode_call_ptr_op (fwnode , get_named_child_node , childname );
985
1022
}
@@ -1025,7 +1062,7 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);
1025
1062
* fwnode_device_is_available - check if a device is available for use
1026
1063
* @fwnode: Pointer to the fwnode of the device.
1027
1064
*/
1028
- bool fwnode_device_is_available (struct fwnode_handle * fwnode )
1065
+ bool fwnode_device_is_available (const struct fwnode_handle * fwnode )
1029
1066
{
1030
1067
return fwnode_call_bool_op (fwnode , device_is_available );
1031
1068
}
@@ -1163,7 +1200,7 @@ EXPORT_SYMBOL(device_get_mac_address);
1163
1200
* are available.
1164
1201
*/
1165
1202
struct fwnode_handle *
1166
- fwnode_graph_get_next_endpoint (struct fwnode_handle * fwnode ,
1203
+ fwnode_graph_get_next_endpoint (const struct fwnode_handle * fwnode ,
1167
1204
struct fwnode_handle * prev )
1168
1205
{
1169
1206
return fwnode_call_ptr_op (fwnode , graph_get_next_endpoint , prev );
@@ -1177,7 +1214,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
1177
1214
* Return: the firmware node of the device the @endpoint belongs to.
1178
1215
*/
1179
1216
struct fwnode_handle *
1180
- fwnode_graph_get_port_parent (struct fwnode_handle * endpoint )
1217
+ fwnode_graph_get_port_parent (const struct fwnode_handle * endpoint )
1181
1218
{
1182
1219
struct fwnode_handle * port , * parent ;
1183
1220
@@ -1197,7 +1234,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
1197
1234
* Extracts firmware node of a remote device the @fwnode points to.
1198
1235
*/
1199
1236
struct fwnode_handle *
1200
- fwnode_graph_get_remote_port_parent (struct fwnode_handle * fwnode )
1237
+ fwnode_graph_get_remote_port_parent (const struct fwnode_handle * fwnode )
1201
1238
{
1202
1239
struct fwnode_handle * endpoint , * parent ;
1203
1240
@@ -1216,7 +1253,8 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port_parent);
1216
1253
*
1217
1254
* Extracts firmware node of a remote port the @fwnode points to.
1218
1255
*/
1219
- struct fwnode_handle * fwnode_graph_get_remote_port (struct fwnode_handle * fwnode )
1256
+ struct fwnode_handle *
1257
+ fwnode_graph_get_remote_port (const struct fwnode_handle * fwnode )
1220
1258
{
1221
1259
return fwnode_get_next_parent (fwnode_graph_get_remote_endpoint (fwnode ));
1222
1260
}
@@ -1229,7 +1267,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port);
1229
1267
* Extracts firmware node of a remote endpoint the @fwnode points to.
1230
1268
*/
1231
1269
struct fwnode_handle *
1232
- fwnode_graph_get_remote_endpoint (struct fwnode_handle * fwnode )
1270
+ fwnode_graph_get_remote_endpoint (const struct fwnode_handle * fwnode )
1233
1271
{
1234
1272
return fwnode_call_ptr_op (fwnode , graph_get_remote_endpoint );
1235
1273
}
@@ -1244,8 +1282,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
1244
1282
* Return: Remote fwnode handle associated with remote endpoint node linked
1245
1283
* to @node. Use fwnode_node_put() on it when done.
1246
1284
*/
1247
- struct fwnode_handle * fwnode_graph_get_remote_node (struct fwnode_handle * fwnode ,
1248
- u32 port_id , u32 endpoint_id )
1285
+ struct fwnode_handle *
1286
+ fwnode_graph_get_remote_node (const struct fwnode_handle * fwnode , u32 port_id ,
1287
+ u32 endpoint_id )
1249
1288
{
1250
1289
struct fwnode_handle * endpoint = NULL ;
1251
1290
@@ -1281,7 +1320,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
1281
1320
* information in @endpoint. The caller must hold a reference to
1282
1321
* @fwnode.
1283
1322
*/
1284
- int fwnode_graph_parse_endpoint (struct fwnode_handle * fwnode ,
1323
+ int fwnode_graph_parse_endpoint (const struct fwnode_handle * fwnode ,
1285
1324
struct fwnode_endpoint * endpoint )
1286
1325
{
1287
1326
memset (endpoint , 0 , sizeof (* endpoint ));
0 commit comments