summaryrefslogtreecommitdiff
path: root/package/madwifi/patches/438-poweroffset_sysctl.patch
blob: 9d5e71f0fc1562867b9cfb61c7905f5c20924cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--- a/ath/if_ath.c
+++ b/ath/if_ath.c
@@ -10473,11 +10473,11 @@ set_node_txpower(void *arg, struct ieee8
  * XXX: this function needs some locking to avoid being called 
  * twice/interrupted. Returns the value actually stored. */
 static u_int32_t
-ath_set_clamped_maxtxpower(struct ath_softc *sc, 
-		u_int32_t new_clamped_maxtxpower)
+ath_set_clamped_maxtxpower(struct ath_softc *sc, u_int32_t new_txpwr)
 {
-	new_clamped_maxtxpower -= sc->sc_poweroffset;
-	(void)ath_hal_settxpowlimit(sc->sc_ah, new_clamped_maxtxpower);
+	new_txpwr = ((new_txpwr < sc->sc_poweroffset) ? 0 :
+		new_txpwr - sc->sc_poweroffset);
+	(void)ath_hal_settxpowlimit(sc->sc_ah, new_txpwr);
 	return ath_get_clamped_maxtxpower(sc);
 }
 
@@ -11028,6 +11028,7 @@ enum {
 	ATH_DEBUG,
 	ATH_TXANTENNA,
 	ATH_RXANTENNA,
+	ATH_POWEROFFSET,
 	ATH_DIVERSITY,
 	ATH_TXINTRPERIOD,
 	ATH_FFTXQMIN,
@@ -11308,6 +11309,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
 				ath_debug_global = (val &  ATH_DEBUG_GLOBAL);
 #endif
 				break;
+			case ATH_POWEROFFSET:
+				sc->sc_poweroffset = val;
+				break;
 			case ATH_TXANTENNA:
 				/*
 				 * antenna can be:
@@ -11475,6 +11479,9 @@ ATH_SYSCTL_DECL(ath_sysctl_halparam, ctl
 		case ATH_DEBUG:
 			val = sc->sc_debug | ath_debug_global;
 			break;
+		case ATH_POWEROFFSET:
+			val = sc->sc_poweroffset;
+			break;
 		case ATH_TXANTENNA:
 			val = sc->sc_txantenna;
 			break;
@@ -11616,6 +11623,12 @@ static const ctl_table ath_sysctl_templa
 	},
 #endif
 	{ .ctl_name	= CTL_AUTO,
+	  .procname	= "poweroffset",
+	  .mode		= 0644,
+	  .proc_handler	= ath_sysctl_halparam,
+	  .extra2	= (void *)ATH_POWEROFFSET,
+	},
+	{ .ctl_name	= CTL_AUTO,
 	  .procname	= "txantenna",
 	  .mode		= 0644,
 	  .proc_handler	= ath_sysctl_halparam,