Pārlūkot izejas kodu

[efi] Allow calls to efi_snp_claim() and efi_snp_release() to be nested

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 gadus atpakaļ
vecāks
revīzija
9869ee5125
2 mainītis faili ar 8 papildinājumiem un 7 dzēšanām
  1. 3
    3
      src/include/ipxe/efi/efi_snp.h
  2. 5
    4
      src/interface/efi/efi_snp.c

+ 3
- 3
src/include/ipxe/efi/efi_snp.h Parādīt failu

@@ -73,14 +73,14 @@ extern int efi_snp_hii_install ( struct efi_snp_device *snpdev );
73 73
 extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev );
74 74
 extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle );
75 75
 extern struct efi_snp_device * last_opened_snpdev ( void );
76
-extern void efi_snp_set_claimed ( int claimed );
76
+extern void efi_snp_add_claim ( int delta );
77 77
 
78 78
 /**
79 79
  * Claim network devices for use by iPXE
80 80
  *
81 81
  */
82 82
 static inline void efi_snp_claim ( void ) {
83
-	efi_snp_set_claimed ( 1 );
83
+	efi_snp_add_claim ( +1 );
84 84
 }
85 85
 
86 86
 /**
@@ -88,7 +88,7 @@ static inline void efi_snp_claim ( void ) {
88 88
  *
89 89
  */
90 90
 static inline void efi_snp_release ( void ) {
91
-	efi_snp_set_claimed ( 0 );
91
+	efi_snp_add_claim ( -1 );
92 92
 }
93 93
 
94 94
 #endif /* _IPXE_EFI_SNP_H */

+ 5
- 4
src/interface/efi/efi_snp.c Parādīt failu

@@ -1231,15 +1231,16 @@ struct efi_snp_device * last_opened_snpdev ( void ) {
1231 1231
 }
1232 1232
 
1233 1233
 /**
1234
- * Set SNP claimed/released state
1234
+ * Add to SNP claimed/released count
1235 1235
  *
1236
- * @v claimed		Network devices are claimed for use by iPXE
1236
+ * @v delta		Claim count change
1237 1237
  */
1238
-void efi_snp_set_claimed ( int claimed ) {
1238
+void efi_snp_add_claim ( int delta ) {
1239 1239
 	struct efi_snp_device *snpdev;
1240 1240
 
1241 1241
 	/* Claim SNP devices */
1242
-	efi_snp_claimed = claimed;
1242
+	efi_snp_claimed += delta;
1243
+	assert ( efi_snp_claimed >= 0 );
1243 1244
 
1244 1245
 	/* Update SNP mode state for each interface */
1245 1246
 	list_for_each_entry ( snpdev, &efi_snp_devices, list )

Notiek ielāde…
Atcelt
Saglabāt