@@ -336,26 +336,6 @@ static int msi_quota_for_device(struct pci_dev *dev, int request)
336336 return request ;
337337}
338338
339- static int rtas_msi_check_device (struct pci_dev * pdev , int nvec , int type )
340- {
341- int quota , rc ;
342-
343- if (type == PCI_CAP_ID_MSIX )
344- rc = check_req_msix (pdev , nvec );
345- else
346- rc = check_req_msi (pdev , nvec );
347-
348- if (rc )
349- return rc ;
350-
351- quota = msi_quota_for_device (pdev , nvec );
352-
353- if (quota && quota < nvec )
354- return quota ;
355-
356- return 0 ;
357- }
358-
359339static int check_msix_entries (struct pci_dev * pdev )
360340{
361341 struct msi_desc * entry ;
@@ -397,15 +377,24 @@ static void rtas_hack_32bit_msi_gen2(struct pci_dev *pdev)
397377static int rtas_setup_msi_irqs (struct pci_dev * pdev , int nvec_in , int type )
398378{
399379 struct pci_dn * pdn ;
400- int hwirq , virq , i , rc ;
380+ int hwirq , virq , i , quota , rc ;
401381 struct msi_desc * entry ;
402382 struct msi_msg msg ;
403383 int nvec = nvec_in ;
404384 int use_32bit_msi_hack = 0 ;
405385
406- pdn = pci_get_pdn (pdev );
407- if (!pdn )
408- return - ENODEV ;
386+ if (type == PCI_CAP_ID_MSIX )
387+ rc = check_req_msix (pdev , nvec );
388+ else
389+ rc = check_req_msi (pdev , nvec );
390+
391+ if (rc )
392+ return rc ;
393+
394+ quota = msi_quota_for_device (pdev , nvec );
395+
396+ if (quota && quota < nvec )
397+ return quota ;
409398
410399 if (type == PCI_CAP_ID_MSIX && check_msix_entries (pdev ))
411400 return - EINVAL ;
@@ -416,12 +405,14 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
416405 */
417406 if (type == PCI_CAP_ID_MSIX ) {
418407 int m = roundup_pow_of_two (nvec );
419- int quota = msi_quota_for_device (pdev , m );
408+ quota = msi_quota_for_device (pdev , m );
420409
421410 if (quota >= m )
422411 nvec = m ;
423412 }
424413
414+ pdn = pci_get_pdn (pdev );
415+
425416 /*
426417 * Try the new more explicit firmware interface, if that fails fall
427418 * back to the old interface. The old interface is known to never
@@ -485,7 +476,7 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type)
485476 irq_set_msi_desc (virq , entry );
486477
487478 /* Read config space back so we can restore after reset */
488- read_msi_msg ( virq , & msg );
479+ __read_msi_msg ( entry , & msg );
489480 entry -> msg = msg ;
490481 }
491482
@@ -526,7 +517,6 @@ static int rtas_msi_init(void)
526517 WARN_ON (ppc_md .setup_msi_irqs );
527518 ppc_md .setup_msi_irqs = rtas_setup_msi_irqs ;
528519 ppc_md .teardown_msi_irqs = rtas_teardown_msi_irqs ;
529- ppc_md .msi_check_device = rtas_msi_check_device ;
530520
531521 WARN_ON (ppc_md .pci_irq_fixup );
532522 ppc_md .pci_irq_fixup = rtas_msi_pci_irq_fixup ;
0 commit comments