Skip to content

Commit

Permalink
[efi] Allow for non-PCI snpnet devices
Browse files Browse the repository at this point in the history
We currently require information about the underlying PCI device to
populate the snpnet device's name and description.  If the underlying
device is not a PCI device, this will fail and prevent the device from
being registered.

Fix by falling back to populating the device description with
information based on the EFI handle, if no PCI device information is
available.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Sep 4, 2014
1 parent 3bb910c commit 0ce3c97
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/drivers/net/efi/snpnet.c
Expand Up @@ -447,19 +447,22 @@ static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
*
* @v efidev EFI device
* @v dev Generic device to fill in
* @ret rc Return status code
*/
static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
static void 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;
return;

/* If we cannot get any underlying device information, fall
* back to providing information about the EFI handle.
*/
DBGC ( device, "SNP %p %s could not get underlying device "
"information\n", device, efi_handle_name ( device ) );
return -ENOTTY;
dev->desc.bus_type = BUS_TYPE_EFI;
snprintf ( dev->name, sizeof ( dev->name ), "SNP-%p", device );
}

/**
Expand Down Expand Up @@ -506,8 +509,7 @@ int snpnet_start ( struct efi_device *efidev ) {
efidev_set_drvdata ( efidev, netdev );

/* Populate underlying device information */
if ( ( rc = snpnet_dev_info ( efidev, &snp->dev ) ) != 0 )
goto err_info;
snpnet_dev_info ( efidev, &snp->dev );
snp->dev.driver_name = "SNP";
snp->dev.parent = &efidev->dev;
list_add ( &snp->dev.siblings, &efidev->dev.children );
Expand Down Expand Up @@ -574,7 +576,6 @@ int snpnet_start ( struct efi_device *efidev ) {
err_shutdown:
err_start:
list_del ( &snp->dev.siblings );
err_info:
netdev_nullify ( netdev );
netdev_put ( netdev );
err_alloc:
Expand Down

0 comments on commit 0ce3c97

Please sign in to comment.