@@ -247,7 +247,9 @@ fn decode_gpios_gpio(unique: &Ident, entry: &Value) -> TokenStream {
247247#[ serde( tag = "type" , rename_all = "snake_case" , content = "value" ) ]
248248pub enum RawInfo {
249249 /// Get the raw device directly from this node.
250- Myself ,
250+ Myself {
251+ args : Vec < ArgInfo > ,
252+ } ,
251253 /// Get the reference from a parent of this node, at a given level.
252254 Parent {
253255 /// How many levels to look up. 0 would refer to this node (but would also be an error).
@@ -272,7 +274,9 @@ impl RawInfo {
272274 } ;
273275
274276 match self {
275- RawInfo :: Myself => {
277+ RawInfo :: Myself { args } => {
278+ let get_args = args. iter ( ) . map ( |arg| arg. args ( node) ) ;
279+
276280 let ord = node. ord ;
277281 let rawdev = format_ident ! ( "__device_dts_ord_{}" , ord) ;
278282 quote ! {
@@ -288,7 +292,7 @@ impl RawInfo {
288292 pub fn get_instance( ) -> Option <#device_id> {
289293 unsafe {
290294 let device = get_instance_raw( ) ;
291- #device_id:: new( & UNIQUE , device)
295+ #device_id:: new( & UNIQUE , device, # ( #get_args ) , * )
292296 }
293297 }
294298 }
@@ -354,6 +358,8 @@ impl RawInfo {
354358pub enum ArgInfo {
355359 /// The arguments come from a 'reg' property.
356360 Reg ,
361+ /// A count of the number of child nodes.
362+ ChildCount ,
357363}
358364
359365impl ArgInfo {
@@ -366,6 +372,12 @@ impl ArgInfo {
366372 #( #reg) , *
367373 }
368374 }
375+ ArgInfo :: ChildCount => {
376+ let count = node. children . len ( ) ;
377+ quote ! {
378+ #count
379+ }
380+ }
369381 }
370382 }
371383}
0 commit comments