[PATCH] hw_downloading may fail to be unset

Pavel Roskin proski
Wed Jan 28 13:05:38 PST 2004


Hello!

Some errors during genesis RAM download make it impossible to load any
firmware until the card is reinserted.  I don't think it's a good idea.
Another attempt to load firmware could actually succeed.

While prism2_download_volatile() and prism2_download_nonvolatile()
guarantee that local->hw_downloading is unset on exit no matter what
happens, prism2_download_genesis() can leave it set if e.g.
prism2_enable_aux_port() fails.

The attached patch ensures that prism2_download_genesis() always unsets
local->hw_downloading on exit.  I'm not a big fan of "goto", but I tried
to make code resemble prism2_download_volatile() for consistency.

-- 
Regards,
Pavel Roskin
-------------- next part --------------
--- driver/modules/hostap_download.c
+++ driver/modules/hostap_download.c
@@ -388,6 +388,7 @@ static int prism2_download_genesis(local
 {
 	struct net_device *dev = local->dev;
 	int ram16 = 0, i;
+	int ret = 0;
 
 	if (local->hw_downloading) {
 		printk(KERN_WARNING "%s: Already downloading - aborting new "
@@ -406,7 +407,8 @@ static int prism2_download_genesis(local
 	if (prism2_enable_aux_port(dev, 1)) {
 		printk(KERN_DEBUG "%s: failed to enable AUX port\n",
 		       dev->name);
-		return -EIO;
+		ret = -EIO;
+		goto out;
 	}
 
 	if (local->sram_type == -1) {
@@ -422,7 +424,8 @@ static int prism2_download_genesis(local
 		} else {
 			printk(KERN_DEBUG "%s: Could not initiate genesis "
 			       "mode\n", dev->name);
-			return -EIO;
+			ret = -EIO;
+			goto out;
 		}
 	} else {
 		if (prism2_enable_genesis(local, local->sram_type == 8 ?
@@ -430,7 +433,8 @@ static int prism2_download_genesis(local
 			printk(KERN_DEBUG "%s: Failed to set Genesis "
 			       "mode (sram_type=%d)\n", dev->name,
 			       local->sram_type);
-			return -EIO;
+			ret = -EIO;
+			goto out;
 		}
 		ram16 = local->sram_type != 8;
 	}
@@ -443,7 +447,8 @@ static int prism2_download_genesis(local
 			printk(KERN_WARNING "%s: RAM download at 0x%08x "
 			       "(len=%d) failed\n", dev->name,
 			       param->data[i].addr, param->data[i].len);
-			return -EIO;
+			ret = -EIO;
+			goto out;
 		}
 	}
 
@@ -461,17 +466,22 @@ static int prism2_download_genesis(local
 	if (prism2_hw_init(dev, 1)) {
 		printk(KERN_DEBUG "%s: Initialization after genesis mode "
 		       "download failed\n", dev->name);
-		return -EIO;
+		ret = -EIO;
+		goto out;
 	}
 
 	PDEBUG(DEBUG_EXTRA2, "Card initialized - running PRI only\n");
 	if (prism2_hw_init2(dev, 1)) {
 		printk(KERN_DEBUG "%s: Initialization(2) after genesis mode "
 		       "download failed\n", dev->name);
-		return -EIO;
+		ret = -EIO;
 	}
 
-	return 0;
+	goto out2;
+ out:
+	local->hw_downloading = 0;
+ out2:
+	return ret;
 }
 
 



More information about the Hostap mailing list