Skip to content

Commit

Permalink
staging: brcm80211: remove code duplication for driver variable lookup
Browse files Browse the repository at this point in the history
The phy code used its own driver variable lookup functions which were
duplicates of those in the brcmsmac driver (in srom.c). The phy code
now uses the functions in srom.c through the phy_shim interface.

Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Alwin Beukers <alwin@broadcom.com>
Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Arend van Spriel authored and Greg Kroah-Hartman committed Oct 5, 2011
1 parent 43e45c3 commit f4e5c54
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 177 deletions.
36 changes: 0 additions & 36 deletions drivers/staging/brcm80211/brcmsmac/phy/phy_cmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,42 +126,6 @@ const u8 ofdm_rate_lookup[] = {

#define PHY_WREG_LIMIT 24

char *phy_getvar(struct brcms_phy *pi, const char *name)
{
char *vars = pi->vars;
char *s;
int len;

if (!name)
return NULL;

len = strlen(name);
if (len == 0)
return NULL;

for (s = vars; s && *s;) {
if ((memcmp(s, name, len) == 0) && (s[len] == '='))
return &s[len + 1];

while (*s++)
;
}

return NULL;
}

int phy_getintvar(struct brcms_phy *pi, const char *name)
{
char *val;
unsigned long res;

val = PHY_GETVAR(pi, name);
if (val && !kstrtoul(val, 0, &res))
return res;

return 0;
}

void wlc_phyreg_enter(struct brcms_phy_pub *pih)
{
struct brcms_phy *pi = (struct brcms_phy *) pih;
Expand Down
6 changes: 0 additions & 6 deletions drivers/staging/brcm80211/brcmsmac/phy/phy_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,6 @@ struct lcnphy_radio_regs {
u8 do_init_g;
};

extern char *phy_getvar(struct brcms_phy *pi, const char *name);
extern int phy_getintvar(struct brcms_phy *pi, const char *name);

#define PHY_GETVAR(pi, name) phy_getvar(pi, name)
#define PHY_GETINTVAR(pi, name) phy_getintvar(pi, name)

extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
Expand Down
56 changes: 31 additions & 25 deletions drivers/staging/brcm80211/brcmsmac/phy/phy_lcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4823,18 +4823,21 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
u32 offset_ofdm, offset_mcs;

pi_lcn->lcnphy_tr_isolation_mid =
(u8) PHY_GETINTVAR(pi, "triso2g");
(u8) wlapi_getintvar(pi->vars, "triso2g");

pi_lcn->lcnphy_rx_power_offset =
(u8) PHY_GETINTVAR(pi, "rxpo2g");
(u8) wlapi_getintvar(pi->vars, "rxpo2g");

pi->txpa_2g[0] = (s16) PHY_GETINTVAR(pi, "pa0b0");
pi->txpa_2g[1] = (s16) PHY_GETINTVAR(pi, "pa0b1");
pi->txpa_2g[2] = (s16) PHY_GETINTVAR(pi, "pa0b2");
pi->txpa_2g[0] = (s16) wlapi_getintvar(pi->vars, "pa0b0");
pi->txpa_2g[1] = (s16) wlapi_getintvar(pi->vars, "pa0b1");
pi->txpa_2g[2] = (s16) wlapi_getintvar(pi->vars, "pa0b2");

pi_lcn->lcnphy_rssi_vf = (u8) PHY_GETINTVAR(pi, "rssismf2g");
pi_lcn->lcnphy_rssi_vc = (u8) PHY_GETINTVAR(pi, "rssismc2g");
pi_lcn->lcnphy_rssi_gs = (u8) PHY_GETINTVAR(pi, "rssisav2g");
pi_lcn->lcnphy_rssi_vf =
(u8) wlapi_getintvar(pi->vars, "rssismf2g");
pi_lcn->lcnphy_rssi_vc =
(u8) wlapi_getintvar(pi->vars, "rssismc2g");
pi_lcn->lcnphy_rssi_gs =
(u8) wlapi_getintvar(pi->vars, "rssisav2g");

pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf;
pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc;
Expand All @@ -4844,15 +4847,15 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc;
pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs;

txpwr = (s8) PHY_GETINTVAR(pi, "maxp2ga0");
txpwr = (s8) wlapi_getintvar(pi->vars, "maxp2ga0");
pi->tx_srom_max_2g = txpwr;

for (i = 0; i < PWRTBL_NUM_COEFF; i++) {
pi->txpa_2g_low_temp[i] = pi->txpa_2g[i];
pi->txpa_2g_high_temp[i] = pi->txpa_2g[i];
}

cckpo = (u16) PHY_GETINTVAR(pi, "cck2gpo");
cckpo = (u16) wlapi_getintvar(pi->vars, "cck2gpo");
if (cckpo) {
uint max_pwr_chan = txpwr;

Expand All @@ -4862,7 +4865,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
cckpo >>= 4;
}

offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo");
offset_ofdm =
(u32) wlapi_getintvar(pi->vars, "ofdm2gpo");
for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) {
pi->tx_srom_max_rate_2g[i] =
max_pwr_chan -
Expand All @@ -4872,21 +4876,23 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
} else {
u8 opo = 0;

opo = (u8) PHY_GETINTVAR(pi, "opo");
opo = (u8) wlapi_getintvar(pi->vars, "opo");

for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++)
pi->tx_srom_max_rate_2g[i] = txpwr;

offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo");
offset_ofdm =
(u32) wlapi_getintvar(pi->vars, "ofdm2gpo");

for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) {
pi->tx_srom_max_rate_2g[i] = txpwr -
((offset_ofdm & 0xf) * 2);
offset_ofdm >>= 4;
}
offset_mcs =
((u16) PHY_GETINTVAR(pi, "mcs2gpo1") << 16) |
(u16) PHY_GETINTVAR(pi, "mcs2gpo0");
wlapi_getintvar(pi->vars, "mcs2gpo1") << 16;
offset_mcs |=
(u16) wlapi_getintvar(pi->vars, "mcs2gpo0");
pi_lcn->lcnphy_mcs20_po = offset_mcs;
for (i = TXP_FIRST_SISO_MCS_20;
i <= TXP_LAST_SISO_MCS_20; i++) {
Expand All @@ -4897,30 +4903,30 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
}

pi_lcn->lcnphy_rawtempsense =
(u16) PHY_GETINTVAR(pi, "rawtempsense");
(u16) wlapi_getintvar(pi->vars, "rawtempsense");
pi_lcn->lcnphy_measPower =
(u8) PHY_GETINTVAR(pi, "measpower");
(u8) wlapi_getintvar(pi->vars, "measpower");
pi_lcn->lcnphy_tempsense_slope =
(u8) PHY_GETINTVAR(pi, "tempsense_slope");
(u8) wlapi_getintvar(pi->vars, "tempsense_slope");
pi_lcn->lcnphy_hw_iqcal_en =
(bool) PHY_GETINTVAR(pi, "hw_iqcal_en");
(bool) wlapi_getintvar(pi->vars, "hw_iqcal_en");
pi_lcn->lcnphy_iqcal_swp_dis =
(bool) PHY_GETINTVAR(pi, "iqcal_swp_dis");
(bool) wlapi_getintvar(pi->vars, "iqcal_swp_dis");
pi_lcn->lcnphy_tempcorrx =
(u8) PHY_GETINTVAR(pi, "tempcorrx");
(u8) wlapi_getintvar(pi->vars, "tempcorrx");
pi_lcn->lcnphy_tempsense_option =
(u8) PHY_GETINTVAR(pi, "tempsense_option");
(u8) wlapi_getintvar(pi->vars, "tempsense_option");
pi_lcn->lcnphy_freqoffset_corr =
(u8) PHY_GETINTVAR(pi, "freqoffset_corr");
(u8) wlapi_getintvar(pi->vars, "freqoffset_corr");
if ((u8) getintvar(pi->vars, "aa2g") > 1)
wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi,
(u8) getintvar(pi->vars,
"aa2g"));
}
pi_lcn->lcnphy_cck_dig_filt_type = -1;
if (PHY_GETVAR(pi, "cckdigfilttype")) {
if (wlapi_getvar(pi->vars, "cckdigfilttype")) {
s16 temp;
temp = (s16) PHY_GETINTVAR(pi, "cckdigfilttype");
temp = (s16) wlapi_getintvar(pi->vars, "cckdigfilttype");
if (temp >= 0)
pi_lcn->lcnphy_cck_dig_filt_type = temp;
}
Expand Down
Loading

0 comments on commit f4e5c54

Please sign in to comment.