[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:
parent
2e0821b9ed
commit
60891f699a
@ -334,24 +334,24 @@ static struct net_device_operations snpnet_operations = {
|
|||||||
static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
|
static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
|
||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *devpath = efidev->path;
|
EFI_DEVICE_PATH_PROTOCOL *devpath = efidev->path;
|
||||||
|
EFI_HANDLE device = efidev->device;
|
||||||
struct pci_device pci;
|
struct pci_device pci;
|
||||||
EFI_HANDLE device;
|
EFI_HANDLE pci_device;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Check for presence of PCI I/O protocol */
|
/* Check for presence of PCI I/O protocol */
|
||||||
if ( ( efirc = bs->LocateDevicePath ( &efi_pci_io_protocol_guid,
|
if ( ( efirc = bs->LocateDevicePath ( &efi_pci_io_protocol_guid,
|
||||||
&devpath, &device ) ) != 0 ) {
|
&devpath, &pci_device ) ) != 0 ) {
|
||||||
DBGC ( efidev->device, "SNP %p %s is not a PCI device\n",
|
DBGC ( device, "SNP %p %s is not a PCI device\n",
|
||||||
efidev->device, efi_devpath_text ( efidev->path ) );
|
device, efi_handle_name ( device ) );
|
||||||
return -EEFI ( efirc );
|
return -EEFI ( efirc );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get PCI device information */
|
/* Get PCI device information */
|
||||||
if ( ( rc = efipci_info ( device, &pci ) ) != 0 ) {
|
if ( ( rc = efipci_info ( pci_device, &pci ) ) != 0 ) {
|
||||||
DBGC ( efidev->device, "SNP %p %s could not get PCI "
|
DBGC ( device, "SNP %p %s could not get PCI information: %s\n",
|
||||||
"information: %s\n", efidev->device,
|
device, efi_handle_name ( device ), strerror ( rc ) );
|
||||||
efi_devpath_text ( efidev->path ), strerror ( rc ) );
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,15 +370,15 @@ static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
|
static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
|
||||||
|
EFI_HANDLE device = efidev->device;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Try getting underlying PCI device information */
|
/* Try getting underlying PCI device information */
|
||||||
if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
|
if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DBGC ( efidev->device, "SNP %p %s could not get underlying device "
|
DBGC ( device, "SNP %p %s could not get underlying device "
|
||||||
"information\n", efidev->device,
|
"information\n", device, efi_handle_name ( device ) );
|
||||||
efi_devpath_text ( efidev->path ) );
|
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,8 +406,7 @@ int snpnet_start ( struct efi_device *efidev ) {
|
|||||||
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( device, "SNP %p %s cannot open SNP protocol: %s\n",
|
DBGC ( device, "SNP %p %s cannot open SNP protocol: %s\n",
|
||||||
device, efi_devpath_text ( efidev->path ),
|
device, efi_handle_name ( device ), strerror ( rc ) );
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_open_protocol;
|
goto err_open_protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,21 +437,21 @@ int snpnet_start ( struct efi_device *efidev ) {
|
|||||||
( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
|
( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( device, "SNP %p %s could not start: %s\n", device,
|
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;
|
goto err_start;
|
||||||
}
|
}
|
||||||
if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
|
if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
|
||||||
( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
|
( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( device, "SNP %p %s could not shut down: %s\n", device,
|
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;
|
goto err_shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Populate network device parameters */
|
/* Populate network device parameters */
|
||||||
if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
|
if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
|
||||||
DBGC ( device, "SNP %p %s has invalid hardware address "
|
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 );
|
mode->HwAddressSize );
|
||||||
rc = -ENOTSUP;
|
rc = -ENOTSUP;
|
||||||
goto err_hw_addr_len;
|
goto err_hw_addr_len;
|
||||||
@ -461,7 +460,7 @@ int snpnet_start ( struct efi_device *efidev ) {
|
|||||||
netdev->ll_protocol->hw_addr_len );
|
netdev->ll_protocol->hw_addr_len );
|
||||||
if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
|
if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
|
||||||
DBGC ( device, "SNP %p %s has invalid link-layer address "
|
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 );
|
mode->HwAddressSize );
|
||||||
rc = -ENOTSUP;
|
rc = -ENOTSUP;
|
||||||
goto err_ll_addr_len;
|
goto err_ll_addr_len;
|
||||||
@ -474,8 +473,8 @@ int snpnet_start ( struct efi_device *efidev ) {
|
|||||||
/* Register network device */
|
/* Register network device */
|
||||||
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
if ( ( rc = register_netdev ( netdev ) ) != 0 )
|
||||||
goto err_register_netdev;
|
goto err_register_netdev;
|
||||||
DBGC ( device, "SNP %p %s registered as %s\n", device,
|
DBGC ( device, "SNP %p %s registered as %s\n",
|
||||||
efi_devpath_text ( efidev->path ), netdev->name );
|
device, efi_handle_name ( device ), netdev->name );
|
||||||
|
|
||||||
/* Set initial link state */
|
/* Set initial link state */
|
||||||
if ( snp->snp->Mode->MediaPresentSupported ) {
|
if ( snp->snp->Mode->MediaPresentSupported ) {
|
||||||
@ -512,6 +511,7 @@ void snpnet_stop ( struct efi_device *efidev ) {
|
|||||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||||
struct net_device *netdev = efidev_get_drvdata ( efidev );
|
struct net_device *netdev = efidev_get_drvdata ( efidev );
|
||||||
struct snp_nic *snp = netdev->priv;
|
struct snp_nic *snp = netdev->priv;
|
||||||
|
EFI_HANDLE device = efidev->device;
|
||||||
EFI_STATUS efirc;
|
EFI_STATUS efirc;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@ -521,9 +521,8 @@ void snpnet_stop ( struct efi_device *efidev ) {
|
|||||||
/* Stop SNP protocol */
|
/* Stop SNP protocol */
|
||||||
if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
|
if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( efidev->device, "SNP %p %s could not stop: %s\n",
|
DBGC ( device, "SNP %p %s could not stop: %s\n", device,
|
||||||
efidev->device, efi_devpath_text ( efidev->path ),
|
efi_handle_name ( device ), strerror ( rc ) );
|
||||||
strerror ( rc ) );
|
|
||||||
/* Nothing we can do about this */
|
/* Nothing we can do about this */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,6 +532,6 @@ void snpnet_stop ( struct efi_device *efidev ) {
|
|||||||
netdev_put ( netdev );
|
netdev_put ( netdev );
|
||||||
|
|
||||||
/* Close SNP protocol */
|
/* Close SNP protocol */
|
||||||
bs->CloseProtocol ( efidev->device, &efi_simple_network_protocol_guid,
|
bs->CloseProtocol ( device, &efi_simple_network_protocol_guid,
|
||||||
efi_image_handle, efidev->device );
|
efi_image_handle, device );
|
||||||
}
|
}
|
||||||
|
@ -238,12 +238,12 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
|
|||||||
&bofm1.interface ) ) != 0 ) {
|
&bofm1.interface ) ) != 0 ) {
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( device, "EFIBOFM %p %s cannot find BOFM protocol\n",
|
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;
|
goto err_locate_bofm;
|
||||||
}
|
}
|
||||||
bofmtab = &bofm1.bofm1->BofmTable;
|
bofmtab = &bofm1.bofm1->BofmTable;
|
||||||
DBGC ( device, "EFIBOFM %p %s found version 1 BOFM table at %p+%04x\n",
|
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 );
|
bofmtab->Parameters.Length );
|
||||||
|
|
||||||
/* Locate BOFM2 protocol, if available */
|
/* Locate BOFM2 protocol, if available */
|
||||||
@ -251,35 +251,35 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
|
|||||||
&bofm2.interface ) ) == 0 ) {
|
&bofm2.interface ) ) == 0 ) {
|
||||||
bofmtab2 = &bofm2.bofm2->BofmTable;
|
bofmtab2 = &bofm2.bofm2->BofmTable;
|
||||||
DBGC ( device, "EFIBOFM %p %s found version 2 BOFM table at "
|
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 );
|
bofmtab2, bofmtab2->Parameters.Length );
|
||||||
assert ( bofm2.bofm2->RegisterSupport ==
|
assert ( bofm2.bofm2->RegisterSupport ==
|
||||||
bofm1.bofm1->RegisterSupport );
|
bofm1.bofm1->RegisterSupport );
|
||||||
} else {
|
} else {
|
||||||
DBGC ( device, "EFIBOFM %p %s cannot find BOFM2 protocol\n",
|
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 */
|
/* Not a fatal error; may be a BOFM1-only system */
|
||||||
bofmtab2 = NULL;
|
bofmtab2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process BOFM table */
|
/* Process BOFM table */
|
||||||
DBGC2 ( device, "EFIBOFM %p %s version 1 before processing:\n",
|
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 );
|
DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
|
||||||
if ( bofmtab2 ) {
|
if ( bofmtab2 ) {
|
||||||
DBGC2 ( device, "EFIBOFM %p %s version 2 before processing:\n",
|
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 );
|
DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
|
||||||
}
|
}
|
||||||
bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
|
bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
|
||||||
DBGC ( device, "EFIBOFM %p %s status %08x\n",
|
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",
|
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 );
|
DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
|
||||||
if ( bofmtab2 ) {
|
if ( bofmtab2 ) {
|
||||||
DBGC2 ( device, "EFIBOFM %p %s version 2 after processing:\n",
|
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 );
|
DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,9 +289,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
|
|||||||
FALSE, bofmrc ) ) != 0){
|
FALSE, bofmrc ) ) != 0){
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( device, "EFIBOFM %p %s could not set BOFM2 "
|
DBGC ( device, "EFIBOFM %p %s could not set BOFM2 "
|
||||||
"status: %s\n",
|
"status: %s\n", device,
|
||||||
device, efi_devpath_text ( efidev->path ),
|
efi_handle_name ( device ), strerror ( rc ) );
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_set_status;
|
goto err_set_status;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -299,9 +298,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
|
|||||||
FALSE, bofmrc ) ) != 0){
|
FALSE, bofmrc ) ) != 0){
|
||||||
rc = -EEFI ( efirc );
|
rc = -EEFI ( efirc );
|
||||||
DBGC ( device, "EFIBOFM %p %s could not set BOFM "
|
DBGC ( device, "EFIBOFM %p %s could not set BOFM "
|
||||||
"status: %s\n",
|
"status: %s\n", device,
|
||||||
device, efi_devpath_text ( efidev->path ),
|
efi_handle_name ( device ), strerror ( rc ) );
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_set_status;
|
goto err_set_status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,15 +291,14 @@ static int efipci_start ( struct efi_device *efidev ) {
|
|||||||
EFI_OPEN_PROTOCOL_EXCLUSIVE ),
|
EFI_OPEN_PROTOCOL_EXCLUSIVE ),
|
||||||
pci ) ) != 0 ) {
|
pci ) ) != 0 ) {
|
||||||
DBGC ( device, "EFIPCI %p %s could not open PCI device: %s\n",
|
DBGC ( device, "EFIPCI %p %s could not open PCI device: %s\n",
|
||||||
device, efi_devpath_text ( efidev->path ),
|
device, efi_handle_name ( device ), strerror ( rc ) );
|
||||||
strerror ( rc ) );
|
|
||||||
goto err_open;
|
goto err_open;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find driver */
|
/* Find driver */
|
||||||
if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
|
if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
|
||||||
DBGC ( device, "EFIPCI %p %s has no driver\n",
|
DBGC ( device, "EFIPCI %p %s has no driver\n",
|
||||||
device, efi_devpath_text ( efidev->path ) );
|
device, efi_handle_name ( device ) );
|
||||||
goto err_find_driver;
|
goto err_find_driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,12 +309,12 @@ static int efipci_start ( struct efi_device *efidev ) {
|
|||||||
/* Probe driver */
|
/* Probe driver */
|
||||||
if ( ( rc = pci_probe ( pci ) ) != 0 ) {
|
if ( ( rc = pci_probe ( pci ) ) != 0 ) {
|
||||||
DBGC ( device, "EFIPCI %p %s could not probe driver \"%s\": "
|
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 ) );
|
pci->id->name, strerror ( rc ) );
|
||||||
goto err_probe;
|
goto err_probe;
|
||||||
}
|
}
|
||||||
DBGC ( device, "EFIPCI %p %s using driver \"%s\"\n", device,
|
DBGC ( device, "EFIPCI %p %s using driver \"%s\"\n",
|
||||||
efi_devpath_text ( efidev->path ), pci->id->name );
|
device, efi_handle_name ( device ), pci->id->name );
|
||||||
|
|
||||||
efidev_set_drvdata ( efidev, pci );
|
efidev_set_drvdata ( efidev, pci );
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1045,7 +1045,7 @@ static int efi_snp_probe ( struct net_device *netdev ) {
|
|||||||
if ( ( rc = efidev_child_add ( efidev, snpdev->handle ) ) != 0 ) {
|
if ( ( rc = efidev_child_add ( efidev, snpdev->handle ) ) != 0 ) {
|
||||||
DBGC ( snpdev, "SNPDEV %p could not become child of %p %s: "
|
DBGC ( snpdev, "SNPDEV %p could not become child of %p %s: "
|
||||||
"%s\n", snpdev, efidev->device,
|
"%s\n", snpdev, efidev->device,
|
||||||
efi_devpath_text ( efidev->path ), strerror ( rc ) );
|
efi_handle_name ( efidev->device ), strerror ( rc ) );
|
||||||
goto err_efidev_child_add;
|
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",
|
DBGC ( snpdev, "SNPDEV %p installed for %s as device %p %s\n",
|
||||||
snpdev, netdev->name, snpdev->handle,
|
snpdev, netdev->name, snpdev->handle,
|
||||||
efi_devpath_text ( &snpdev->path ) );
|
efi_handle_name ( snpdev->handle ) );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( snpdev->package_list )
|
if ( snpdev->package_list )
|
||||||
|
Reference in New Issue
Block a user