david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[efi] Use efi_handle_name() instead of efi_devpath_text() where applicable

Using efi_devpath_text() is marginally more efficient if we already
have the device path protocol available, but the mild increase in
efficiency is not worth compromising the clarity of the pattern:

  DBGC ( device, "THING %p %s ...", device, efi_handle_name ( device ) );

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2014-07-31 11:21:09 +01:00
parent 2e0821b9ed
commit 60891f699a
4 changed files with 43 additions and 47 deletions

View File

@ -334,24 +334,24 @@ static struct net_device_operations snpnet_operations = {
static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_DEVICE_PATH_PROTOCOL *devpath = efidev->path;
EFI_HANDLE device = efidev->device;
struct pci_device pci;
EFI_HANDLE device;
EFI_HANDLE pci_device;
EFI_STATUS efirc;
int rc;
/* Check for presence of PCI I/O protocol */
if ( ( efirc = bs->LocateDevicePath ( &efi_pci_io_protocol_guid,
&devpath, &device ) ) != 0 ) {
DBGC ( efidev->device, "SNP %p %s is not a PCI device\n",
efidev->device, efi_devpath_text ( efidev->path ) );
&devpath, &pci_device ) ) != 0 ) {
DBGC ( device, "SNP %p %s is not a PCI device\n",
device, efi_handle_name ( device ) );
return -EEFI ( efirc );
}
/* Get PCI device information */
if ( ( rc = efipci_info ( device, &pci ) ) != 0 ) {
DBGC ( efidev->device, "SNP %p %s could not get PCI "
"information: %s\n", efidev->device,
efi_devpath_text ( efidev->path ), strerror ( rc ) );
if ( ( rc = efipci_info ( pci_device, &pci ) ) != 0 ) {
DBGC ( device, "SNP %p %s could not get PCI information: %s\n",
device, efi_handle_name ( device ), strerror ( rc ) );
return rc;
}
@ -370,15 +370,15 @@ static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
* @ret rc Return status code
*/
static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
EFI_HANDLE device = efidev->device;
int rc;
/* Try getting underlying PCI device information */
if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
return 0;
DBGC ( efidev->device, "SNP %p %s could not get underlying device "
"information\n", efidev->device,
efi_devpath_text ( efidev->path ) );
DBGC ( device, "SNP %p %s could not get underlying device "
"information\n", device, efi_handle_name ( device ) );
return -ENOTTY;
}
@ -406,8 +406,7 @@ int snpnet_start ( struct efi_device *efidev ) {
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
rc = -EEFI ( efirc );
DBGC ( device, "SNP %p %s cannot open SNP protocol: %s\n",
device, efi_devpath_text ( efidev->path ),
strerror ( rc ) );
device, efi_handle_name ( device ), strerror ( rc ) );
goto err_open_protocol;
}
@ -438,21 +437,21 @@ int snpnet_start ( struct efi_device *efidev ) {
( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
rc = -EEFI ( efirc );
DBGC ( device, "SNP %p %s could not start: %s\n", device,
efi_devpath_text ( efidev->path ), strerror ( rc ) );
efi_handle_name ( device ), strerror ( rc ) );
goto err_start;
}
if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
rc = -EEFI ( efirc );
DBGC ( device, "SNP %p %s could not shut down: %s\n", device,
efi_devpath_text ( efidev->path ), strerror ( rc ) );
efi_handle_name ( device ), strerror ( rc ) );
goto err_shutdown;
}
/* Populate network device parameters */
if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
DBGC ( device, "SNP %p %s has invalid hardware address "
"length %d\n", device, efi_devpath_text ( efidev->path ),
"length %d\n", device, efi_handle_name ( device ),
mode->HwAddressSize );
rc = -ENOTSUP;
goto err_hw_addr_len;
@ -461,7 +460,7 @@ int snpnet_start ( struct efi_device *efidev ) {
netdev->ll_protocol->hw_addr_len );
if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
DBGC ( device, "SNP %p %s has invalid link-layer address "
"length %d\n", device, efi_devpath_text ( efidev->path ),
"length %d\n", device, efi_handle_name ( device ),
mode->HwAddressSize );
rc = -ENOTSUP;
goto err_ll_addr_len;
@ -474,8 +473,8 @@ int snpnet_start ( struct efi_device *efidev ) {
/* Register network device */
if ( ( rc = register_netdev ( netdev ) ) != 0 )
goto err_register_netdev;
DBGC ( device, "SNP %p %s registered as %s\n", device,
efi_devpath_text ( efidev->path ), netdev->name );
DBGC ( device, "SNP %p %s registered as %s\n",
device, efi_handle_name ( device ), netdev->name );
/* Set initial link state */
if ( snp->snp->Mode->MediaPresentSupported ) {
@ -512,6 +511,7 @@ 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;
EFI_STATUS efirc;
int rc;
@ -521,9 +521,8 @@ void snpnet_stop ( struct efi_device *efidev ) {
/* Stop SNP protocol */
if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( efidev->device, "SNP %p %s could not stop: %s\n",
efidev->device, efi_devpath_text ( efidev->path ),
strerror ( rc ) );
DBGC ( device, "SNP %p %s could not stop: %s\n", device,
efi_handle_name ( device ), strerror ( rc ) );
/* Nothing we can do about this */
}
@ -533,6 +532,6 @@ void snpnet_stop ( struct efi_device *efidev ) {
netdev_put ( netdev );
/* Close SNP protocol */
bs->CloseProtocol ( efidev->device, &efi_simple_network_protocol_guid,
efi_image_handle, efidev->device );
bs->CloseProtocol ( device, &efi_simple_network_protocol_guid,
efi_image_handle, device );
}

View File

@ -238,12 +238,12 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
&bofm1.interface ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( device, "EFIBOFM %p %s cannot find BOFM protocol\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
goto err_locate_bofm;
}
bofmtab = &bofm1.bofm1->BofmTable;
DBGC ( device, "EFIBOFM %p %s found version 1 BOFM table at %p+%04x\n",
device, efi_devpath_text ( efidev->path ), bofmtab,
device, efi_handle_name ( device ), bofmtab,
bofmtab->Parameters.Length );
/* Locate BOFM2 protocol, if available */
@ -251,35 +251,35 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
&bofm2.interface ) ) == 0 ) {
bofmtab2 = &bofm2.bofm2->BofmTable;
DBGC ( device, "EFIBOFM %p %s found version 2 BOFM table at "
"%p+%04x\n", device, efi_devpath_text ( efidev->path ),
"%p+%04x\n", device, efi_handle_name ( device ),
bofmtab2, bofmtab2->Parameters.Length );
assert ( bofm2.bofm2->RegisterSupport ==
bofm1.bofm1->RegisterSupport );
} else {
DBGC ( device, "EFIBOFM %p %s cannot find BOFM2 protocol\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
/* Not a fatal error; may be a BOFM1-only system */
bofmtab2 = NULL;
}
/* Process BOFM table */
DBGC2 ( device, "EFIBOFM %p %s version 1 before processing:\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
if ( bofmtab2 ) {
DBGC2 ( device, "EFIBOFM %p %s version 2 before processing:\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
}
bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
DBGC ( device, "EFIBOFM %p %s status %08x\n",
device, efi_devpath_text ( efidev->path ), bofmrc );
device, efi_handle_name ( device ), bofmrc );
DBGC2 ( device, "EFIBOFM %p %s version 1 after processing:\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
if ( bofmtab2 ) {
DBGC2 ( device, "EFIBOFM %p %s version 2 after processing:\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
}
@ -289,9 +289,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
FALSE, bofmrc ) ) != 0){
rc = -EEFI ( efirc );
DBGC ( device, "EFIBOFM %p %s could not set BOFM2 "
"status: %s\n",
device, efi_devpath_text ( efidev->path ),
strerror ( rc ) );
"status: %s\n", device,
efi_handle_name ( device ), strerror ( rc ) );
goto err_set_status;
}
} else {
@ -299,9 +298,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
FALSE, bofmrc ) ) != 0){
rc = -EEFI ( efirc );
DBGC ( device, "EFIBOFM %p %s could not set BOFM "
"status: %s\n",
device, efi_devpath_text ( efidev->path ),
strerror ( rc ) );
"status: %s\n", device,
efi_handle_name ( device ), strerror ( rc ) );
goto err_set_status;
}
}

View File

@ -291,15 +291,14 @@ static int efipci_start ( struct efi_device *efidev ) {
EFI_OPEN_PROTOCOL_EXCLUSIVE ),
pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %p %s could not open PCI device: %s\n",
device, efi_devpath_text ( efidev->path ),
strerror ( rc ) );
device, efi_handle_name ( device ), strerror ( rc ) );
goto err_open;
}
/* Find driver */
if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %p %s has no driver\n",
device, efi_devpath_text ( efidev->path ) );
device, efi_handle_name ( device ) );
goto err_find_driver;
}
@ -310,12 +309,12 @@ static int efipci_start ( struct efi_device *efidev ) {
/* Probe driver */
if ( ( rc = pci_probe ( pci ) ) != 0 ) {
DBGC ( device, "EFIPCI %p %s could not probe driver \"%s\": "
"%s\n", device, efi_devpath_text ( efidev->path ),
"%s\n", device, efi_handle_name ( device ),
pci->id->name, strerror ( rc ) );
goto err_probe;
}
DBGC ( device, "EFIPCI %p %s using driver \"%s\"\n", device,
efi_devpath_text ( efidev->path ), pci->id->name );
DBGC ( device, "EFIPCI %p %s using driver \"%s\"\n",
device, efi_handle_name ( device ), pci->id->name );
efidev_set_drvdata ( efidev, pci );
return 0;

View File

@ -1045,7 +1045,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
if ( ( rc = efidev_child_add ( efidev, snpdev->handle ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not become child of %p %s: "
"%s\n", snpdev, efidev->device,
efi_devpath_text ( efidev->path ), strerror ( rc ) );
efi_handle_name ( efidev->device ), strerror ( rc ) );
goto err_efidev_child_add;
}
@ -1064,7 +1064,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
DBGC ( snpdev, "SNPDEV %p installed for %s as device %p %s\n",
snpdev, netdev->name, snpdev->handle,
efi_devpath_text ( &snpdev->path ) );
efi_handle_name ( snpdev->handle ) );
return 0;
if ( snpdev->package_list )