From: Larry Finger <Larry.Finger@lwfinger.net>
To: Franky Lin <frankyl@broadcom.com>,
wireless <linux-wireless@vger.kernel.org>
Subject: Some funny code in brcmsmac
Date: Tue, 13 Dec 2011 22:19:12 -0600 [thread overview]
Message-ID: <4EE823C0.7080205@lwfinger.net> (raw)
Franky,
I was looking through the code and noticed the following in routine
wlc_phy_txpwrctrl_pwr_setup_nphy():
if (pi->sh->sromrev < 4) {
...
target_pwr_qtrdbm[0] = 13 * 4;
target_pwr_qtrdbm[1] = 13 * 4;
...
} else {
chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0);
switch (chan_freq_range) {
case WL_CHAN_FREQ_RANGE_2G:
...
target_pwr_qtrdbm[0] =
pi->nphy_pwrctrl_info[0].max_pwr_2g;
target_pwr_qtrdbm[1] =
pi->nphy_pwrctrl_info[1].max_pwr_2g;
...
break;
case WL_CHAN_FREQ_RANGE_5GL:
...
target_pwr_qtrdbm[0] =
pi->nphy_pwrctrl_info[0].max_pwr_5gl;
target_pwr_qtrdbm[1] =
pi->nphy_pwrctrl_info[1].max_pwr_5gl;
...
break;
case WL_CHAN_FREQ_RANGE_5GM:
...
target_pwr_qtrdbm[0] =
pi->nphy_pwrctrl_info[0].max_pwr_5gm;
target_pwr_qtrdbm[1] =
pi->nphy_pwrctrl_info[1].max_pwr_5gm;
...
break;
case WL_CHAN_FREQ_RANGE_5GH:
...
target_pwr_qtrdbm[0] =
pi->nphy_pwrctrl_info[0].max_pwr_5gh;
target_pwr_qtrdbm[1] =
pi->nphy_pwrctrl_info[1].max_pwr_5gh;
...
break;
default:
...
target_pwr_qtrdbm[0] = 13 * 4;
target_pwr_qtrdbm[1] = 13 * 4;
...
break;
}
}
target_pwr_qtrdbm[0] = (s8) pi->tx_power_max;
target_pwr_qtrdbm[1] = (s8) pi->tx_power_max;
After going to some effort to customize the target_pwr_qtrdbm array depending on
the SPROM version and the particular channel being used, the array is
unconditionally overwritten in the end. Although gcc probably optimizes out the
statements that are not needed (I have not looked at the generated code.),
perhaps the code should be modified to make it clearer for human readers.
Thanks,
Larry
next reply other threads:[~2011-12-14 4:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 4:19 Larry Finger [this message]
2011-12-14 20:13 ` Some funny code in brcmsmac Arend van Spriel
2011-12-14 21:22 ` Larry Finger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EE823C0.7080205@lwfinger.net \
--to=larry.finger@lwfinger.net \
--cc=frankyl@broadcom.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).