]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Use efi_handle_name() instead of efi_devpath_text() where applicable
authorMichael Brown <mcb30@ipxe.org>
Thu, 31 Jul 2014 10:21:09 +0000 (11:21 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 31 Jul 2014 10:57:31 +0000 (11:57 +0100)
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>
src/drivers/net/efi/snpnet.c
src/interface/efi/efi_bofm.c
src/interface/efi/efi_pci.c
src/interface/efi/efi_snp.c

index f005dfb9fd5e3cc2c141a30bf06afe2315617643..acba3ed36ebfe6d014c68cc69c0283ebf0c672db 100644 (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 );
 }
index 8d277e8117bc08b51a1a6d94b0af3097ba43fc81..bdb7051969e312b0e6b8bcee9f8794217eac3bc6 100644 (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;
                }
        }
index 5b58c9b6bd693992576a23e9d4ea2695341a0071..1cd4e63b253f45c3e2d223380ab78fcc012acf01 100644 (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;
index d869c30f835ec7b19b5128164cd369fb240a067e..dd64fd3b97121962ed50624da1350c06738ef975 100644 (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 )