linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8712: remove the condition with no effect
@ 2021-10-28  4:31 Saurav Girepunje
  2021-10-28 11:26 ` Pavel Skripkin
  0 siblings, 1 reply; 3+ messages in thread
From: Saurav Girepunje @ 2021-10-28  4:31 UTC (permalink / raw)
  To: Larry.Finger, florian.c.schilhabel, gregkh, alec,
	saurav.girepunje, linux-staging, linux-kernel
  Cc: saurav.girepunje

Remove the if condition check and else code section in
query_rx_phy_status(). As variable cck_highpwr is assign a value of '0'
after this assignment, if condition check !cck_highpwr is always
going to be true. So remove the if condition check as well as else
section which will be never true.

After removing the if condition there is no use of local variable
cck_highpwr. Remove the local variable cck_highpwr.

Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
---
 drivers/staging/rtl8712/rtl8712_recv.c | 75 +++++++++-----------------
 1 file changed, 26 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index 0ffb30f1af7e..f04c454e16a6 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -708,7 +708,7 @@ static void query_rx_phy_status(struct _adapter *padapter,
 	s8 rx_pwr[4], rx_pwr_all;
 	u8 pwdb_all;
 	u32 rssi, total_rssi = 0;
-	u8 bcck_rate = 0, rf_rx_num = 0, cck_highpwr = 0;
+	u8 bcck_rate = 0, rf_rx_num = 0;
 	struct phy_cck_rx_status *pcck_buf;
 	u8 sq;

@@ -723,55 +723,32 @@ static void query_rx_phy_status(struct _adapter *padapter,
 		 * (2)PWDB, Average PWDB calculated by hardware
 		 * (for rate adaptive)
 		 */
-		if (!cck_highpwr) {
-			report = pcck_buf->cck_agc_rpt & 0xc0;
-			report >>= 6;
-			switch (report) {
-			/* Modify the RF RNA gain value to -40, -20,
-			 * -2, 14 by Jenyu's suggestion
-			 * Note: different RF with the different
-			 * RNA gain.
-			 */
-			case 0x3:
-				rx_pwr_all = -40 - (pcck_buf->cck_agc_rpt &
-					     0x3e);
-				break;
-			case 0x2:
-				rx_pwr_all = -20 - (pcck_buf->cck_agc_rpt &
-					     0x3e);
-				break;
-			case 0x1:
-				rx_pwr_all = -2 - (pcck_buf->cck_agc_rpt &
-					     0x3e);
-				break;
-			case 0x0:
-				rx_pwr_all = 14 - (pcck_buf->cck_agc_rpt &
-					     0x3e);
-				break;
-			}
-		} else {
-			report = ((u8)(le32_to_cpu(pphy_stat->phydw1) >> 8)) &
-				 0x60;
-			report >>= 5;
-			switch (report) {
-			case 0x3:
-				rx_pwr_all = -40 - ((pcck_buf->cck_agc_rpt &
-					     0x1f) << 1);
-				break;
-			case 0x2:
-				rx_pwr_all = -20 - ((pcck_buf->cck_agc_rpt &
-					     0x1f) << 1);
-				break;
-			case 0x1:
-				rx_pwr_all = -2 - ((pcck_buf->cck_agc_rpt &
-					     0x1f) << 1);
-				break;
-			case 0x0:
-				rx_pwr_all = 14 - ((pcck_buf->cck_agc_rpt &
-					     0x1f) << 1);
-				break;
-			}
+		report = pcck_buf->cck_agc_rpt & 0xc0;
+		report >>= 6;
+		switch (report) {
+		/* Modify the RF RNA gain value to -40, -20,
+		 * -2, 14 by Jenyu's suggestion
+		 * Note: different RF with the different
+		 * RNA gain.
+		 */
+		case 0x3:
+			rx_pwr_all = -40 - (pcck_buf->cck_agc_rpt &
+				     0x3e);
+			break;
+		case 0x2:
+			rx_pwr_all = -20 - (pcck_buf->cck_agc_rpt &
+				     0x3e);
+			break;
+		case 0x1:
+			rx_pwr_all = -2 - (pcck_buf->cck_agc_rpt &
+				     0x3e);
+			break;
+		case 0x0:
+			rx_pwr_all = 14 - (pcck_buf->cck_agc_rpt &
+				     0x3e);
+			break;
 		}
+
 		pwdb_all = query_rx_pwr_percentage(rx_pwr_all);
 		/* CCK gain is smaller than OFDM/MCS gain,*/
 		/* so we add gain diff by experiences, the val is 6 */
--
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: rtl8712: remove the condition with no effect
  2021-10-28  4:31 [PATCH] staging: rtl8712: remove the condition with no effect Saurav Girepunje
@ 2021-10-28 11:26 ` Pavel Skripkin
  2021-10-31  9:35   ` Saurav Girepunje
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Skripkin @ 2021-10-28 11:26 UTC (permalink / raw)
  To: Saurav Girepunje, Larry.Finger, florian.c.schilhabel, gregkh,
	alec, linux-staging, linux-kernel
  Cc: saurav.girepunje

On 10/28/21 07:31, Saurav Girepunje wrote:
> Remove the if condition check and else code section in
> query_rx_phy_status(). As variable cck_highpwr is assign a value of '0'
> after this assignment, if condition check !cck_highpwr is always
> going to be true. So remove the if condition check as well as else
> section which will be never true.
> 
> After removing the if condition there is no use of local variable
> cck_highpwr. Remove the local variable cck_highpwr.
> 
> Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
> ---

[code snip]

> +		report = pcck_buf->cck_agc_rpt & 0xc0;
> +		report >>= 6;
> +		switch (report) {
> +		/* Modify the RF RNA gain value to -40, -20,
> +		 * -2, 14 by Jenyu's suggestion
> +		 * Note: different RF with the different
> +		 * RNA gain.
> +		 */
> +		case 0x3:
> +			rx_pwr_all = -40 - (pcck_buf->cck_agc_rpt &
> +				     0x3e);

You can move "0x3e);" part on previous line, since it will fit even 80 
characters boundary. It will improve readability, IMO

Same below.

> +			break;
> +		case 0x2:
> +			rx_pwr_all = -20 - (pcck_buf->cck_agc_rpt &
> +				     0x3e);
> +			break;
> +		case 0x1:
> +			rx_pwr_all = -2 - (pcck_buf->cck_agc_rpt &
> +				     0x3e);
> +			break;
> +		case 0x0:
> +			rx_pwr_all = 14 - (pcck_buf->cck_agc_rpt &
> +				     0x3e);
> +			break;
>   		}
> +



With regards,
Pavel Skripkin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: rtl8712: remove the condition with no effect
  2021-10-28 11:26 ` Pavel Skripkin
@ 2021-10-31  9:35   ` Saurav Girepunje
  0 siblings, 0 replies; 3+ messages in thread
From: Saurav Girepunje @ 2021-10-31  9:35 UTC (permalink / raw)
  To: Pavel Skripkin, Larry.Finger, florian.c.schilhabel, gregkh, alec,
	linux-staging, linux-kernel
  Cc: saurav.girepunje



On 28/10/21 4:56 pm, Pavel Skripkin wrote:
> On 10/28/21 07:31, Saurav Girepunje wrote:
>> Remove the if condition check and else code section in
>> query_rx_phy_status(). As variable cck_highpwr is assign a value of '0'
>> after this assignment, if condition check !cck_highpwr is always
>> going to be true. So remove the if condition check as well as else
>> section which will be never true.
>>
>> After removing the if condition there is no use of local variable
>> cck_highpwr. Remove the local variable cck_highpwr.
>>
>> Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
>> ---
> 
> [code snip]
> 
>> +        report = pcck_buf->cck_agc_rpt & 0xc0;
>> +        report >>= 6;
>> +        switch (report) {
>> +        /* Modify the RF RNA gain value to -40, -20,
>> +         * -2, 14 by Jenyu's suggestion
>> +         * Note: different RF with the different
>> +         * RNA gain.
>> +         */
>> +        case 0x3:
>> +            rx_pwr_all = -40 - (pcck_buf->cck_agc_rpt &
>> +                     0x3e);
> 
> You can move "0x3e);" part on previous line, since it will fit even 80 characters boundary. It will improve readability, IMO
> 
> Same below.
> 
Yes, This is also can be done on same patch.
Thanks for review Pavel
>> +            break;
>> +        case 0x2:
>> +            rx_pwr_all = -20 - (pcck_buf->cck_agc_rpt &
>> +                     0x3e);
>> +            break;
>> +        case 0x1:
>> +            rx_pwr_all = -2 - (pcck_buf->cck_agc_rpt &
>> +                     0x3e);
>> +            break;
>> +        case 0x0:
>> +            rx_pwr_all = 14 - (pcck_buf->cck_agc_rpt &
>> +                     0x3e);
>> +            break;
>>           }
>> +
> 
> 
> 
> With regards,
> Pavel Skripkin

Regards,
Saurav 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-31  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28  4:31 [PATCH] staging: rtl8712: remove the condition with no effect Saurav Girepunje
2021-10-28 11:26 ` Pavel Skripkin
2021-10-31  9:35   ` Saurav Girepunje

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).