Sfoglia il codice sorgente

[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 anni fa
parent
commit
60891f699a

+ 23
- 24
src/drivers/net/efi/snpnet.c Vedi File

@@ -334,24 +334,24 @@ static struct net_device_operations snpnet_operations = {
334 334
 static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
335 335
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
336 336
 	EFI_DEVICE_PATH_PROTOCOL *devpath = efidev->path;
337
+	EFI_HANDLE device = efidev->device;
337 338
 	struct pci_device pci;
338
-	EFI_HANDLE device;
339
+	EFI_HANDLE pci_device;
339 340
 	EFI_STATUS efirc;
340 341
 	int rc;
341 342
 
342 343
 	/* Check for presence of PCI I/O protocol */
343 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 348
 		return -EEFI ( efirc );
348 349
 	}
349 350
 
350 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 355
 		return rc;
356 356
 	}
357 357
 
@@ -370,15 +370,15 @@ static int snpnet_pci_info ( struct efi_device *efidev, struct device *dev ) {
370 370
  * @ret rc		Return status code
371 371
  */
372 372
 static int snpnet_dev_info ( struct efi_device *efidev, struct device *dev ) {
373
+	EFI_HANDLE device = efidev->device;
373 374
 	int rc;
374 375
 
375 376
 	/* Try getting underlying PCI device information */
376 377
 	if ( ( rc = snpnet_pci_info ( efidev, dev ) ) == 0 )
377 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 382
 	return -ENOTTY;
383 383
 }
384 384
 
@@ -406,8 +406,7 @@ int snpnet_start ( struct efi_device *efidev ) {
406 406
 					    EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
407 407
 		rc = -EEFI ( efirc );
408 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 410
 		goto err_open_protocol;
412 411
 	}
413 412
 
@@ -438,21 +437,21 @@ int snpnet_start ( struct efi_device *efidev ) {
438 437
 	     ( ( efirc = snp->snp->Start ( snp->snp ) ) != 0 ) ) {
439 438
 		rc = -EEFI ( efirc );
440 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 441
 		goto err_start;
443 442
 	}
444 443
 	if ( ( mode->State == EfiSimpleNetworkInitialized ) &&
445 444
 	     ( ( efirc = snp->snp->Shutdown ( snp->snp ) ) != 0 ) ) {
446 445
 		rc = -EEFI ( efirc );
447 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 448
 		goto err_shutdown;
450 449
 	}
451 450
 
452 451
 	/* Populate network device parameters */
453 452
 	if ( mode->HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
454 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 455
 		       mode->HwAddressSize );
457 456
 		rc = -ENOTSUP;
458 457
 		goto err_hw_addr_len;
@@ -461,7 +460,7 @@ int snpnet_start ( struct efi_device *efidev ) {
461 460
 		 netdev->ll_protocol->hw_addr_len );
462 461
 	if ( mode->HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
463 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 464
 		       mode->HwAddressSize );
466 465
 		rc = -ENOTSUP;
467 466
 		goto err_ll_addr_len;
@@ -474,8 +473,8 @@ int snpnet_start ( struct efi_device *efidev ) {
474 473
 	/* Register network device */
475 474
 	if ( ( rc = register_netdev ( netdev ) ) != 0 )
476 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 479
 	/* Set initial link state */
481 480
 	if ( snp->snp->Mode->MediaPresentSupported ) {
@@ -512,6 +511,7 @@ void snpnet_stop ( struct efi_device *efidev ) {
512 511
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
513 512
 	struct net_device *netdev = efidev_get_drvdata ( efidev );
514 513
 	struct snp_nic *snp = netdev->priv;
514
+	EFI_HANDLE device = efidev->device;
515 515
 	EFI_STATUS efirc;
516 516
 	int rc;
517 517
 
@@ -521,9 +521,8 @@ void snpnet_stop ( struct efi_device *efidev ) {
521 521
 	/* Stop SNP protocol */
522 522
 	if ( ( efirc = snp->snp->Stop ( snp->snp ) ) != 0 ) {
523 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 526
 		/* Nothing we can do about this */
528 527
 	}
529 528
 
@@ -533,6 +532,6 @@ void snpnet_stop ( struct efi_device *efidev ) {
533 532
 	netdev_put ( netdev );
534 533
 
535 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 Vedi File

@@ -238,12 +238,12 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
238 238
 					    &bofm1.interface ) ) != 0 ) {
239 239
 		rc = -EEFI ( efirc );
240 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 242
 		goto err_locate_bofm;
243 243
 	}
244 244
 	bofmtab = &bofm1.bofm1->BofmTable;
245 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 247
 	       bofmtab->Parameters.Length );
248 248
 
249 249
 	/* Locate BOFM2 protocol, if available */
@@ -251,35 +251,35 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
251 251
 					    &bofm2.interface ) ) == 0 ) {
252 252
 		bofmtab2 = &bofm2.bofm2->BofmTable;
253 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 255
 		       bofmtab2, bofmtab2->Parameters.Length );
256 256
 		assert ( bofm2.bofm2->RegisterSupport ==
257 257
 			 bofm1.bofm1->RegisterSupport );
258 258
 	} else {
259 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 261
 		/* Not a fatal error; may be a BOFM1-only system */
262 262
 		bofmtab2 = NULL;
263 263
 	}
264 264
 
265 265
 	/* Process BOFM table */
266 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 268
 	DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
269 269
 	if ( bofmtab2 ) {
270 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 272
 		DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
273 273
 	}
274 274
 	bofmrc = bofm ( virt_to_user ( bofmtab2 ? bofmtab2 : bofmtab ), &pci );
275 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 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 279
 	DBGC2_HD ( device, bofmtab, bofmtab->Parameters.Length );
280 280
 	if ( bofmtab2 ) {
281 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 283
 		DBGC2_HD ( device, bofmtab2, bofmtab2->Parameters.Length );
284 284
 	}
285 285
 
@@ -289,9 +289,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
289 289
 							FALSE, bofmrc ) ) != 0){
290 290
 			rc = -EEFI ( efirc );
291 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 294
 			goto err_set_status;
296 295
 		}
297 296
 	} else {
@@ -299,9 +298,8 @@ static int efi_bofm_start ( struct efi_device *efidev ) {
299 298
 							FALSE, bofmrc ) ) != 0){
300 299
 			rc = -EEFI ( efirc );
301 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 303
 			goto err_set_status;
306 304
 		}
307 305
 	}

+ 5
- 6
src/interface/efi/efi_pci.c Vedi File

@@ -291,15 +291,14 @@ static int efipci_start ( struct efi_device *efidev ) {
291 291
 					    EFI_OPEN_PROTOCOL_EXCLUSIVE ),
292 292
 				  pci ) ) != 0 ) {
293 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 295
 		goto err_open;
297 296
 	}
298 297
 
299 298
 	/* Find driver */
300 299
 	if ( ( rc = pci_find_driver ( pci ) ) != 0 ) {
301 300
 		DBGC ( device, "EFIPCI %p %s has no driver\n",
302
-		       device, efi_devpath_text ( efidev->path ) );
301
+		       device, efi_handle_name ( device ) );
303 302
 		goto err_find_driver;
304 303
 	}
305 304
 
@@ -310,12 +309,12 @@ static int efipci_start ( struct efi_device *efidev ) {
310 309
 	/* Probe driver */
311 310
 	if ( ( rc = pci_probe ( pci ) ) != 0 ) {
312 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 313
 		       pci->id->name, strerror ( rc ) );
315 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 319
 	efidev_set_drvdata ( efidev, pci );
321 320
 	return 0;

+ 2
- 2
src/interface/efi/efi_snp.c Vedi File

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

Loading…
Annulla
Salva