@@ -418,25 +418,15 @@ static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp)
418
418
}
419
419
}
420
420
421
- int dw_pcie_host_init (struct dw_pcie_rp * pp )
421
+ static int dw_pcie_host_get_resources (struct dw_pcie_rp * pp )
422
422
{
423
423
struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
424
424
struct device * dev = pci -> dev ;
425
- struct device_node * np = dev -> of_node ;
426
425
struct platform_device * pdev = to_platform_device (dev );
427
426
struct resource_entry * win ;
428
- struct pci_host_bridge * bridge ;
429
427
struct resource * res ;
430
428
int ret ;
431
429
432
- raw_spin_lock_init (& pp -> lock );
433
-
434
- bridge = devm_pci_alloc_host_bridge (dev , 0 );
435
- if (!bridge )
436
- return - ENOMEM ;
437
-
438
- pp -> bridge = bridge ;
439
-
440
430
ret = dw_pcie_get_resources (pci );
441
431
if (ret )
442
432
return ret ;
@@ -455,13 +445,36 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
455
445
return PTR_ERR (pp -> va_cfg0_base );
456
446
457
447
/* Get the I/O range from DT */
458
- win = resource_list_first_type (& bridge -> windows , IORESOURCE_IO );
448
+ win = resource_list_first_type (& pp -> bridge -> windows , IORESOURCE_IO );
459
449
if (win ) {
460
450
pp -> io_size = resource_size (win -> res );
461
451
pp -> io_bus_addr = win -> res -> start - win -> offset ;
462
452
pp -> io_base = pci_pio_to_address (win -> res -> start );
463
453
}
464
454
455
+ return 0 ;
456
+ }
457
+
458
+ int dw_pcie_host_init (struct dw_pcie_rp * pp )
459
+ {
460
+ struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
461
+ struct device * dev = pci -> dev ;
462
+ struct device_node * np = dev -> of_node ;
463
+ struct pci_host_bridge * bridge ;
464
+ int ret ;
465
+
466
+ raw_spin_lock_init (& pp -> lock );
467
+
468
+ bridge = devm_pci_alloc_host_bridge (dev , 0 );
469
+ if (!bridge )
470
+ return - ENOMEM ;
471
+
472
+ pp -> bridge = bridge ;
473
+
474
+ ret = dw_pcie_host_get_resources (pp );
475
+ if (ret )
476
+ return ret ;
477
+
465
478
/* Set default bus ops */
466
479
bridge -> ops = & dw_pcie_ops ;
467
480
bridge -> child_ops = & dw_child_pcie_ops ;
0 commit comments