diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-05-02 16:47:48 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-14 16:29:32 -0400 |
commit | cdbf0846e2dd5f122f3910d0e2a305fab337744b (patch) | |
tree | 74f5fb5611227edf502d449e16adb97abf462e8d /drivers/net/wireless/b43 | |
parent | 8c046c8c64ba81dd87468ddaf2db4a5d926b988b (diff) |
b43: replace limit_value macro with clamp_val
kernel-provided clamp_val is identical, delete the private limit_value helper.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Michael Buesch <mb@bu3sch.de>
Cc: "John W. Linville" <linville@tuxdriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43')
-rw-r--r-- | drivers/net/wireless/b43/b43.h | 16 | ||||
-rw-r--r-- | drivers/net/wireless/b43/lo.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/b43/main.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy.c | 24 |
4 files changed, 18 insertions, 34 deletions
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 7d034df250bd..0c2bc061e8f3 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h | |||
@@ -939,22 +939,6 @@ static inline bool __b43_warn_on_dummy(bool x) { return x; } | |||
939 | # define B43_WARN_ON(x) __b43_warn_on_dummy(unlikely(!!(x))) | 939 | # define B43_WARN_ON(x) __b43_warn_on_dummy(unlikely(!!(x))) |
940 | #endif | 940 | #endif |
941 | 941 | ||
942 | /** Limit a value between two limits */ | ||
943 | #ifdef limit_value | ||
944 | # undef limit_value | ||
945 | #endif | ||
946 | #define limit_value(value, min, max) \ | ||
947 | ({ \ | ||
948 | typeof(value) __value = (value); \ | ||
949 | typeof(value) __min = (min); \ | ||
950 | typeof(value) __max = (max); \ | ||
951 | if (__value < __min) \ | ||
952 | __value = __min; \ | ||
953 | else if (__value > __max) \ | ||
954 | __value = __max; \ | ||
955 | __value; \ | ||
956 | }) | ||
957 | |||
958 | /* Convert an integer to a Q5.2 value */ | 942 | /* Convert an integer to a Q5.2 value */ |
959 | #define INT_TO_Q52(i) ((i) << 2) | 943 | #define INT_TO_Q52(i) ((i) << 2) |
960 | /* Convert a Q5.2 value to an integer (precision loss!) */ | 944 | /* Convert a Q5.2 value to an integer (precision loss!) */ |
diff --git a/drivers/net/wireless/b43/lo.c b/drivers/net/wireless/b43/lo.c index 4ce1e3561205..9c854d6aae36 100644 --- a/drivers/net/wireless/b43/lo.c +++ b/drivers/net/wireless/b43/lo.c | |||
@@ -199,7 +199,7 @@ static void lo_measure_txctl_values(struct b43_wldev *dev) | |||
199 | if (lb_gain > 10) { | 199 | if (lb_gain > 10) { |
200 | radio_pctl_reg = 0; | 200 | radio_pctl_reg = 0; |
201 | pga = abs(10 - lb_gain) / 6; | 201 | pga = abs(10 - lb_gain) / 6; |
202 | pga = limit_value(pga, 0, 15); | 202 | pga = clamp_val(pga, 0, 15); |
203 | } else { | 203 | } else { |
204 | int cmp_val; | 204 | int cmp_val; |
205 | int tmp; | 205 | int tmp; |
@@ -321,7 +321,7 @@ static void lo_measure_gain_values(struct b43_wldev *dev, | |||
321 | phy->lna_lod_gain = 1; | 321 | phy->lna_lod_gain = 1; |
322 | trsw_rx_gain -= 8; | 322 | trsw_rx_gain -= 8; |
323 | } | 323 | } |
324 | trsw_rx_gain = limit_value(trsw_rx_gain, 0, 0x2D); | 324 | trsw_rx_gain = clamp_val(trsw_rx_gain, 0, 0x2D); |
325 | phy->pga_gain = trsw_rx_gain / 3; | 325 | phy->pga_gain = trsw_rx_gain / 3; |
326 | if (phy->pga_gain >= 5) { | 326 | if (phy->pga_gain >= 5) { |
327 | phy->pga_gain -= 5; | 327 | phy->pga_gain -= 5; |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index c6e79a15d3cb..7c23aa8705c2 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -1182,10 +1182,10 @@ static void handle_irq_noise(struct b43_wldev *dev) | |||
1182 | /* Get the noise samples. */ | 1182 | /* Get the noise samples. */ |
1183 | B43_WARN_ON(dev->noisecalc.nr_samples >= 8); | 1183 | B43_WARN_ON(dev->noisecalc.nr_samples >= 8); |
1184 | i = dev->noisecalc.nr_samples; | 1184 | i = dev->noisecalc.nr_samples; |
1185 | noise[0] = limit_value(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 1185 | noise[0] = clamp_val(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
1186 | noise[1] = limit_value(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 1186 | noise[1] = clamp_val(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
1187 | noise[2] = limit_value(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 1187 | noise[2] = clamp_val(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
1188 | noise[3] = limit_value(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 1188 | noise[3] = clamp_val(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
1189 | dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]]; | 1189 | dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]]; |
1190 | dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]]; | 1190 | dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]]; |
1191 | dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]]; | 1191 | dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]]; |
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c index 8b3c24da8db9..6378c266549a 100644 --- a/drivers/net/wireless/b43/phy.c +++ b/drivers/net/wireless/b43/phy.c | |||
@@ -1415,7 +1415,7 @@ static void b43_phy_initg(struct b43_wldev *dev) | |||
1415 | * the value 0x7FFFFFFF here. I think that is some weird | 1415 | * the value 0x7FFFFFFF here. I think that is some weird |
1416 | * compiler optimization in the original driver. | 1416 | * compiler optimization in the original driver. |
1417 | * Essentially, what we do here is resetting all NRSSI LT | 1417 | * Essentially, what we do here is resetting all NRSSI LT |
1418 | * entries to -32 (see the limit_value() in nrssi_hw_update()) | 1418 | * entries to -32 (see the clamp_val() in nrssi_hw_update()) |
1419 | */ | 1419 | */ |
1420 | b43_nrssi_hw_update(dev, 0xFFFF); //FIXME? | 1420 | b43_nrssi_hw_update(dev, 0xFFFF); //FIXME? |
1421 | b43_calc_nrssi_threshold(dev); | 1421 | b43_calc_nrssi_threshold(dev); |
@@ -1477,13 +1477,13 @@ static s8 b43_phy_estimate_power_out(struct b43_wldev *dev, s8 tssi) | |||
1477 | switch (phy->type) { | 1477 | switch (phy->type) { |
1478 | case B43_PHYTYPE_A: | 1478 | case B43_PHYTYPE_A: |
1479 | tmp += 0x80; | 1479 | tmp += 0x80; |
1480 | tmp = limit_value(tmp, 0x00, 0xFF); | 1480 | tmp = clamp_val(tmp, 0x00, 0xFF); |
1481 | dbm = phy->tssi2dbm[tmp]; | 1481 | dbm = phy->tssi2dbm[tmp]; |
1482 | //TODO: There's a FIXME on the specs | 1482 | //TODO: There's a FIXME on the specs |
1483 | break; | 1483 | break; |
1484 | case B43_PHYTYPE_B: | 1484 | case B43_PHYTYPE_B: |
1485 | case B43_PHYTYPE_G: | 1485 | case B43_PHYTYPE_G: |
1486 | tmp = limit_value(tmp, 0x00, 0x3F); | 1486 | tmp = clamp_val(tmp, 0x00, 0x3F); |
1487 | dbm = phy->tssi2dbm[tmp]; | 1487 | dbm = phy->tssi2dbm[tmp]; |
1488 | break; | 1488 | break; |
1489 | default: | 1489 | default: |
@@ -1542,8 +1542,8 @@ void b43_put_attenuation_into_ranges(struct b43_wldev *dev, | |||
1542 | break; | 1542 | break; |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | *_rfatt = limit_value(rfatt, rf_min, rf_max); | 1545 | *_rfatt = clamp_val(rfatt, rf_min, rf_max); |
1546 | *_bbatt = limit_value(bbatt, bb_min, bb_max); | 1546 | *_bbatt = clamp_val(bbatt, bb_min, bb_max); |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | /* http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */ | 1549 | /* http://bcm-specs.sipsolutions.net/RecalculateTransmissionPower */ |
@@ -1638,7 +1638,7 @@ void b43_phy_xmitpower(struct b43_wldev *dev) | |||
1638 | /* Get desired power (in Q5.2) */ | 1638 | /* Get desired power (in Q5.2) */ |
1639 | desired_pwr = INT_TO_Q52(phy->power_level); | 1639 | desired_pwr = INT_TO_Q52(phy->power_level); |
1640 | /* And limit it. max_pwr already is Q5.2 */ | 1640 | /* And limit it. max_pwr already is Q5.2 */ |
1641 | desired_pwr = limit_value(desired_pwr, 0, max_pwr); | 1641 | desired_pwr = clamp_val(desired_pwr, 0, max_pwr); |
1642 | if (b43_debug(dev, B43_DBG_XMITPOWER)) { | 1642 | if (b43_debug(dev, B43_DBG_XMITPOWER)) { |
1643 | b43dbg(dev->wl, | 1643 | b43dbg(dev->wl, |
1644 | "Current TX power output: " Q52_FMT | 1644 | "Current TX power output: " Q52_FMT |
@@ -1748,7 +1748,7 @@ static inline | |||
1748 | f = q; | 1748 | f = q; |
1749 | i++; | 1749 | i++; |
1750 | } while (delta >= 2); | 1750 | } while (delta >= 2); |
1751 | entry[index] = limit_value(b43_tssi2dbm_ad(m1 * f, 8192), -127, 128); | 1751 | entry[index] = clamp_val(b43_tssi2dbm_ad(m1 * f, 8192), -127, 128); |
1752 | return 0; | 1752 | return 0; |
1753 | } | 1753 | } |
1754 | 1754 | ||
@@ -2274,7 +2274,7 @@ void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val) | |||
2274 | for (i = 0; i < 64; i++) { | 2274 | for (i = 0; i < 64; i++) { |
2275 | tmp = b43_nrssi_hw_read(dev, i); | 2275 | tmp = b43_nrssi_hw_read(dev, i); |
2276 | tmp -= val; | 2276 | tmp -= val; |
2277 | tmp = limit_value(tmp, -32, 31); | 2277 | tmp = clamp_val(tmp, -32, 31); |
2278 | b43_nrssi_hw_write(dev, i, tmp); | 2278 | b43_nrssi_hw_write(dev, i, tmp); |
2279 | } | 2279 | } |
2280 | } | 2280 | } |
@@ -2291,7 +2291,7 @@ void b43_nrssi_mem_update(struct b43_wldev *dev) | |||
2291 | tmp = (i - delta) * phy->nrssislope; | 2291 | tmp = (i - delta) * phy->nrssislope; |
2292 | tmp /= 0x10000; | 2292 | tmp /= 0x10000; |
2293 | tmp += 0x3A; | 2293 | tmp += 0x3A; |
2294 | tmp = limit_value(tmp, 0, 0x3F); | 2294 | tmp = clamp_val(tmp, 0, 0x3F); |
2295 | phy->nrssi_lt[i] = tmp; | 2295 | phy->nrssi_lt[i] = tmp; |
2296 | } | 2296 | } |
2297 | } | 2297 | } |
@@ -2728,7 +2728,7 @@ void b43_calc_nrssi_threshold(struct b43_wldev *dev) | |||
2728 | } else | 2728 | } else |
2729 | threshold = phy->nrssi[1] - 5; | 2729 | threshold = phy->nrssi[1] - 5; |
2730 | 2730 | ||
2731 | threshold = limit_value(threshold, 0, 0x3E); | 2731 | threshold = clamp_val(threshold, 0, 0x3E); |
2732 | b43_phy_read(dev, 0x0020); /* dummy read */ | 2732 | b43_phy_read(dev, 0x0020); /* dummy read */ |
2733 | b43_phy_write(dev, 0x0020, | 2733 | b43_phy_write(dev, 0x0020, |
2734 | (((u16) threshold) << 8) | 0x001C); | 2734 | (((u16) threshold) << 8) | 0x001C); |
@@ -2779,7 +2779,7 @@ void b43_calc_nrssi_threshold(struct b43_wldev *dev) | |||
2779 | else | 2779 | else |
2780 | a += 32; | 2780 | a += 32; |
2781 | a = a >> 6; | 2781 | a = a >> 6; |
2782 | a = limit_value(a, -31, 31); | 2782 | a = clamp_val(a, -31, 31); |
2783 | 2783 | ||
2784 | b = b * (phy->nrssi[1] - phy->nrssi[0]); | 2784 | b = b * (phy->nrssi[1] - phy->nrssi[0]); |
2785 | b += (phy->nrssi[0] << 6); | 2785 | b += (phy->nrssi[0] << 6); |
@@ -2788,7 +2788,7 @@ void b43_calc_nrssi_threshold(struct b43_wldev *dev) | |||
2788 | else | 2788 | else |
2789 | b += 32; | 2789 | b += 32; |
2790 | b = b >> 6; | 2790 | b = b >> 6; |
2791 | b = limit_value(b, -31, 31); | 2791 | b = clamp_val(b, -31, 31); |
2792 | 2792 | ||
2793 | tmp_u16 = b43_phy_read(dev, 0x048A) & 0xF000; | 2793 | tmp_u16 = b43_phy_read(dev, 0x048A) & 0xF000; |
2794 | tmp_u16 |= ((u32) b & 0x0000003F); | 2794 | tmp_u16 |= ((u32) b & 0x0000003F); |