Browse Source

[efi] Allow for non-PCI snpnet devices

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>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
0ce3c97095
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      src/drivers/net/efi/snpnet.c

+ 8
- 7
src/drivers/net/efi/snpnet.c View File

447
  *
447
  *
448
  * @v efidev		EFI device
448
  * @v efidev		EFI device
449
  * @v dev		Generic device to fill in
449
  * @v dev		Generic device to fill in
450
- * @ret rc		Return status code
451
  */
450
  */
452
-static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
451
+static void snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
453
 	EFI_HANDLE device = efidev->device;
452
 	EFI_HANDLE device = efidev->device;
454
 	int rc;
453
 	int rc;
455
 
454
 
456
 	/* Try getting underlying PCI device information */
455
 	/* Try getting underlying PCI device information */
457
 	if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
456
 	if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
458
-		return 0;
457
+		return;
459
 
458
 
459
+	/* If we cannot get any underlying device information, fall
460
+	 * back to providing information about the EFI handle.
461
+	 */
460
 	DBGC ( device, "SNP %p %s could not get underlying device "
462
 	DBGC ( device, "SNP %p %s could not get underlying device "
461
 	       "information\n", device, efi_handle_name ( device ) );
463
 	       "information\n", device, efi_handle_name ( device ) );
462
-	return -ENOTTY;
464
+	dev->desc.bus_type = BUS_TYPE_EFI;
465
+	snprintf ( dev->name, sizeof ( dev->name ), "SNP-%p", device );
463
 }
466
 }
464
 
467
 
465
 /**
468
 /**
506
 	efidev_set_drvdata ( efidev, netdev );
509
 	efidev_set_drvdata ( efidev, netdev );
507
 
510
 
508
 	/* Populate underlying device information */
511
 	/* Populate underlying device information */
509
-	if ( ( rc = snpnet_dev_info ( efidev, &snp->dev ) ) != 0 )
510
-		goto err_info;
512
+	snpnet_dev_info ( efidev, &snp->dev );
511
 	snp->dev.driver_name = "SNP";
513
 	snp->dev.driver_name = "SNP";
512
 	snp->dev.parent = &efidev->dev;
514
 	snp->dev.parent = &efidev->dev;
513
 	list_add ( &snp->dev.siblings, &efidev->dev.children );
515
 	list_add ( &snp->dev.siblings, &efidev->dev.children );
574
  err_shutdown:
576
  err_shutdown:
575
  err_start:
577
  err_start:
576
 	list_del ( &snp->dev.siblings );
578
 	list_del ( &snp->dev.siblings );
577
- err_info:
578
 	netdev_nullify ( netdev );
579
 	netdev_nullify ( netdev );
579
 	netdev_put ( netdev );
580
 	netdev_put ( netdev );
580
  err_alloc:
581
  err_alloc:

Loading…
Cancel
Save