Преглед изворни кода

[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>
tags/v1.20.1
Michael Brown пре 9 година
родитељ
комит
60891f699a
4 измењених фајлова са 43 додато и 47 уклоњено
  1. 23
    24
      src/drivers/net/efi/snpnet.c
  2. 13
    15
      src/interface/efi/efi_bofm.c
  3. 5
    6
      src/interface/efi/efi_pci.c
  4. 2
    2
      src/interface/efi/efi_snp.c

+ 23
- 24
src/drivers/net/efi/snpnet.c Прегледај датотеку

334
 static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
334
 static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
335
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
335
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
336
 	EFI_DEVICE_PATH_PROTOCOL *devpath = efidev->path;
336
 	EFI_DEVICE_PATH_PROTOCOL *devpath = efidev->path;
337
+	EFI_HANDLE device = efidev->device;
337
 	struct pci_device pci;
338
 	struct pci_device pci;
338
-	EFI_HANDLE device;
339
+	EFI_HANDLE pci_device;
339
 	EFI_STATUS efirc;
340
 	EFI_STATUS efirc;
340
 	int rc;
341
 	int rc;
341
 
342
 
342
 	/* Check for presence of PCI I/O protocol */
343
 	/* Check for presence of PCI I/O protocol */
343
 	if ( ( efirc = bs->LocateDevicePath ( &efi_pci_io_protocol_guid,
344
 	if ( ( efirc = bs->LocateDevicePath ( &efi_pci_io_protocol_guid,
344
-					      &devpath, &device ) ) != 0 ) {
345
-		DBGC ( efidev->device, "SNP %p %s is not a PCI device\n",
346
-		       efidev->device, efi_devpath_text ( efidev->path ) );
345
+					      &devpath, &pci_device ) ) != 0 ) {
346
+		DBGC ( device, "SNP %p %s is not a PCI device\n",
347
+		       device, efi_handle_name ( device ) );
347
 		return -EEFI ( efirc );
348
 		return -EEFI ( efirc );
348
 	}
349
 	}
349
 
350
 
350
 	/* Get PCI device information */
351
 	/* Get PCI device information */
351
-	if ( ( rc = efipci_info ( device, &pci ) ) != 0 ) {
352
-		DBGC ( efidev->device, "SNP %p %s could not get PCI "
353
-		       "information: %s\n", efidev->device,
354
-		       efi_devpath_text ( efidev->path ), strerror ( rc ) );
352
+	if ( ( rc = efipci_info ( pci_device, &pci ) ) != 0 ) {
353
+		DBGC ( device, "SNP %p %s could not get PCI information: %s\n",
354
+		       device, efi_handle_name ( device ), strerror ( rc ) );
355
 		return rc;
355
 		return rc;
356
 	}
356
 	}
357
 
357
 
370
  * @ret rc		Return status code
370
  * @ret rc		Return status code
371
  */
371
  */
372
 static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
372
 static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
373
+	EFI_HANDLE device = efidev->device;
373
 	int rc;
374
 	int rc;
374
 
375
 
375
 	/* Try getting underlying PCI device information */
376
 	/* Try getting underlying PCI device information */
376
 	if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
377
 	if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
377
 		return 0;
378
 		return 0;
378
 
379
 
379
-	DBGC ( efidev->device, "SNP %p %s could not get underlying device "
380
-	       "information\n", efidev->device,
381
-	       efi_devpath_text ( efidev->path ) );
380
+	DBGC ( device, "SNP %p %s could not get underlying device "
381
+	       "information\n", device, efi_handle_name ( device ) );
382
 	return -ENOTTY;
382
 	return -ENOTTY;
383
 }
383
 }
384
 
384
 
406
 					    EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
406
 					    EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
407
 		rc = -EEFI ( efirc );
407
 		rc = -EEFI ( efirc );
408
 		DBGC ( device, "SNP %p %s cannot open SNP protocol: %s\n",
408
 		DBGC ( device, "SNP %p %s cannot open SNP protocol: %s\n",
409
-		       device, efi_devpath_text ( efidev->path ),
410
-		       strerror ( rc ) );
409
+		       device, efi_handle_name ( device ), strerror ( rc ) );
411
 		goto err_open_protocol;
410
 		goto err_open_protocol;
412
 	}
411
 	}
413
 
412
 
438
 	     ( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
437
 	     ( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
439
 		rc = -EEFI ( efirc );
438
 		rc = -EEFI ( efirc );
440
 		DBGC ( device, "SNP %p %s could not start: %s\n", device,
439
 		DBGC ( device, "SNP %p %s could not start: %s\n", device,
441
-		       efi_devpath_text ( efidev->path ), strerror ( rc ) );
440
+		       efi_handle_name ( device ), strerror ( rc ) );
442
 		goto err_start;
441
 		goto err_start;
443
 	}
442
 	}
444
 	if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
443
 	if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
445
 	     ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
444
 	     ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
446
 		rc = -EEFI ( efirc );
445
 		rc = -EEFI ( efirc );
447
 		DBGC ( device, "SNP %p %s could not shut down: %s\n", device,
446
 		DBGC ( device, "SNP %p %s could not shut down: %s\n", device,
448
-		       efi_devpath_text ( efidev->path ), strerror ( rc ) );
447
+		       efi_handle_name ( device ), strerror ( rc ) );
449
 		goto err_shutdown;
448
 		goto err_shutdown;
450
 	}
449
 	}
451
 
450
 
452
 	/* Populate network device parameters */
451
 	/* Populate network device parameters */
453
 	if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
452
 	if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
454
 		DBGC ( device, "SNP %p %s has invalid hardware address "
453
 		DBGC ( device, "SNP %p %s has invalid hardware address "
455
-		       "length %d\n", device, efi_devpath_text ( efidev->path ),
454
+		       "length %d\n", device, efi_handle_name ( device ),
456
 		       mode->HwAddressSize );
455
 		       mode->HwAddressSize );
457
 		rc = -ENOTSUP;
456
 		rc = -ENOTSUP;
458
 		goto err_hw_addr_len;
457
 		goto err_hw_addr_len;
461
 		 netdev->ll_protocol->hw_addr_len );
460
 		 netdev->ll_protocol->hw_addr_len );
462
 	if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
461
 	if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
463
 		DBGC ( device, "SNP %p %s has invalid link-layer address "
462
 		DBGC ( device, "SNP %p %s has invalid link-layer address "
464
-		       "length %d\n", device, efi_devpath_text ( efidev->path ),
463
+		       "length %d\n", device, efi_handle_name ( device ),
465
 		       mode->HwAddressSize );
464
 		       mode->HwAddressSize );
466
 		rc = -ENOTSUP;
465
 		rc = -ENOTSUP;
467
 		goto err_ll_addr_len;
466
 		goto err_ll_addr_len;
474
 	/* Register network device */
473
 	/* Register network device */
475
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
474
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
476
 		goto err_register_netdev;
475
 		goto err_register_netdev;
477
-	DBGC ( device, "SNP %p %s registered as %s\n", device,
478
-	       efi_devpath_text ( efidev->path ), netdev->name );
476
+	DBGC ( device, "SNP %p %s registered as %s\n",
477
+	       device, efi_handle_name ( device ), netdev->name );
479
 
478
 
480
 	/* Set initial link state */
479
 	/* Set initial link state */
481
 	if ( snp->snp->Mode->MediaPresentSupported ) {
480
 	if ( snp->snp->Mode->MediaPresentSupported ) {
512
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
511
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
513
 	struct net_device *netdev = efidev_get_drvdata ( efidev );
512
 	struct net_device *netdev = efidev_get_drvdata ( efidev );
514
 	struct snp_nic *snp = netdev->priv;
513
 	struct snp_nic *snp = netdev->priv;
514
+	EFI_HANDLE device = efidev->device;
515
 	EFI_STATUS efirc;
515
 	EFI_STATUS efirc;
516
 	int rc;
516
 	int rc;
517
 
517
 
521
 	/* Stop SNP protocol */
521
 	/* Stop SNP protocol */
522
 	if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
522
 	if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
523
 		rc = -EEFI ( efirc );
523
 		rc = -EEFI ( efirc );
524
-		DBGC ( efidev->device, "SNP %p %s could not stop: %s\n",
525
-		       efidev->device, efi_devpath_text ( efidev->path ),
526
-		       strerror ( rc ) );
524
+		DBGC ( device, "SNP %p %s could not stop: %s\n", device,
525
+		       efi_handle_name ( device ), strerror ( rc ) );
527
 		/* Nothing we can do about this */
526
 		/* Nothing we can do about this */
528
 	}
527
 	}
529
 
528
 
533
 	netdev_put ( netdev );
532
 	netdev_put ( netdev );
534
 
533
 
535
 	/* Close SNP protocol */
534
 	/* Close SNP protocol */
536
-	bs->CloseProtocol ( efidev->device, &efi_simple_network_protocol_guid,
537
-			    efi_image_handle, efidev->device );
535
+	bs->CloseProtocol ( device, &efi_simple_network_protocol_guid,
536
+			    efi_image_handle, device );
538
 }
537
 }

+ 13
- 15
src/interface/efi/efi_bofm.c Прегледај датотеку

238
 					    &bofm1.interface ) ) != 0 ) {
238
 					    &bofm1.interface ) ) != 0 ) {
239
 		rc = -EEFI ( efirc );
239
 		rc = -EEFI ( efirc );
240
 		DBGC ( device, "EFIBOFM %p %s cannot find BOFM protocol\n",
240
 		DBGC ( device, "EFIBOFM %p %s cannot find BOFM protocol\n",
241
-		       device, efi_devpath_text ( efidev->path ) );
241
+		       device, efi_handle_name ( device ) );
242
 		goto err_locate_bofm;
242
 		goto err_locate_bofm;
243
 	}
243
 	}
244
 	bofmtab = &bofm1.bofm1->BofmTable;
244
 	bofmtab = &bofm1.bofm1->BofmTable;
245
 	DBGC ( device, "EFIBOFM %p %s found version 1 BOFM table at %p+%04x\n",
245
 	DBGC ( device, "EFIBOFM %p %s found version 1 BOFM table at %p+%04x\n",
246
-	       device, efi_devpath_text ( efidev->path ), bofmtab,
246
+	       device, efi_handle_name ( device ), bofmtab,
247
 	       bofmtab->Parameters.Length );
247
 	       bofmtab->Parameters.Length );
248
 
248
 
249
 	/* Locate BOFM2 protocol, if available */
249
 	/* Locate BOFM2 protocol, if available */
251
 					    &bofm2.interface ) ) == 0 ) {
251
 					    &bofm2.interface ) ) == 0 ) {
252
 		bofmtab2 = &bofm2.bofm2->BofmTable;
252
 		bofmtab2 = &bofm2.bofm2->BofmTable;
253
 		DBGC ( device, "EFIBOFM %p %s found version 2 BOFM table at "
253
 		DBGC ( device, "EFIBOFM %p %s found version 2 BOFM table at "
254
-		       "%p+%04x\n", device, efi_devpath_text ( efidev->path ),
254
+		       "%p+%04x\n", device, efi_handle_name ( device ),
255
 		       bofmtab2, bofmtab2->Parameters.Length );
255
 		       bofmtab2, bofmtab2->Parameters.Length );
256
 		assert ( bofm2.bofm2->RegisterSupport ==
256
 		assert ( bofm2.bofm2->RegisterSupport ==
257
 			 bofm1.bofm1->RegisterSupport );
257
 			 bofm1.bofm1->RegisterSupport );
258
 	} else {
258
 	} else {
259
 		DBGC ( device, "EFIBOFM %p %s cannot find BOFM2 protocol\n",
259
 		DBGC ( device, "EFIBOFM %p %s cannot find BOFM2 protocol\n",
260
-		       device, efi_devpath_text ( efidev->path ) );
260
+		       device, efi_handle_name ( device ) );
261
 		/* Not a fatal error; may be a BOFM1-only system */
261
 		/* Not a fatal error; may be a BOFM1-only system */
262
 		bofmtab2 = NULL;
262
 		bofmtab2 = NULL;
263
 	}
263
 	}
264
 
264
 
265
 	/* Process BOFM table */
265
 	/* Process BOFM table */
266
 	DBGC2 ( device, "EFIBOFM %p %s version 1 before processing:\n",
266
 	DBGC2 ( device, "EFIBOFM %p %s version 1 before processing:\n",
267
-		device, efi_devpath_text ( efidev->path ) );
267
+		device, efi_handle_name ( device ) );
268
 	DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
268
 	DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
269
 	if ( bofmtab2 ) {
269
 	if ( bofmtab2 ) {
270
 		DBGC2 ( device, "EFIBOFM %p %s version 2 before processing:\n",
270
 		DBGC2 ( device, "EFIBOFM %p %s version 2 before processing:\n",
271
-			device, efi_devpath_text ( efidev->path ) );
271
+			device, efi_handle_name ( device ) );
272
 		DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
272
 		DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
273
 	}
273
 	}
274
 	bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
274
 	bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
275
 	DBGC ( device, "EFIBOFM %p %s status %08x\n",
275
 	DBGC ( device, "EFIBOFM %p %s status %08x\n",
276
-	       device, efi_devpath_text ( efidev->path ), bofmrc );
276
+	       device, efi_handle_name ( device ), bofmrc );
277
 	DBGC2 ( device, "EFIBOFM %p %s version 1 after processing:\n",
277
 	DBGC2 ( device, "EFIBOFM %p %s version 1 after processing:\n",
278
-		device, efi_devpath_text ( efidev->path ) );
278
+		device, efi_handle_name ( device ) );
279
 	DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
279
 	DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
280
 	if ( bofmtab2 ) {
280
 	if ( bofmtab2 ) {
281
 		DBGC2 ( device, "EFIBOFM %p %s version 2 after processing:\n",
281
 		DBGC2 ( device, "EFIBOFM %p %s version 2 after processing:\n",
282
-			device, efi_devpath_text ( efidev->path ) );
282
+			device, efi_handle_name ( device ) );
283
 		DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
283
 		DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
284
 	}
284
 	}
285
 
285
 
289
 							FALSE, bofmrc ) ) != 0){
289
 							FALSE, bofmrc ) ) != 0){
290
 			rc = -EEFI ( efirc );
290
 			rc = -EEFI ( efirc );
291
 			DBGC ( device, "EFIBOFM %p %s could not set BOFM2 "
291
 			DBGC ( device, "EFIBOFM %p %s could not set BOFM2 "
292
-			       "status: %s\n",
293
-			       device, efi_devpath_text ( efidev->path ),
294
-			       strerror ( rc ) );
292
+			       "status: %s\n", device,
293
+			       efi_handle_name ( device ), strerror ( rc ) );
295
 			goto err_set_status;
294
 			goto err_set_status;
296
 		}
295
 		}
297
 	} else {
296
 	} else {
299
 							FALSE, bofmrc ) ) != 0){
298
 							FALSE, bofmrc ) ) != 0){
300
 			rc = -EEFI ( efirc );
299
 			rc = -EEFI ( efirc );
301
 			DBGC ( device, "EFIBOFM %p %s could not set BOFM "
300
 			DBGC ( device, "EFIBOFM %p %s could not set BOFM "
302
-			       "status: %s\n",
303
-			       device, efi_devpath_text ( efidev->path ),
304
-			       strerror ( rc ) );
301
+			       "status: %s\n", device,
302
+			       efi_handle_name ( device ), strerror ( rc ) );
305
 			goto err_set_status;
303
 			goto err_set_status;
306
 		}
304
 		}
307
 	}
305
 	}

+ 5
- 6
src/interface/efi/efi_pci.c Прегледај датотеку

291
 					    EFI_OPEN_PROTOCOL_EXCLUSIVE ),
291
 					    EFI_OPEN_PROTOCOL_EXCLUSIVE ),
292
 				  pci ) ) != 0 ) {
292
 				  pci ) ) != 0 ) {
293
 		DBGC ( device, "EFIPCI %p %s could not open PCI device: %s\n",
293
 		DBGC ( device, "EFIPCI %p %s could not open PCI device: %s\n",
294
-		       device, efi_devpath_text ( efidev->path ),
295
-		       strerror ( rc ) );
294
+		       device, efi_handle_name ( device ), strerror ( rc ) );
296
 		goto err_open;
295
 		goto err_open;
297
 	}
296
 	}
298
 
297
 
299
 	/* Find driver */
298
 	/* Find driver */
300
 	if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
299
 	if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
301
 		DBGC ( device, "EFIPCI %p %s has no driver\n",
300
 		DBGC ( device, "EFIPCI %p %s has no driver\n",
302
-		       device, efi_devpath_text ( efidev->path ) );
301
+		       device, efi_handle_name ( device ) );
303
 		goto err_find_driver;
302
 		goto err_find_driver;
304
 	}
303
 	}
305
 
304
 
310
 	/* Probe driver */
309
 	/* Probe driver */
311
 	if ( ( rc = pci_probe ( pci ) ) != 0 ) {
310
 	if ( ( rc = pci_probe ( pci ) ) != 0 ) {
312
 		DBGC ( device, "EFIPCI %p %s could not probe driver \"%s\": "
311
 		DBGC ( device, "EFIPCI %p %s could not probe driver \"%s\": "
313
-		       "%s\n", device, efi_devpath_text ( efidev->path ),
312
+		       "%s\n", device, efi_handle_name ( device ),
314
 		       pci->id->name, strerror ( rc ) );
313
 		       pci->id->name, strerror ( rc ) );
315
 		goto err_probe;
314
 		goto err_probe;
316
 	}
315
 	}
317
-	DBGC ( device, "EFIPCI %p %s using driver \"%s\"\n", device,
318
-	       efi_devpath_text ( efidev->path ), pci->id->name );
316
+	DBGC ( device, "EFIPCI %p %s using driver \"%s\"\n",
317
+	       device, efi_handle_name ( device ), pci->id->name );
319
 
318
 
320
 	efidev_set_drvdata ( efidev, pci );
319
 	efidev_set_drvdata ( efidev, pci );
321
 	return 0;
320
 	return 0;

+ 2
- 2
src/interface/efi/efi_snp.c Прегледај датотеку

1045
 	if ( ( rc = efidev_child_add ( efidev, snpdev->handle ) ) != 0 ) {
1045
 	if ( ( rc = efidev_child_add ( efidev, snpdev->handle ) ) != 0 ) {
1046
 		DBGC ( snpdev, "SNPDEV %p could not become child of %p %s: "
1046
 		DBGC ( snpdev, "SNPDEV %p could not become child of %p %s: "
1047
 		       "%s\n", snpdev, efidev->device,
1047
 		       "%s\n", snpdev, efidev->device,
1048
-		       efi_devpath_text ( efidev->path ), strerror ( rc ) );
1048
+		       efi_handle_name ( efidev->device ), strerror ( rc ) );
1049
 		goto err_efidev_child_add;
1049
 		goto err_efidev_child_add;
1050
 	}
1050
 	}
1051
 
1051
 
1064
 
1064
 
1065
 	DBGC ( snpdev, "SNPDEV %p installed for %s as device %p %s\n",
1065
 	DBGC ( snpdev, "SNPDEV %p installed for %s as device %p %s\n",
1066
 	       snpdev, netdev->name, snpdev->handle,
1066
 	       snpdev, netdev->name, snpdev->handle,
1067
-	       efi_devpath_text ( &snpdev->path ) );
1067
+	       efi_handle_name ( snpdev->handle ) );
1068
 	return 0;
1068
 	return 0;
1069
 
1069
 
1070
 	if ( snpdev->package_list )
1070
 	if ( snpdev->package_list )

Loading…
Откажи
Сачувај