diff options
| author | Michael Brown | 2025-03-23 19:06:15 +0100 |
|---|---|---|
| committer | Michael Brown | 2025-03-24 14:19:26 +0100 |
| commit | 9dd30f11f74722a43ed590df9f525e038d155283 (patch) | |
| tree | 936e026af6624356fe467017866cb1095647b1ba /src/interface | |
| parent | [efi] Use efi_open_by_child() for all by-child protocol opens (diff) | |
| download | ipxe-9dd30f11f74722a43ed590df9f525e038d155283.tar.gz ipxe-9dd30f11f74722a43ed590df9f525e038d155283.tar.xz ipxe-9dd30f11f74722a43ed590df9f525e038d155283.zip | |
[efi] Use efi_open_by_driver() for all by-driver protocol opens
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/efi/efi_file.c | 13 | ||||
| -rw-r--r-- | src/interface/efi/efi_pci.c | 18 | ||||
| -rw-r--r-- | src/interface/efi/efi_snp.c | 30 |
3 files changed, 19 insertions, 42 deletions
diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index 48fccdbe1..f31f2fe3b 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -1169,11 +1169,8 @@ int efi_file_install ( EFI_HANDLE handle ) { * of calls to our DRIVER_STOP method when starting the EFI * shell. I have no idea why this is. */ - if ( ( efirc = bs->OpenProtocol ( handle, &efi_disk_io_protocol_guid, - &diskio.interface, efi_image_handle, - handle, - EFI_OPEN_PROTOCOL_BY_DRIVER ) ) != 0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( handle, &efi_disk_io_protocol_guid, + &diskio.interface ) ) != 0 ) { DBGC ( handle, "Could not open disk I/O protocol: %s\n", strerror ( rc ) ); DBGC_EFI_OPENERS ( handle, handle, &efi_disk_io_protocol_guid ); @@ -1199,8 +1196,7 @@ int efi_file_install ( EFI_HANDLE handle ) { efi_file_path_uninstall ( &efi_file_initrd ); err_initrd_install: err_initrd_claim: - bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_disk_io_protocol_guid ); err_open: bs->UninstallMultipleProtocolInterfaces ( handle, @@ -1228,8 +1224,7 @@ void efi_file_uninstall ( EFI_HANDLE handle ) { efi_file_path_uninstall ( &efi_file_initrd ); /* Close our own disk I/O protocol */ - bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid, - efi_image_handle, handle ); + efi_close_by_driver ( handle, &efi_disk_io_protocol_guid ); /* We must install the file system protocol first, since * otherwise the EDK2 code will attempt to helpfully uninstall diff --git a/src/interface/efi/efi_pci.c b/src/interface/efi/efi_pci.c index d55cbe86c..b53a88d66 100644 --- a/src/interface/efi/efi_pci.c +++ b/src/interface/efi/efi_pci.c @@ -902,11 +902,9 @@ static int efipci_supported ( EFI_HANDLE device ) { * @ret rc Return status code */ static int efipci_start ( struct efi_device *efidev ) { - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; struct efi_pci_device *efipci; void *pci_io; - EFI_STATUS efirc; int rc; /* Allocate PCI device */ @@ -920,12 +918,9 @@ static int efipci_start ( struct efi_device *efidev ) { if ( ( rc = efipci_info ( device, efipci ) ) != 0 ) goto err_info; - /* Open PCI device */ - if ( ( efirc = bs->OpenProtocol ( device, &efi_pci_io_protocol_guid, - &pci_io, efi_image_handle, device, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI_PCI ( efirc ); + /* Open PCI I/O protocol */ + if ( ( rc = efi_open_by_driver ( device, &efi_pci_io_protocol_guid, + &pci_io ) ) != 0 ) { DBGC ( device, "EFIPCI %s could not open PCI device: %s\n", efi_handle_name ( device ), strerror ( rc ) ); DBGC_EFI_OPENERS ( device, device, &efi_pci_io_protocol_guid ); @@ -960,8 +955,7 @@ static int efipci_start ( struct efi_device *efidev ) { err_probe: list_del ( &efipci->pci.dev.siblings ); err_find_driver: - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_pci_io_protocol_guid ); err_open: err_info: free ( efipci ); @@ -976,15 +970,13 @@ static int efipci_start ( struct efi_device *efidev ) { */ static void efipci_stop ( struct efi_device *efidev ) { struct efi_pci_device *efipci = efidev_get_drvdata ( efidev ); - EFI_BOOT_SERVICES *bs = efi_systab->BootServices; EFI_HANDLE device = efidev->device; pci_remove ( &efipci->pci ); list_del ( &efipci->pci.dev.siblings ); assert ( efipci->pci.dma.mapped == 0 ); assert ( efipci->pci.dma.allocated == 0 ); - bs->CloseProtocol ( device, &efi_pci_io_protocol_guid, - efi_image_handle, device ); + efi_close_by_driver ( device, &efi_pci_io_protocol_guid ); free ( efipci ); } diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index d977802fd..b9706d5ab 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -1916,22 +1916,16 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { * instances to prevent SnpDxe from attempting to bind to * them. */ - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii; } - if ( ( efirc = bs->OpenProtocol ( snpdev->handle, - &efi_nii31_protocol_guid, &interface, - efi_image_handle, snpdev->handle, - ( EFI_OPEN_PROTOCOL_BY_DRIVER | - EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){ - rc = -EEFI ( efirc ); + if ( ( rc = efi_open_by_driver ( snpdev->handle, + &efi_nii31_protocol_guid, + &interface ) ) != 0 ) { DBGC ( snpdev, "SNPDEV %p could not open NII31 protocol: %s\n", snpdev, strerror ( rc ) ); goto err_open_nii31; @@ -1967,11 +1961,9 @@ static int efi_snp_probe ( struct net_device *netdev, void *priv __unused ) { leak |= efi_snp_hii_uninstall ( snpdev ); efi_child_del ( efidev->device, snpdev->handle ); err_efi_child_add: - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); err_open_nii31: - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); err_open_nii: if ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, @@ -2060,10 +2052,8 @@ static void efi_snp_remove ( struct net_device *netdev, void *priv __unused ) { if ( snpdev->package_list ) leak |= efi_snp_hii_uninstall ( snpdev ); efi_child_del ( snpdev->efidev->device, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii_protocol_guid, - efi_image_handle, snpdev->handle ); - bs->CloseProtocol ( snpdev->handle, &efi_nii31_protocol_guid, - efi_image_handle, snpdev->handle ); + efi_close_by_driver ( snpdev->handle, &efi_nii_protocol_guid ); + efi_close_by_driver ( snpdev->handle, &efi_nii31_protocol_guid ); if ( ( ! efi_shutdown_in_progress ) && ( ( efirc = bs->UninstallMultipleProtocolInterfaces ( snpdev->handle, |
