@@ -129,6 +129,34 @@ static struct list_node g_pci_ctrl_list =
129
129
* Private Functions
130
130
****************************************************************************/
131
131
132
+ static FAR struct pci_device_s *
133
+ pci_do_find_device_from_bus (FAR struct pci_bus_s * bus , uint8_t busno ,
134
+ unsigned int devfn )
135
+ {
136
+ FAR struct pci_bus_s * bus_tmp ;
137
+ FAR struct pci_device_s * dev ;
138
+
139
+ list_for_every_entry (& bus -> devices , dev , struct pci_device_s , node )
140
+ {
141
+ if (dev -> bus -> number == busno && devfn == dev -> devfn )
142
+ {
143
+ return dev ;
144
+ }
145
+ }
146
+
147
+ list_for_every_entry (& bus -> children , bus_tmp ,
148
+ struct pci_bus_s , node )
149
+ {
150
+ dev = pci_find_device_from_bus (bus_tmp , busno , devfn );
151
+ if (dev != NULL )
152
+ {
153
+ return dev ;
154
+ }
155
+ }
156
+
157
+ return NULL ;
158
+ }
159
+
132
160
/****************************************************************************
133
161
* Name: pci_change_master
134
162
*
@@ -782,6 +810,41 @@ static void pci_scan_bus(FAR struct pci_bus_s *bus)
782
810
* Public Functions
783
811
****************************************************************************/
784
812
813
+ /****************************************************************************
814
+ * Name: pci_find_device_from_bus
815
+ *
816
+ * Description:
817
+ * To find a PCI device from the bus
818
+ *
819
+ * Input Parameters:
820
+ * bus - pci bus
821
+ * busno - bus number
822
+ * devfn - device number and function number
823
+ *
824
+ * Returned Value:
825
+ * Failed if return NULL, otherwise return pci devices
826
+ *
827
+ ****************************************************************************/
828
+
829
+ FAR struct pci_device_s *
830
+ pci_find_device_from_bus (FAR struct pci_bus_s * bus , uint8_t busno ,
831
+ unsigned int devfn )
832
+ {
833
+ FAR struct pci_device_s * dev ;
834
+ int ret ;
835
+
836
+ ret = nxmutex_lock (& g_pci_lock );
837
+ if (ret < 0 )
838
+ {
839
+ return NULL ;
840
+ }
841
+
842
+ dev = pci_do_find_device_from_bus (bus , busno , devfn );
843
+ nxmutex_unlock (& g_pci_lock );
844
+
845
+ return dev ;
846
+ }
847
+
785
848
/****************************************************************************
786
849
* Name: pci_bus_read_config
787
850
*
0 commit comments