@@ -1009,6 +1009,64 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
10091009}
10101010EXPORT_SYMBOL_GPL (__acpi_node_get_property_reference );
10111011
1012+ int __acpi_node_count_property_reference (const struct fwnode_handle * fwnode ,
1013+ const char * propname )
1014+ {
1015+ const union acpi_object * element , * end ;
1016+ const union acpi_object * obj ;
1017+ const struct acpi_device_data * data ;
1018+ struct acpi_device * device ;
1019+ int ret , idx = 0 ;
1020+
1021+ data = acpi_device_data_of_node (fwnode );
1022+ if (!data )
1023+ return - ENOENT ;
1024+
1025+ ret = acpi_data_get_property (data , propname , ACPI_TYPE_ANY , & obj );
1026+ if (ret )
1027+ return ret == - EINVAL ? - ENOENT : - EINVAL ;
1028+
1029+ switch (obj -> type ) {
1030+ case ACPI_TYPE_LOCAL_REFERENCE :
1031+ return 1 ;
1032+ case ACPI_TYPE_PACKAGE :
1033+ break ;
1034+ default :
1035+ return - EINVAL ;
1036+ }
1037+
1038+ element = obj -> package .elements ;
1039+ end = element + obj -> package .count ;
1040+
1041+ while (element < end ) {
1042+ switch (element -> type ) {
1043+ case ACPI_TYPE_LOCAL_REFERENCE :
1044+ device = acpi_fetch_acpi_dev (element -> reference .handle );
1045+ if (!device )
1046+ return - EINVAL ;
1047+
1048+ element ++ ;
1049+
1050+ ret = acpi_get_ref_args (NULL , acpi_fwnode_handle (device ),
1051+ & element , end , NR_FWNODE_REFERENCE_ARGS );
1052+ if (ret < 0 )
1053+ return ret ;
1054+
1055+ break ;
1056+ case ACPI_TYPE_INTEGER :
1057+ element ++ ;
1058+ break ;
1059+ default :
1060+ return - EINVAL ;
1061+ }
1062+
1063+ idx ++ ;
1064+ }
1065+
1066+ return idx ;
1067+ }
1068+ EXPORT_SYMBOL_GPL (__acpi_node_count_property_reference );
1069+
10121070static int acpi_data_prop_read_single (const struct acpi_device_data * data ,
10131071 const char * propname ,
10141072 enum dev_prop_type proptype , void * val )
@@ -1536,6 +1594,13 @@ acpi_fwnode_get_reference_args(const struct fwnode_handle *fwnode,
15361594 args_count , args );
15371595}
15381596
1597+ static int
1598+ acpi_fwnode_count_reference_with_args (const struct fwnode_handle * fwnode ,
1599+ const char * list_name , const char * cells_name )
1600+ {
1601+ return __acpi_node_count_property_reference (fwnode , list_name );
1602+ }
1603+
15391604static const char * acpi_fwnode_get_name (const struct fwnode_handle * fwnode )
15401605{
15411606 const struct acpi_device * adev ;
@@ -1641,6 +1706,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,
16411706 .graph_get_port_parent = acpi_fwnode_get_parent, \
16421707 .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \
16431708 .irq_get = acpi_fwnode_irq_get, \
1709+ .property_count_reference_with_args = acpi_fwnode_count_reference_with_args, \
16441710 }; \
16451711 EXPORT_SYMBOL_GPL(ops)
16461712
0 commit comments