Browse Source

[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 years ago
parent
commit
9869ee5125
2 changed files with 8 additions and 7 deletions
  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 View File

73
 extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev );
73
 extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev );
74
 extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle );
74
 extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle );
75
 extern struct efi_snp_device * last_opened_snpdev ( void );
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
  * Claim network devices for use by iPXE
79
  * Claim network devices for use by iPXE
80
  *
80
  *
81
  */
81
  */
82
 static inline void efi_snp_claim ( void ) {
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
  *
88
  *
89
  */
89
  */
90
 static inline void efi_snp_release ( void ) {
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
 #endif /* _IPXE_EFI_SNP_H */
94
 #endif /* _IPXE_EFI_SNP_H */

+ 5
- 4
src/interface/efi/efi_snp.c View File

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
 	struct efi_snp_device *snpdev;
1239
 	struct efi_snp_device *snpdev;
1240
 
1240
 
1241
 	/* Claim SNP devices */
1241
 	/* Claim SNP devices */
1242
-	efi_snp_claimed = claimed;
1242
+	efi_snp_claimed += delta;
1243
+	assert ( efi_snp_claimed >= 0 );
1243
 
1244
 
1244
 	/* Update SNP mode state for each interface */
1245
 	/* Update SNP mode state for each interface */
1245
 	list_for_each_entry ( snpdev, &efi_snp_devices, list )
1246
 	list_for_each_entry ( snpdev, &efi_snp_devices, list )

Loading…
Cancel
Save