Commit 67d392c0 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by John W. Linville

ssb: make code for antenna gain extraction more generic

Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b3bbf842
...@@ -326,13 +326,13 @@ static int sprom_do_write(struct ssb_bus *bus, const u16 *sprom) ...@@ -326,13 +326,13 @@ static int sprom_do_write(struct ssb_bus *bus, const u16 *sprom)
return err; return err;
} }
static s8 r123_extract_antgain(u8 sprom_revision, const u16 *in, static s8 sprom_extract_antgain(u8 sprom_revision, const u16 *in, u16 offset,
u16 mask, u16 shift) u16 mask, u16 shift)
{ {
u16 v; u16 v;
u8 gain; u8 gain;
v = in[SPOFF(SSB_SPROM1_AGAIN)]; v = in[SPOFF(offset)];
gain = (v & mask) >> shift; gain = (v & mask) >> shift;
if (gain == 0xFF) if (gain == 0xFF)
gain = 2; /* If unset use 2dBm */ gain = 2; /* If unset use 2dBm */
...@@ -416,12 +416,14 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) ...@@ -416,12 +416,14 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0); SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
/* Extract the antenna gain values. */ /* Extract the antenna gain values. */
out->antenna_gain.a0 = r123_extract_antgain(out->revision, in, out->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,
SSB_SPROM1_AGAIN_BG, SSB_SPROM1_AGAIN,
SSB_SPROM1_AGAIN_BG_SHIFT); SSB_SPROM1_AGAIN_BG,
out->antenna_gain.a1 = r123_extract_antgain(out->revision, in, SSB_SPROM1_AGAIN_BG_SHIFT);
SSB_SPROM1_AGAIN_A, out->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,
SSB_SPROM1_AGAIN_A_SHIFT); SSB_SPROM1_AGAIN,
SSB_SPROM1_AGAIN_A,
SSB_SPROM1_AGAIN_A_SHIFT);
if (out->revision >= 2) if (out->revision >= 2)
sprom_extract_r23(out, in); sprom_extract_r23(out, in);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment