Search Linux Wireless

[PATCH] Add module parameter to override regioncode on libertas

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Resending to linux-wireless after positive feedback on libertas-dev.

Attached is a patch against the 2.6.25 driver that adds a 
module parameter called "regioncode" to set the region code
in the libertas driver.

Hope the format is ok.
Signed-off-by: Johan.Adolfsson@xxxxxxxx

Best regards
/Johan
Index: drivers/net/wireless/libertas/main.c
===================================================================
RCS file: /usr/local/cvs/linux/os/linux-2.6/drivers/net/wireless/libertas/main.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 main.c
--- drivers/net/wireless/libertas/main.c	2 Jun 2008 15:08:37 -0000	1.1.1.4
+++ drivers/net/wireless/libertas/main.c	27 Jun 2008 13:08:19 -0000
@@ -36,6 +36,9 @@
 EXPORT_SYMBOL_GPL(lbs_debug);
 module_param_named(libertas_debug, lbs_debug, int, 0644);
 
+static int lbs_regioncode;
+module_param_named(regioncode, lbs_regioncode, int, 0644);
+
 
 #define LBS_TX_PWR_DEFAULT		20	/*100mW */
 #define LBS_TX_PWR_US_DEFAULT		20	/*100mW */
@@ -936,9 +939,11 @@
 	lbs_deb_enter(LBS_DEB_FW);
 
 	/*
-	 * Read MAC address from HW
+	 * Read MAC address and regioncode etc. from HW
 	 */
 	memset(priv->current_addr, 0xff, ETH_ALEN);
+	if (lbs_regioncode > 0)
+		priv->regioncode = lbs_regioncode;
 	ret = lbs_update_hw_spec(priv);
 	if (ret) {
 		ret = -1;
Index: drivers/net/wireless/libertas/cmd.c
===================================================================
RCS file: /usr/local/cvs/linux/os/linux-2.6/drivers/net/wireless/libertas/cmd.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 cmd.c
--- drivers/net/wireless/libertas/cmd.c	2 Jun 2008 15:08:37 -0000	1.1.1.4
+++ drivers/net/wireless/libertas/cmd.c	27 Jun 2008 13:08:19 -0000
@@ -81,22 +81,34 @@
 	lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
 		    cmd.hwifversion, cmd.version);
 
-	/* Clamp region code to 8-bit since FW spec indicates that it should
-	 * only ever be 8-bit, even though the field size is 16-bit.  Some firmware
-	 * returns non-zero high 8 bits here.
-	 */
-	priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
-
-	for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
-		/* use the region code to search for the index */
-		if (priv->regioncode == lbs_region_code_to_index[i])
-			break;
+	/* First check if a regioncode already provided */
+	if (priv->regioncode) {
+		for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
+			/* use the region code to search for the index */
+			if (priv->regioncode == lbs_region_code_to_index[i])
+				break;
+		}
+	} else {
+		i = MRVDRV_MAX_REGION_CODE; /* Check the from from cmd */
 	}
+	if (i >= MRVDRV_MAX_REGION_CODE) {
+		/* Clamp region code to 8-bit since FW spec indicates that it should
+		 * only ever be 8-bit, even though the field size is 16-bit.  Some firmware
+		 * returns non-zero high 8 bits here.
+		 */
+
+		priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
 
+		for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
+			/* use the region code to search for the index */
+			if (priv->regioncode == lbs_region_code_to_index[i])
+				break;
+		}
+	}
 	/* if it's unidentified region code, use the default (USA) */
 	if (i >= MRVDRV_MAX_REGION_CODE) {
+		lbs_pr_info("unidentified region code 0x%02x; using the default (USA)\n", priv->regioncode);
 		priv->regioncode = 0x10;
-		lbs_pr_info("unidentified region code; using the default (USA)\n");
 	}
 
 	if (priv->current_addr[0] == 0xff)

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux