diff options
author | Oscar Carter <oscar.carter@gmx.com> | 2020-04-25 17:15:14 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-28 15:19:13 +0300 |
commit | 345f2d84dd1a749b4711eca88a98c12a87e39c18 (patch) | |
tree | 864e5ee594e504c6c8f4404cb312265acaa648ad /drivers/staging/vt6656 | |
parent | f5e5e3024c1ea8b7dd04f5ac3f89afe08d470233 (diff) | |
download | linux-345f2d84dd1a749b4711eca88a98c12a87e39c18.tar.xz |
staging: vt6656: Add formula to the vnt_rf_addpower function
Use a formula to calculate the return value of the vnt_rf_addpower
function instead of the "if" statement with literal values for every
case.
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
Link: https://lore.kernel.org/r/20200425141514.5528-1-oscar.carter@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vt6656')
-rw-r--r-- | drivers/staging/vt6656/rf.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 06fa8867cfa3..05c9d06f84dd 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -538,26 +538,19 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 data) static u8 vnt_rf_addpower(struct vnt_private *priv) { + int base; s32 rssi = -priv->current_rssi; if (!rssi) return 7; - if (priv->rf_type == RF_VT3226D0) { - if (rssi < -70) - return 9; - else if (rssi < -65) - return 7; - else if (rssi < -60) - return 5; - } else { - if (rssi < -80) - return 9; - else if (rssi < -75) - return 7; - else if (rssi < -70) - return 5; - } + if (priv->rf_type == RF_VT3226D0) + base = -60; + else + base = -70; + + if (rssi < base) + return ((rssi - base + 1) / -5) * 2 + 5; return 0; } |