Skip to content

Commit

Permalink
[PATCH] bcm43xx: Fix bug in frequency to channel conversion
Browse files Browse the repository at this point in the history
The frequency to channel routine in bcm43xx requires that the frequency
be in MHz, but that condition is not always met. This patch does the
necessary conversion.

Signed-off-by: Joerg Sommer <joerg@alea.gnuu.de>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Joerg Sommer authored and John W. Linville committed Mar 8, 2007
1 parent 01a5977 commit d632f9f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/net/wireless/bcm43xx/bcm43xx_wx.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,24 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
unsigned long flags;
u8 channel;
s8 expon;
int freq;
int err = -EINVAL;

mutex_lock(&bcm->mutex);
spin_lock_irqsave(&bcm->irq_lock, flags);

if ((data->freq.m >= 0) && (data->freq.m <= 1000)) {
if ((data->freq.e == 0) &&
(data->freq.m >= 0) && (data->freq.m <= 1000)) {
channel = data->freq.m;
freq = bcm43xx_channel_to_freq(bcm, channel);
} else {
channel = bcm43xx_freq_to_channel(bcm, data->freq.m);
freq = data->freq.m;
expon = 6 - data->freq.e;
while (--expon >= 0) /* scale down the frequency to MHz */
freq /= 10;
assert(freq > 1000);
channel = bcm43xx_freq_to_channel(bcm, freq);
}
if (!ieee80211_is_valid_channel(bcm->ieee, channel))
goto out_unlock;
Expand Down

0 comments on commit d632f9f

Please sign in to comment.