]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Allow calls to efi_snp_claim() and efi_snp_release() to be nested
authorMichael Brown <mcb30@ipxe.org>
Tue, 1 Sep 2015 15:19:08 +0000 (16:19 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 1 Sep 2015 20:04:45 +0000 (21:04 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/efi/efi_snp.h
src/interface/efi/efi_snp.c

index 1e5c6662662869a339ee86561659a9a2c40b40b1..4c5461ec4d0143236560c9ceb4e5a3617662063d 100644 (file)
@@ -73,14 +73,14 @@ extern int efi_snp_hii_install ( struct efi_snp_device *snpdev );
 extern void efi_snp_hii_uninstall ( struct efi_snp_device *snpdev );
 extern struct efi_snp_device * find_snpdev ( EFI_HANDLE handle );
 extern struct efi_snp_device * last_opened_snpdev ( void );
-extern void efi_snp_set_claimed ( int claimed );
+extern void efi_snp_add_claim ( int delta );
 
 /**
  * Claim network devices for use by iPXE
  *
  */
 static inline void efi_snp_claim ( void ) {
-       efi_snp_set_claimed ( 1 );
+       efi_snp_add_claim ( +1 );
 }
 
 /**
@@ -88,7 +88,7 @@ static inline void efi_snp_claim ( void ) {
  *
  */
 static inline void efi_snp_release ( void ) {
-       efi_snp_set_claimed ( 0 );
+       efi_snp_add_claim ( -1 );
 }
 
 #endif /* _IPXE_EFI_SNP_H */
index c2604580fab25947a1824d2aa91e9cc6e2dd4c78..b7debe7b02542c019d6b898ae1a792fe9744e85c 100644 (file)
@@ -1231,15 +1231,16 @@ struct efi_snp_device * last_opened_snpdev ( void ) {
 }
 
 /**
- * Set SNP claimed/released state
+ * Add to SNP claimed/released count
  *
- * @v claimed          Network devices are claimed for use by iPXE
+ * @v delta            Claim count change
  */
-void efi_snp_set_claimed ( int claimed ) {
+void efi_snp_add_claim ( int delta ) {
        struct efi_snp_device *snpdev;
 
        /* Claim SNP devices */
-       efi_snp_claimed = claimed;
+       efi_snp_claimed += delta;
+       assert ( efi_snp_claimed >= 0 );
 
        /* Update SNP mode state for each interface */
        list_for_each_entry ( snpdev, &efi_snp_devices, list )