mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
[efi] Use efi_open_by_driver() for all by-driver protocol opens
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -367,7 +367,6 @@ static struct net_device_operations mnpnet_operations = {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int mnpnet_start ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE device = efidev->device;
|
||||
EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid;
|
||||
EFI_SIMPLE_NETWORK_MODE mode;
|
||||
@@ -408,13 +407,9 @@ int mnpnet_start ( struct efi_device *efidev ) {
|
||||
}
|
||||
|
||||
/* Open MNP protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( efidev->child,
|
||||
&efi_managed_network_protocol_guid,
|
||||
&u.interface, efi_image_handle,
|
||||
efidev->child,
|
||||
( EFI_OPEN_PROTOCOL_BY_DRIVER |
|
||||
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open_by_driver ( efidev->child,
|
||||
&efi_managed_network_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( mnp, "MNP %s could not open MNP protocol: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
goto err_open;
|
||||
@@ -464,8 +459,8 @@ int mnpnet_start ( struct efi_device *efidev ) {
|
||||
err_ll_addr_len:
|
||||
err_hw_addr_len:
|
||||
err_mode:
|
||||
bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid,
|
||||
efi_image_handle, efidev->child );
|
||||
efi_close_by_driver ( efidev->child,
|
||||
&efi_managed_network_protocol_guid );
|
||||
err_open:
|
||||
efi_service_del ( device, binding, efidev->child );
|
||||
err_service:
|
||||
@@ -482,7 +477,6 @@ int mnpnet_start ( struct efi_device *efidev ) {
|
||||
* @v efidev EFI device
|
||||
*/
|
||||
void mnpnet_stop ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid;
|
||||
struct net_device *netdev = efidev_get_drvdata ( efidev );
|
||||
struct mnp_nic *mnp = netdev->priv;
|
||||
@@ -491,8 +485,8 @@ void mnpnet_stop ( struct efi_device *efidev ) {
|
||||
unregister_netdev ( netdev );
|
||||
|
||||
/* Close MNP protocol */
|
||||
bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid,
|
||||
efi_image_handle, efidev->child );
|
||||
efi_close_by_driver ( efidev->child,
|
||||
&efi_managed_network_protocol_guid );
|
||||
|
||||
/* Remove MNP child (unless whole system shutdown is in progress) */
|
||||
if ( ! efi_shutdown_in_progress )
|
||||
|
||||
@@ -1270,12 +1270,10 @@ static struct net_device_operations nii_operations = {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int nii_start ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE device = efidev->device;
|
||||
struct net_device *netdev;
|
||||
struct nii_nic *nii;
|
||||
void *interface;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Allocate and initialise structure */
|
||||
@@ -1300,11 +1298,8 @@ int nii_start ( struct efi_device *efidev ) {
|
||||
netdev->dev = &nii->dev;
|
||||
|
||||
/* Open NII protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( device, &efi_nii31_protocol_guid,
|
||||
&interface, efi_image_handle, device,
|
||||
( EFI_OPEN_PROTOCOL_BY_DRIVER |
|
||||
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open_by_driver ( device, &efi_nii31_protocol_guid,
|
||||
&interface ) ) != 0 ) {
|
||||
DBGC ( nii, "NII %s cannot open NII protocol: %s\n",
|
||||
nii->dev.name, strerror ( rc ) );
|
||||
DBGC_EFI_OPENERS ( device, device, &efi_nii31_protocol_guid );
|
||||
@@ -1373,8 +1368,7 @@ int nii_start ( struct efi_device *efidev ) {
|
||||
err_pci_open:
|
||||
err_hw_undi:
|
||||
err_no_undi:
|
||||
bs->CloseProtocol ( device, &efi_nii31_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
efi_close_by_driver ( device, &efi_nii31_protocol_guid );
|
||||
err_open_protocol:
|
||||
list_del ( &nii->dev.siblings );
|
||||
netdev_nullify ( netdev );
|
||||
@@ -1389,7 +1383,6 @@ int nii_start ( struct efi_device *efidev ) {
|
||||
* @v efidev EFI device
|
||||
*/
|
||||
void nii_stop ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
struct net_device *netdev = efidev_get_drvdata ( efidev );
|
||||
struct nii_nic *nii = netdev->priv;
|
||||
EFI_HANDLE device = efidev->device;
|
||||
@@ -1404,8 +1397,7 @@ void nii_stop ( struct efi_device *efidev ) {
|
||||
nii_pci_close ( nii );
|
||||
|
||||
/* Close NII protocol */
|
||||
bs->CloseProtocol ( device, &efi_nii31_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
efi_close_by_driver ( device, &efi_nii31_protocol_guid );
|
||||
|
||||
/* Free network device */
|
||||
list_del ( &nii->dev.siblings );
|
||||
|
||||
@@ -539,7 +539,6 @@ int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int snpnet_start ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE device = efidev->device;
|
||||
EFI_SIMPLE_NETWORK_MODE *mode;
|
||||
struct net_device *netdev;
|
||||
@@ -549,12 +548,9 @@ int snpnet_start ( struct efi_device *efidev ) {
|
||||
int rc;
|
||||
|
||||
/* Open SNP protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( device,
|
||||
&efi_simple_network_protocol_guid,
|
||||
&interface, efi_image_handle, device,
|
||||
( EFI_OPEN_PROTOCOL_BY_DRIVER |
|
||||
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open_by_driver ( device,
|
||||
&efi_simple_network_protocol_guid,
|
||||
&interface ) ) != 0 ) {
|
||||
DBGC ( device, "SNP %s cannot open SNP protocol: %s\n",
|
||||
efi_handle_name ( device ), strerror ( rc ) );
|
||||
DBGC_EFI_OPENERS ( device, device,
|
||||
@@ -644,8 +640,7 @@ int snpnet_start ( struct efi_device *efidev ) {
|
||||
netdev_nullify ( netdev );
|
||||
netdev_put ( netdev );
|
||||
err_alloc:
|
||||
bs->CloseProtocol ( device, &efi_simple_network_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
efi_close_by_driver ( device, &efi_simple_network_protocol_guid );
|
||||
err_open_protocol:
|
||||
return rc;
|
||||
}
|
||||
@@ -656,7 +651,6 @@ int snpnet_start ( struct efi_device *efidev ) {
|
||||
* @v efidev EFI device
|
||||
*/
|
||||
void snpnet_stop ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
struct net_device *netdev = efidev_get_drvdata ( efidev );
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
EFI_HANDLE device = efidev->device;
|
||||
@@ -681,6 +675,5 @@ void snpnet_stop ( struct efi_device *efidev ) {
|
||||
netdev_put ( netdev );
|
||||
|
||||
/* Close SNP protocol */
|
||||
bs->CloseProtocol ( device, &efi_simple_network_protocol_guid,
|
||||
efi_image_handle, device );
|
||||
efi_close_by_driver ( device, &efi_simple_network_protocol_guid );
|
||||
}
|
||||
|
||||
@@ -229,13 +229,9 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) {
|
||||
}
|
||||
|
||||
/* Open USB I/O protocol on this handle */
|
||||
if ( ( efirc = bs->OpenProtocol ( intf->handle,
|
||||
&efi_usb_io_protocol_guid,
|
||||
&u.interface, efi_image_handle,
|
||||
intf->handle,
|
||||
( EFI_OPEN_PROTOCOL_BY_DRIVER |
|
||||
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open_by_driver ( intf->handle,
|
||||
&efi_usb_io_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( usbio, "USBIO %s cannot open ",
|
||||
efi_handle_name ( handle ) );
|
||||
DBGC ( usbio, "%s: %s\n",
|
||||
@@ -259,7 +255,6 @@ static int usbio_open ( struct usbio_device *usbio, unsigned int interface ) {
|
||||
* @v interface Interface number
|
||||
*/
|
||||
static void usbio_close ( struct usbio_device *usbio, unsigned int interface ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
struct usbio_interface *intf = &usbio->interface[interface];
|
||||
|
||||
/* Sanity checks */
|
||||
@@ -274,8 +269,7 @@ static void usbio_close ( struct usbio_device *usbio, unsigned int interface ) {
|
||||
return;
|
||||
|
||||
/* Close USB I/O protocol */
|
||||
bs->CloseProtocol ( intf->handle, &efi_usb_io_protocol_guid,
|
||||
efi_image_handle, intf->handle );
|
||||
efi_close_by_driver ( intf->handle, &efi_usb_io_protocol_guid );
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -1608,7 +1602,6 @@ static int usbio_interfaces ( struct usbio_device *usbio ) {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int usbio_start ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE handle = efidev->device;
|
||||
struct usbio_device *usbio;
|
||||
struct usb_port *port;
|
||||
@@ -1616,7 +1609,6 @@ static int usbio_start ( struct efi_device *efidev ) {
|
||||
void *interface;
|
||||
EFI_USB_IO_PROTOCOL *io;
|
||||
} u;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
/* Allocate and initialise structure */
|
||||
@@ -1630,12 +1622,8 @@ static int usbio_start ( struct efi_device *efidev ) {
|
||||
INIT_LIST_HEAD ( &usbio->endpoints );
|
||||
|
||||
/* Open USB I/O protocol */
|
||||
if ( ( efirc = bs->OpenProtocol ( handle, &efi_usb_io_protocol_guid,
|
||||
&u.interface, efi_image_handle,
|
||||
handle,
|
||||
( EFI_OPEN_PROTOCOL_BY_DRIVER |
|
||||
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
||||
rc = -EEFI ( efirc );
|
||||
if ( ( rc = efi_open_by_driver ( handle, &efi_usb_io_protocol_guid,
|
||||
&u.interface ) ) != 0 ) {
|
||||
DBGC ( usbio, "USBIO %s cannot open USB I/O protocol: %s\n",
|
||||
efi_handle_name ( handle ), strerror ( rc ) );
|
||||
DBGC_EFI_OPENERS ( usbio, handle, &efi_usb_io_protocol_guid );
|
||||
@@ -1692,8 +1680,7 @@ static int usbio_start ( struct efi_device *efidev ) {
|
||||
free ( usbio->config );
|
||||
err_config:
|
||||
list_del ( &usbio->dev.siblings );
|
||||
bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
efi_close_by_driver ( handle, &efi_usb_io_protocol_guid );
|
||||
err_open_usbio:
|
||||
free ( usbio );
|
||||
err_alloc:
|
||||
@@ -1706,7 +1693,6 @@ static int usbio_start ( struct efi_device *efidev ) {
|
||||
* @v efidev EFI device
|
||||
*/
|
||||
static void usbio_stop ( struct efi_device *efidev ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
EFI_HANDLE handle = efidev->device;
|
||||
struct usbio_device *usbio = efidev_get_drvdata ( efidev );
|
||||
|
||||
@@ -1716,8 +1702,7 @@ static void usbio_stop ( struct efi_device *efidev ) {
|
||||
free ( usbio->path );
|
||||
free ( usbio->config );
|
||||
list_del ( &usbio->dev.siblings );
|
||||
bs->CloseProtocol ( handle, &efi_usb_io_protocol_guid,
|
||||
efi_image_handle, handle );
|
||||
efi_close_by_driver ( handle, &efi_usb_io_protocol_guid );
|
||||
free ( usbio );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user