diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-05-02 16:47:49 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-14 16:29:33 -0400 |
commit | ca21614d4c7a176d3723ac211873020b3722dbda (patch) | |
tree | 15b77a9b5250b708985458ce13963c72ca52af28 /drivers | |
parent | cdbf0846e2dd5f122f3910d0e2a305fab337744b (diff) |
b43legacy: 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')
-rw-r--r-- | drivers/net/wireless/b43legacy/b43legacy.h | 17 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/main.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/phy.c | 14 | ||||
-rw-r--r-- | drivers/net/wireless/b43legacy/radio.c | 12 |
4 files changed, 17 insertions, 34 deletions
diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h index ded3cd31b3df..c40078e1fff9 100644 --- a/drivers/net/wireless/b43legacy/b43legacy.h +++ b/drivers/net/wireless/b43legacy/b43legacy.h | |||
@@ -823,23 +823,6 @@ void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...) | |||
823 | # define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0) | 823 | # define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0) |
824 | #endif /* DEBUG */ | 824 | #endif /* DEBUG */ |
825 | 825 | ||
826 | |||
827 | /** Limit a value between two limits */ | ||
828 | #ifdef limit_value | ||
829 | # undef limit_value | ||
830 | #endif | ||
831 | #define limit_value(value, min, max) \ | ||
832 | ({ \ | ||
833 | typeof(value) __value = (value); \ | ||
834 | typeof(value) __min = (min); \ | ||
835 | typeof(value) __max = (max); \ | ||
836 | if (__value < __min) \ | ||
837 | __value = __min; \ | ||
838 | else if (__value > __max) \ | ||
839 | __value = __max; \ | ||
840 | __value; \ | ||
841 | }) | ||
842 | |||
843 | /* Macros for printing a value in Q5.2 format */ | 826 | /* Macros for printing a value in Q5.2 format */ |
844 | #define Q52_FMT "%u.%u" | 827 | #define Q52_FMT "%u.%u" |
845 | #define Q52_ARG(q52) ((q52) / 4), (((q52) & 3) * 100 / 4) | 828 | #define Q52_ARG(q52) ((q52) / 4), (((q52) & 3) * 100 / 4) |
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index 1ccc51e90a8e..d3820dce3c43 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c | |||
@@ -846,10 +846,10 @@ static void handle_irq_noise(struct b43legacy_wldev *dev) | |||
846 | /* Get the noise samples. */ | 846 | /* Get the noise samples. */ |
847 | B43legacy_WARN_ON(dev->noisecalc.nr_samples >= 8); | 847 | B43legacy_WARN_ON(dev->noisecalc.nr_samples >= 8); |
848 | i = dev->noisecalc.nr_samples; | 848 | i = dev->noisecalc.nr_samples; |
849 | noise[0] = limit_value(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 849 | noise[0] = clamp_val(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
850 | noise[1] = limit_value(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 850 | noise[1] = clamp_val(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
851 | noise[2] = limit_value(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 851 | noise[2] = clamp_val(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
852 | noise[3] = limit_value(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); | 852 | noise[3] = clamp_val(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1); |
853 | dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]]; | 853 | dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]]; |
854 | dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]]; | 854 | dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]]; |
855 | dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]]; | 855 | dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]]; |
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c index 8e5c09b81871..768cccb9b1ba 100644 --- a/drivers/net/wireless/b43legacy/phy.c +++ b/drivers/net/wireless/b43legacy/phy.c | |||
@@ -1088,7 +1088,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev) | |||
1088 | * the value 0x7FFFFFFF here. I think that is some weird | 1088 | * the value 0x7FFFFFFF here. I think that is some weird |
1089 | * compiler optimization in the original driver. | 1089 | * compiler optimization in the original driver. |
1090 | * Essentially, what we do here is resetting all NRSSI LT | 1090 | * Essentially, what we do here is resetting all NRSSI LT |
1091 | * entries to -32 (see the limit_value() in nrssi_hw_update()) | 1091 | * entries to -32 (see the clamp_val() in nrssi_hw_update()) |
1092 | */ | 1092 | */ |
1093 | b43legacy_nrssi_hw_update(dev, 0xFFFF); | 1093 | b43legacy_nrssi_hw_update(dev, 0xFFFF); |
1094 | b43legacy_calc_nrssi_threshold(dev); | 1094 | b43legacy_calc_nrssi_threshold(dev); |
@@ -1756,7 +1756,7 @@ static s8 b43legacy_phy_estimate_power_out(struct b43legacy_wldev *dev, s8 tssi) | |||
1756 | switch (phy->type) { | 1756 | switch (phy->type) { |
1757 | case B43legacy_PHYTYPE_B: | 1757 | case B43legacy_PHYTYPE_B: |
1758 | case B43legacy_PHYTYPE_G: | 1758 | case B43legacy_PHYTYPE_G: |
1759 | tmp = limit_value(tmp, 0x00, 0x3F); | 1759 | tmp = clamp_val(tmp, 0x00, 0x3F); |
1760 | dbm = phy->tssi2dbm[tmp]; | 1760 | dbm = phy->tssi2dbm[tmp]; |
1761 | break; | 1761 | break; |
1762 | default: | 1762 | default: |
@@ -1859,7 +1859,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) | |||
1859 | 1859 | ||
1860 | /* find the desired power in Q5.2 - power_level is in dBm | 1860 | /* find the desired power in Q5.2 - power_level is in dBm |
1861 | * and limit it - max_pwr is already in Q5.2 */ | 1861 | * and limit it - max_pwr is already in Q5.2 */ |
1862 | desired_pwr = limit_value(phy->power_level << 2, 0, max_pwr); | 1862 | desired_pwr = clamp_val(phy->power_level << 2, 0, max_pwr); |
1863 | if (b43legacy_debug(dev, B43legacy_DBG_XMITPOWER)) | 1863 | if (b43legacy_debug(dev, B43legacy_DBG_XMITPOWER)) |
1864 | b43legacydbg(dev->wl, "Current TX power output: " Q52_FMT | 1864 | b43legacydbg(dev->wl, "Current TX power output: " Q52_FMT |
1865 | " dBm, Desired TX power output: " Q52_FMT | 1865 | " dBm, Desired TX power output: " Q52_FMT |
@@ -1905,7 +1905,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) | |||
1905 | radio_attenuation++; | 1905 | radio_attenuation++; |
1906 | } | 1906 | } |
1907 | } | 1907 | } |
1908 | baseband_attenuation = limit_value(baseband_attenuation, 0, 11); | 1908 | baseband_attenuation = clamp_val(baseband_attenuation, 0, 11); |
1909 | 1909 | ||
1910 | txpower = phy->txctl1; | 1910 | txpower = phy->txctl1; |
1911 | if ((phy->radio_ver == 0x2050) && (phy->radio_rev == 2)) { | 1911 | if ((phy->radio_ver == 0x2050) && (phy->radio_rev == 2)) { |
@@ -1933,8 +1933,8 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) | |||
1933 | } | 1933 | } |
1934 | /* Save the control values */ | 1934 | /* Save the control values */ |
1935 | phy->txctl1 = txpower; | 1935 | phy->txctl1 = txpower; |
1936 | baseband_attenuation = limit_value(baseband_attenuation, 0, 11); | 1936 | baseband_attenuation = clamp_val(baseband_attenuation, 0, 11); |
1937 | radio_attenuation = limit_value(radio_attenuation, 0, 9); | 1937 | radio_attenuation = clamp_val(radio_attenuation, 0, 9); |
1938 | phy->rfatt = radio_attenuation; | 1938 | phy->rfatt = radio_attenuation; |
1939 | phy->bbatt = baseband_attenuation; | 1939 | phy->bbatt = baseband_attenuation; |
1940 | 1940 | ||
@@ -1979,7 +1979,7 @@ s8 b43legacy_tssi2dbm_entry(s8 entry [], u8 index, s16 pab0, s16 pab1, s16 pab2) | |||
1979 | f = q; | 1979 | f = q; |
1980 | i++; | 1980 | i++; |
1981 | } while (delta >= 2); | 1981 | } while (delta >= 2); |
1982 | entry[index] = limit_value(b43legacy_tssi2dbm_ad(m1 * f, 8192), | 1982 | entry[index] = clamp_val(b43legacy_tssi2dbm_ad(m1 * f, 8192), |
1983 | -127, 128); | 1983 | -127, 128); |
1984 | return 0; | 1984 | return 0; |
1985 | } | 1985 | } |
diff --git a/drivers/net/wireless/b43legacy/radio.c b/drivers/net/wireless/b43legacy/radio.c index 955832e8654f..2df545cfad14 100644 --- a/drivers/net/wireless/b43legacy/radio.c +++ b/drivers/net/wireless/b43legacy/radio.c | |||
@@ -357,7 +357,7 @@ void b43legacy_nrssi_hw_update(struct b43legacy_wldev *dev, u16 val) | |||
357 | for (i = 0; i < 64; i++) { | 357 | for (i = 0; i < 64; i++) { |
358 | tmp = b43legacy_nrssi_hw_read(dev, i); | 358 | tmp = b43legacy_nrssi_hw_read(dev, i); |
359 | tmp -= val; | 359 | tmp -= val; |
360 | tmp = limit_value(tmp, -32, 31); | 360 | tmp = clamp_val(tmp, -32, 31); |
361 | b43legacy_nrssi_hw_write(dev, i, tmp); | 361 | b43legacy_nrssi_hw_write(dev, i, tmp); |
362 | } | 362 | } |
363 | } | 363 | } |
@@ -375,7 +375,7 @@ void b43legacy_nrssi_mem_update(struct b43legacy_wldev *dev) | |||
375 | tmp = (i - delta) * phy->nrssislope; | 375 | tmp = (i - delta) * phy->nrssislope; |
376 | tmp /= 0x10000; | 376 | tmp /= 0x10000; |
377 | tmp += 0x3A; | 377 | tmp += 0x3A; |
378 | tmp = limit_value(tmp, 0, 0x3F); | 378 | tmp = clamp_val(tmp, 0, 0x3F); |
379 | phy->nrssi_lt[i] = tmp; | 379 | phy->nrssi_lt[i] = tmp; |
380 | } | 380 | } |
381 | } | 381 | } |
@@ -839,7 +839,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev) | |||
839 | } else | 839 | } else |
840 | threshold = phy->nrssi[1] - 5; | 840 | threshold = phy->nrssi[1] - 5; |
841 | 841 | ||
842 | threshold = limit_value(threshold, 0, 0x3E); | 842 | threshold = clamp_val(threshold, 0, 0x3E); |
843 | b43legacy_phy_read(dev, 0x0020); /* dummy read */ | 843 | b43legacy_phy_read(dev, 0x0020); /* dummy read */ |
844 | b43legacy_phy_write(dev, 0x0020, (((u16)threshold) << 8) | 844 | b43legacy_phy_write(dev, 0x0020, (((u16)threshold) << 8) |
845 | | 0x001C); | 845 | | 0x001C); |
@@ -892,7 +892,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev) | |||
892 | else | 892 | else |
893 | a += 32; | 893 | a += 32; |
894 | a = a >> 6; | 894 | a = a >> 6; |
895 | a = limit_value(a, -31, 31); | 895 | a = clamp_val(a, -31, 31); |
896 | 896 | ||
897 | b = b * (phy->nrssi[1] - phy->nrssi[0]); | 897 | b = b * (phy->nrssi[1] - phy->nrssi[0]); |
898 | b += (phy->nrssi[0] << 6); | 898 | b += (phy->nrssi[0] << 6); |
@@ -901,7 +901,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev) | |||
901 | else | 901 | else |
902 | b += 32; | 902 | b += 32; |
903 | b = b >> 6; | 903 | b = b >> 6; |
904 | b = limit_value(b, -31, 31); | 904 | b = clamp_val(b, -31, 31); |
905 | 905 | ||
906 | tmp_u16 = b43legacy_phy_read(dev, 0x048A) & 0xF000; | 906 | tmp_u16 = b43legacy_phy_read(dev, 0x048A) & 0xF000; |
907 | tmp_u16 |= ((u32)b & 0x0000003F); | 907 | tmp_u16 |= ((u32)b & 0x0000003F); |
@@ -1905,7 +1905,7 @@ void b43legacy_radio_set_txpower_a(struct b43legacy_wldev *dev, u16 txpower) | |||
1905 | u16 dac; | 1905 | u16 dac; |
1906 | u16 ilt; | 1906 | u16 ilt; |
1907 | 1907 | ||
1908 | txpower = limit_value(txpower, 0, 63); | 1908 | txpower = clamp_val(txpower, 0, 63); |
1909 | 1909 | ||
1910 | pamp = b43legacy_get_txgain_freq_power_amp(txpower); | 1910 | pamp = b43legacy_get_txgain_freq_power_amp(txpower); |
1911 | pamp <<= 5; | 1911 | pamp <<= 5; |