Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1267456 > unrolled thread

[PATCH] Staging: R8723au: rtw_ieee80211: Fixing code style space issues

Started byMarcos Oviedo <devkerp@gmail.com>
First post2015-11-11 22:40 +0100
Last post2015-11-11 23:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Staging: R8723au: rtw_ieee80211: Fixing code style space issues Marcos Oviedo <devkerp@gmail.com> - 2015-11-11 22:40 +0100
    Re: [PATCH] Staging: R8723au: rtw_ieee80211: Fixing code style space issues Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-11 23:20 +0100

#1267456 — [PATCH] Staging: R8723au: rtw_ieee80211: Fixing code style space issues

FromMarcos Oviedo <devkerp@gmail.com>
Date2015-11-11 22:40 +0100
Subject[PATCH] Staging: R8723au: rtw_ieee80211: Fixing code style space issues
Message-ID<qtLhw-8fl-13@gated-at.bofh.it>
Fixing code style space issues at rtw_mcs_rate23a()

Signed-off-by: Marcos Oviedo <devkerp@gmail.com>
---
 drivers/staging/rtl8723au/core/rtw_ieee80211.c |   80 ++++++++++++++----------
 1 file changed, 48 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
index 07a6490..df89833 100644
--- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
@@ -791,64 +791,80 @@ u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
 
 	if (rf_type == RF_1T1R) {
 		if (mcs->rx_mask[0] & BIT(7))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?1500:1350):
-				((short_GI_20)?722:650);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) :
+				((short_GI_20) ? 722 : 650);
 		else if (mcs->rx_mask[0] & BIT(6))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?1350:1215):
-				((short_GI_20)?650:585);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) :
+				((short_GI_20) ? 650 : 585);
 		else if (mcs->rx_mask[0] & BIT(5))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):
-				((short_GI_20)?578:520);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) :
+				((short_GI_20) ? 578 : 520);
 		else if (mcs->rx_mask[0] & BIT(4))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):
-				((short_GI_20)?433:390);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) :
+				((short_GI_20) ? 433 : 390);
 		else if (mcs->rx_mask[0] & BIT(3))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):
-				((short_GI_20)?289:260);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) :
+				((short_GI_20) ? 289 : 260);
 		else if (mcs->rx_mask[0] & BIT(2))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?450:405):
-				((short_GI_20)?217:195);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) :
+				((short_GI_20) ? 217 : 195);
 		else if (mcs->rx_mask[0] & BIT(1))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):
-				((short_GI_20)?144:130);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) :
+				((short_GI_20) ? 144 : 130);
 		else if (mcs->rx_mask[0] & BIT(0))
-			max_rate = (bw_40MHz) ? ((short_GI_40)?150:135):
-				((short_GI_20)?72:65);
+			max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) :
+				((short_GI_20) ? 72 : 65);
 	} else {
 		if (mcs->rx_mask[1]) {
 			if (mcs->rx_mask[1] & BIT(7))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?3000:2700):((short_GI_20)?1444:1300);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 3000 : 2700) :
+					((short_GI_20) ? 1444 : 1300);
 			else if (mcs->rx_mask[1] & BIT(6))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?2700:2430):((short_GI_20)?1300:1170);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 2700 : 2430) :
+					((short_GI_20) ? 1300 : 1170);
 			else if (mcs->rx_mask[1] & BIT(5))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?2400:2160):((short_GI_20)?1156:1040);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 2400 : 2160) :
+					((short_GI_20) ? 1156 : 1040);
 			else if (mcs->rx_mask[1] & BIT(4))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?1800:1620):((short_GI_20)?867:780);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 1800 : 1620) :
+					((short_GI_20) ? 867 : 780);
 			else if (mcs->rx_mask[1] & BIT(3))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):((short_GI_20)?578:520);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) :
+					((short_GI_20) ? 578 : 520);
 			else if (mcs->rx_mask[1] & BIT(2))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):((short_GI_20)?433:390);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) :
+					((short_GI_20) ? 433 : 390);
 			else if (mcs->rx_mask[1] & BIT(1))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):((short_GI_20)?289:260);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) :
+					((short_GI_20) ? 289 : 260);
 			else if (mcs->rx_mask[1] & BIT(0))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):((short_GI_20)?144:130);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) :
+					((short_GI_20) ? 144 : 130);
 		} else {
 			if (mcs->rx_mask[0] & BIT(7))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?1500:1350):((short_GI_20)?722:650);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) :
+					((short_GI_20) ? 722 : 650);
 			else if (mcs->rx_mask[0] & BIT(6))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?1350:1215):((short_GI_20)?650:585);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) :
+					((short_GI_20) ? 650 : 585);
 			else if (mcs->rx_mask[0] & BIT(5))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):((short_GI_20)?578:520);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) :
+					((short_GI_20) ? 578 : 520);
 			else if (mcs->rx_mask[0] & BIT(4))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):((short_GI_20)?433:390);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) :
+					((short_GI_20) ? 433 : 390);
 			else if (mcs->rx_mask[0] & BIT(3))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):((short_GI_20)?289:260);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) :
+					((short_GI_20) ? 289 : 260);
 			else if (mcs->rx_mask[0] & BIT(2))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?450:405):((short_GI_20)?217:195);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) :
+					((short_GI_20) ? 217 : 195);
 			else if (mcs->rx_mask[0] & BIT(1))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):((short_GI_20)?144:130);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) :
+					((short_GI_20) ? 144 : 130);
 			else if (mcs->rx_mask[0] & BIT(0))
-				max_rate = (bw_40MHz) ? ((short_GI_40)?150:135):((short_GI_20)?72:65);
+				max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) :
+					((short_GI_20) ? 72 : 65);
 		}
 	}
 	return max_rate;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1267480

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2015-11-11 23:20 +0100
Message-ID<qtLUf-hJ-25@gated-at.bofh.it>
In reply to#1267456
On Wed, Nov 11, 2015 at 9:48 AM, Marcos Oviedo <devkerp@gmail.com> wrote:
> Fixing code style space issues at rtw_mcs_rate23a()
>
> Signed-off-by: Marcos Oviedo <devkerp@gmail.com>
> ---
>  drivers/staging/rtl8723au/core/rtw_ieee80211.c |   80 ++++++++++++++----------
>  1 file changed, 48 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
> index 07a6490..df89833 100644
> --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c
> +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
> @@ -791,64 +791,80 @@ u16 rtw_mcs_rate23a(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40,
>
>         if (rf_type == RF_1T1R) {
>                 if (mcs->rx_mask[0] & BIT(7))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?1500:1350):
> -                               ((short_GI_20)?722:650);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) :
> +                               ((short_GI_20) ? 722 : 650);
>                 else if (mcs->rx_mask[0] & BIT(6))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?1350:1215):
> -                               ((short_GI_20)?650:585);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) :
> +                               ((short_GI_20) ? 650 : 585);

Besides that fact you left redundant parens why not to convert this
long list to something more simpler like

static const u16 max_rate_bit0[][] =
{
 …
 {585, 650, 1215, 1350},
 {650, 722, 1350, 1500},
};

u8 line;

line = fls(mcs->rx_mask[0]); /* needs check! */
max_rate = max_rate_bit0[line][…];

Same for the other branch.

>                 else if (mcs->rx_mask[0] & BIT(5))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):
> -                               ((short_GI_20)?578:520);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) :
> +                               ((short_GI_20) ? 578 : 520);
>                 else if (mcs->rx_mask[0] & BIT(4))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):
> -                               ((short_GI_20)?433:390);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) :
> +                               ((short_GI_20) ? 433 : 390);
>                 else if (mcs->rx_mask[0] & BIT(3))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):
> -                               ((short_GI_20)?289:260);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) :
> +                               ((short_GI_20) ? 289 : 260);
>                 else if (mcs->rx_mask[0] & BIT(2))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?450:405):
> -                               ((short_GI_20)?217:195);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) :
> +                               ((short_GI_20) ? 217 : 195);
>                 else if (mcs->rx_mask[0] & BIT(1))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):
> -                               ((short_GI_20)?144:130);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) :
> +                               ((short_GI_20) ? 144 : 130);
>                 else if (mcs->rx_mask[0] & BIT(0))
> -                       max_rate = (bw_40MHz) ? ((short_GI_40)?150:135):
> -                               ((short_GI_20)?72:65);
> +                       max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) :
> +                               ((short_GI_20) ? 72 : 65);
>         } else {
>                 if (mcs->rx_mask[1]) {
>                         if (mcs->rx_mask[1] & BIT(7))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?3000:2700):((short_GI_20)?1444:1300);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 3000 : 2700) :
> +                                       ((short_GI_20) ? 1444 : 1300);
>                         else if (mcs->rx_mask[1] & BIT(6))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?2700:2430):((short_GI_20)?1300:1170);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 2700 : 2430) :
> +                                       ((short_GI_20) ? 1300 : 1170);
>                         else if (mcs->rx_mask[1] & BIT(5))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?2400:2160):((short_GI_20)?1156:1040);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 2400 : 2160) :
> +                                       ((short_GI_20) ? 1156 : 1040);
>                         else if (mcs->rx_mask[1] & BIT(4))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?1800:1620):((short_GI_20)?867:780);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1800 : 1620) :
> +                                       ((short_GI_20) ? 867 : 780);
>                         else if (mcs->rx_mask[1] & BIT(3))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):((short_GI_20)?578:520);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) :
> +                                       ((short_GI_20) ? 578 : 520);
>                         else if (mcs->rx_mask[1] & BIT(2))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):((short_GI_20)?433:390);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) :
> +                                       ((short_GI_20) ? 433 : 390);
>                         else if (mcs->rx_mask[1] & BIT(1))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):((short_GI_20)?289:260);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) :
> +                                       ((short_GI_20) ? 289 : 260);
>                         else if (mcs->rx_mask[1] & BIT(0))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):((short_GI_20)?144:130);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) :
> +                                       ((short_GI_20) ? 144 : 130);
>                 } else {
>                         if (mcs->rx_mask[0] & BIT(7))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?1500:1350):((short_GI_20)?722:650);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) :
> +                                       ((short_GI_20) ? 722 : 650);
>                         else if (mcs->rx_mask[0] & BIT(6))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?1350:1215):((short_GI_20)?650:585);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) :
> +                                       ((short_GI_20) ? 650 : 585);
>                         else if (mcs->rx_mask[0] & BIT(5))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?1200:1080):((short_GI_20)?578:520);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) :
> +                                       ((short_GI_20) ? 578 : 520);
>                         else if (mcs->rx_mask[0] & BIT(4))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?900:810):((short_GI_20)?433:390);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) :
> +                                       ((short_GI_20) ? 433 : 390);
>                         else if (mcs->rx_mask[0] & BIT(3))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?600:540):((short_GI_20)?289:260);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) :
> +                                       ((short_GI_20) ? 289 : 260);
>                         else if (mcs->rx_mask[0] & BIT(2))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?450:405):((short_GI_20)?217:195);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) :
> +                                       ((short_GI_20) ? 217 : 195);
>                         else if (mcs->rx_mask[0] & BIT(1))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?300:270):((short_GI_20)?144:130);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) :
> +                                       ((short_GI_20) ? 144 : 130);
>                         else if (mcs->rx_mask[0] & BIT(0))
> -                               max_rate = (bw_40MHz) ? ((short_GI_40)?150:135):((short_GI_20)?72:65);
> +                               max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) :
> +                                       ((short_GI_20) ? 72 : 65);
>                 }
>         }
>         return max_rate;
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web