@@ -103,43 +103,6 @@ static const struct ivshmem_reg no_reg;
103103
104104#endif /* CONFIG_IVSHMEM_DOORBELL */
105105
106- static bool ivshmem_check_on_bdf (pcie_bdf_t bdf )
107- {
108- uint32_t data ;
109-
110- data = pcie_conf_read (bdf , PCIE_CONF_ID );
111- if ((data != PCIE_ID_NONE ) &&
112- (PCIE_ID_TO_VEND (data ) == IVSHMEM_VENDOR_ID ) &&
113- (PCIE_ID_TO_DEV (data ) == IVSHMEM_DEVICE_ID )) {
114- return true;
115- }
116-
117- return false;
118- }
119-
120- /* Ivshmem's BDF is not a static value that we could get from DTS,
121- * since the same image could run on qemu or ACRN which could set
122- * a different one. So instead, let's find it at runtime.
123- */
124- static pcie_bdf_t ivshmem_bdf_lookup (void )
125- {
126- int bus , dev , func ;
127-
128- for (bus = 0 ; bus <= MAX_BUS ; bus ++ ) {
129- for (dev = 0 ; dev <= MAX_DEV ; ++ dev ) {
130- for (func = 0 ; func <= MAX_FUNC ; ++ func ) {
131- pcie_bdf_t bdf = PCIE_BDF (bus , dev , func );
132-
133- if (ivshmem_check_on_bdf (bdf )) {
134- return bdf ;
135- }
136- }
137- }
138- }
139-
140- return 0 ;
141- }
142-
143106static bool ivshmem_configure (const struct device * dev )
144107{
145108 struct ivshmem * data = dev -> data ;
@@ -261,8 +224,9 @@ static int ivshmem_init(const struct device *dev)
261224{
262225 struct ivshmem * data = dev -> data ;
263226
264- data -> bdf = ivshmem_bdf_lookup ();
265- if (data -> bdf == 0 ) {
227+ data -> bdf = pcie_bdf_lookup (PCIE_ID (IVSHMEM_VENDOR_ID ,
228+ IVSHMEM_DEVICE_ID ));
229+ if (data -> bdf == PCIE_BDF_NONE ) {
266230 LOG_WRN ("ivshmem device not found" );
267231 return - ENOTSUP ;
268232 }
0 commit comments