From: Oscar Carter <oscar.carter@gmx.com> To: Forest Bond <forest@alittletooquiet.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Dan Carpenter <dan.carpenter@oracle.com>, Oscar Carter <oscar.carter@gmx.com>, Malcolm Priestley <tvboxspy@gmail.com>, Quentin Deslandes <quentin.deslandes@itdev.co.uk>, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: vt6656: Add formula to the vnt_rf_addpower function Date: Thu, 23 Apr 2020 19:05:57 +0200 [thread overview] Message-ID: <20200423170557.10401-1-oscar.carter@gmx.com> (raw) 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> --- Changelog v1 -> v2 - Change the type of "base" variable from s32 to int as Dan Carpenter suggested. - Remove the "--" postoperator and replace with (base - 1) as Dan Carpenter suggested. Also, as this expression has a minus before the parenthesis, remove it an apply the minus operator changing the sign of "base" and literal "1". drivers/staging/vt6656/rf.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 06fa8867cfa3..612fd4a59f8a 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -538,28 +538,14 @@ 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; - } - - return 0; + base = (priv->rf_type == RF_VT3226D0) ? -60 : -70; + return (rssi < base) ? ((rssi - base + 1) / -5) * 2 + 5 : 0; } /* Set Tx power by power level and rate */ -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Oscar Carter <oscar.carter@gmx.com> To: Forest Bond <forest@alittletooquiet.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: devel@driverdev.osuosl.org, Oscar Carter <oscar.carter@gmx.com>, Malcolm Priestley <tvboxspy@gmail.com>, linux-kernel@vger.kernel.org, Dan Carpenter <dan.carpenter@oracle.com> Subject: [PATCH v2] staging: vt6656: Add formula to the vnt_rf_addpower function Date: Thu, 23 Apr 2020 19:05:57 +0200 [thread overview] Message-ID: <20200423170557.10401-1-oscar.carter@gmx.com> (raw) 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> --- Changelog v1 -> v2 - Change the type of "base" variable from s32 to int as Dan Carpenter suggested. - Remove the "--" postoperator and replace with (base - 1) as Dan Carpenter suggested. Also, as this expression has a minus before the parenthesis, remove it an apply the minus operator changing the sign of "base" and literal "1". drivers/staging/vt6656/rf.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 06fa8867cfa3..612fd4a59f8a 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -538,28 +538,14 @@ 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; - } - - return 0; + base = (priv->rf_type == RF_VT3226D0) ? -60 : -70; + return (rssi < base) ? ((rssi - base + 1) / -5) * 2 + 5 : 0; } /* Set Tx power by power level and rate */ -- 2.20.1 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next reply other threads:[~2020-04-23 17:06 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-23 17:05 Oscar Carter [this message] 2020-04-23 17:05 ` [PATCH v2] staging: vt6656: Add formula to the vnt_rf_addpower function Oscar Carter 2020-04-25 10:57 ` Greg Kroah-Hartman 2020-04-25 10:57 ` Greg Kroah-Hartman 2020-04-25 14:02 ` Oscar Carter 2020-04-25 14:02 ` Oscar Carter
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=20200423170557.10401-1-oscar.carter@gmx.com \ --to=oscar.carter@gmx.com \ --cc=dan.carpenter@oracle.com \ --cc=devel@driverdev.osuosl.org \ --cc=forest@alittletooquiet.net \ --cc=gregkh@linuxfoundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=quentin.deslandes@itdev.co.uk \ --cc=tvboxspy@gmail.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.