All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] staging: rtl8192e: some simple cleanups
@ 2023-06-19 15:09 Michael Straube
  2023-06-19 15:09 ` [PATCH 1/4] staging: rtl8192e: clean up brace coding style issues Michael Straube
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michael Straube @ 2023-06-19 15:09 UTC (permalink / raw)
  To: gregkh; +Cc: philipp.g.hortmann, linux-staging, linux-kernel, Michael Straube

Four patches with simple coding style cleanups.

Michael Straube (4):
  staging: rtl8192e: clean up brace coding style issues
  staging: rtl8192e: convert else if sequence to switch
  staging: rtl8192e: remove return statement from void function
  staging: rtl8192e: remove comparison to true

 .../staging/rtl8192e/rtl8192e/r8192E_dev.c    |  3 +-
 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 11 +++---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c    |  3 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_ps.c    |  3 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c    |  6 +--
 drivers/staging/rtl8192e/rtllib_softmac.c     | 39 +++++++++++--------
 drivers/staging/rtl8192e/rtllib_softmac_wx.c  |  4 +-
 7 files changed, 40 insertions(+), 29 deletions(-)

-- 
2.41.0


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

* [PATCH 1/4] staging: rtl8192e: clean up brace coding style issues
  2023-06-19 15:09 [PATCH 0/4] staging: rtl8192e: some simple cleanups Michael Straube
@ 2023-06-19 15:09 ` Michael Straube
  2023-06-19 15:09 ` [PATCH 2/4] staging: rtl8192e: convert else if sequence to switch Michael Straube
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2023-06-19 15:09 UTC (permalink / raw)
  To: gregkh; +Cc: philipp.g.hortmann, linux-staging, linux-kernel, Michael Straube

Clean up brace coding style in if/else statements to improve
readability and clear checkpatch issues.

CHECK: braces {} should be used on all arms of this statement
CHECK: Unbalanced braces around else statement

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 .../staging/rtl8192e/rtl8192e/r8192E_dev.c    |  3 ++-
 .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 10 +++++---
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c    |  3 ++-
 drivers/staging/rtl8192e/rtl8192e/rtl_ps.c    |  3 ++-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c    |  4 +--
 drivers/staging/rtl8192e/rtllib_softmac.c     | 25 +++++++++++--------
 drivers/staging/rtl8192e/rtllib_softmac_wx.c  |  4 +--
 7 files changed, 30 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 7683853e7c46..e5925899402c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -765,8 +765,9 @@ void rtl92e_link_change(struct net_device *dev)
 				;
 			else
 				priv->receive_config = reg |= RCR_CBSSID;
-		} else
+		} else {
 			priv->receive_config = reg &= ~RCR_CBSSID;
+		}
 
 		rtl92e_writel(dev, RCR, reg);
 	}
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 7b0da55fa7aa..24180670ea0b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -39,8 +39,9 @@ void rtl92e_set_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask,
 		BitShift = _rtl92e_calculate_bit_shift(dwBitMask);
 		NewValue = (OriginalValue & ~dwBitMask) | (dwData << BitShift);
 		rtl92e_writel(dev, dwRegAddr, NewValue);
-	} else
+	} else {
 		rtl92e_writel(dev, dwRegAddr, dwData);
+	}
 }
 
 u32 rtl92e_get_bb_reg(struct net_device *dev, u32 dwRegAddr, u32 dwBitMask)
@@ -163,10 +164,10 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr,
 						New_Value);
-		} else
+		} else {
 			_rtl92e_phy_rf_fw_write(dev, eRFPath, RegAddr, Data);
+		}
 		udelay(200);
-
 	} else {
 		if (BitMask != bMask12Bits) {
 			Original_Value = _rtl92e_phy_rf_read(dev, eRFPath,
@@ -175,8 +176,9 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath,
 			New_Value = (Original_Value & ~BitMask) | (Data << BitShift);
 
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, New_Value);
-		} else
+		} else {
 			_rtl92e_phy_rf_write(dev, eRFPath, RegAddr, Data);
+		}
 	}
 }
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index adb6f12c89d8..37c275cac40b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -622,8 +622,9 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev)
 				} else if (priv->rtllib->current_network.channel != 14 && priv->bcck_in_ch14) {
 					priv->bcck_in_ch14 = false;
 					rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
-				} else
+				} else {
 					rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
+				}
 			}
 
 			if (priv->cck_present_attn_diff <= -12 ||
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
index 5ecade840d75..1c49d5da68eb 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
@@ -219,8 +219,9 @@ void rtl92e_leisure_ps_enter(struct net_device *dev)
 
 			if (priv->rtllib->ps == RTLLIB_PS_DISABLED)
 				_rtl92e_ps_set_mode(dev, RTLLIB_PS_MBCAST | RTLLIB_PS_UNICAST);
-		} else
+		} else {
 			psc->LpsIdleCount++;
+		}
 	}
 }
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 4436442b56dd..b680757cfcf6 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -568,9 +568,9 @@ static int _rtl92e_wx_set_frag(struct net_device *dev,
 	if (priv->hw_radio_off)
 		return 0;
 
-	if (wrqu->frag.disabled)
+	if (wrqu->frag.disabled) {
 		priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
-	else {
+	} else {
 		if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
 		    wrqu->frag.value > MAX_FRAG_THRESHOLD)
 			return -EINVAL;
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 7494c7e6fff6..a47614c837ce 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -809,8 +809,9 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee,
 		erpinfo_content = 0;
 		if (ieee->current_network.buseprotection)
 			erpinfo_content |= ERP_UseProtection;
-	} else
+	} else {
 		erp_len = 0;
+	}
 
 	crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx];
 	encrypt = ieee->host_encrypt && crypt && crypt->ops &&
@@ -1383,9 +1384,9 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr)
 
 	skb = rtllib_authentication_req(beacon, ieee, 0, daddr);
 
-	if (!skb)
+	if (!skb) {
 		rtllib_associate_abort(ieee);
-	else {
+	} else {
 		ieee->link_state = RTLLIB_ASSOCIATING_AUTHENTICATING;
 		netdev_dbg(ieee->dev, "Sending authentication request\n");
 		softmac_mgmt_xmit(skb, ieee);
@@ -1408,9 +1409,9 @@ static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge,
 
 	skb = rtllib_authentication_req(beacon, ieee, chlen + 2, beacon->bssid);
 
-	if (!skb)
+	if (!skb) {
 		rtllib_associate_abort(ieee);
-	else {
+	} else {
 		c = skb_put(skb, chlen + 2);
 		*(c++) = MFIE_TYPE_CHALLENGE;
 		*(c++) = chlen;
@@ -1439,9 +1440,9 @@ static void rtllib_associate_step2(struct rtllib_device *ieee)
 
 	ieee->softmac_stats.tx_ass_rq++;
 	skb = rtllib_association_req(beacon, ieee);
-	if (!skb)
+	if (!skb) {
 		rtllib_associate_abort(ieee);
-	else {
+	} else {
 		softmac_mgmt_xmit(skb, ieee);
 		mod_timer(&ieee->associate_timer, jiffies + (HZ / 2));
 	}
@@ -1583,11 +1584,12 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
 				net->ssid_len = net->hidden_ssid_len;
 				ssidbroad = 1;
 			}
-		} else
+		} else {
 			ssidmatch =
 			   (ieee->current_network.ssid_len == net->ssid_len) &&
 			   (!strncmp(ieee->current_network.ssid, net->ssid,
 			   net->ssid_len));
+		}
 
 		/* if the user set the AP check if match.
 		 * if the network does not broadcast essid we check the
@@ -2536,8 +2538,9 @@ static void rtllib_start_ibss_wq(void *data)
 			ieee->current_network.rates[3] =
 				 RTLLIB_BASIC_RATE_MASK | RTLLIB_CCK_RATE_11MB;
 
-		} else
+		} else {
 			ieee->current_network.rates_len = 0;
+		}
 
 		if (ieee->modulation & RTLLIB_OFDM_MODULATION) {
 			ieee->current_network.rates_ex_len = 8;
@@ -3119,10 +3122,10 @@ void notify_wx_assoc_event(struct rtllib_device *ieee)
 		return;
 
 	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	if (ieee->link_state == MAC80211_LINKED)
+	if (ieee->link_state == MAC80211_LINKED) {
 		memcpy(wrqu.ap_addr.sa_data, ieee->current_network.bssid,
 		       ETH_ALEN);
-	else {
+	} else {
 		netdev_info(ieee->dev, "%s(): Tell user space disconnected\n",
 			    __func__);
 		eth_zero_addr(wrqu.ap_addr.sa_data);
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index be82f0a655e8..783948fd67ca 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -231,9 +231,9 @@ int rtllib_wx_set_rts(struct rtllib_device *ieee,
 			     struct iw_request_info *info,
 			     union iwreq_data *wrqu, char *extra)
 {
-	if (wrqu->rts.disabled || !wrqu->rts.fixed)
+	if (wrqu->rts.disabled || !wrqu->rts.fixed) {
 		ieee->rts = DEFAULT_RTS_THRESHOLD;
-	else {
+	} else {
 		if (wrqu->rts.value < MIN_RTS_THRESHOLD ||
 				wrqu->rts.value > MAX_RTS_THRESHOLD)
 			return -EINVAL;
-- 
2.41.0


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

* [PATCH 2/4] staging: rtl8192e: convert else if sequence to switch
  2023-06-19 15:09 [PATCH 0/4] staging: rtl8192e: some simple cleanups Michael Straube
  2023-06-19 15:09 ` [PATCH 1/4] staging: rtl8192e: clean up brace coding style issues Michael Straube
@ 2023-06-19 15:09 ` Michael Straube
  2023-06-19 15:09 ` [PATCH 3/4] staging: rtl8192e: remove return statement from void function Michael Straube
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2023-06-19 15:09 UTC (permalink / raw)
  To: gregkh; +Cc: philipp.g.hortmann, linux-staging, linux-kernel, Michael Straube

Convert a sequence of else if statements that all check the same
variable to a single switch statement. With a switch statement it is
easier to see what is going on. Additionally this clears a checkpatch
warning.

WARNING: braces {} are not necessary for any arm of this statement

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/rtl8192e/rtllib_softmac.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index a47614c837ce..7b3cbe28e562 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -2830,15 +2830,19 @@ void rtllib_start_protocol(struct rtllib_device *ieee)
 	 * attempts does not fail just because the user provide the essid
 	 * and the nic is still checking for the AP MAC ??
 	 */
-	if (ieee->iw_mode == IW_MODE_INFRA) {
+	switch (ieee->iw_mode) {
+	case IW_MODE_INFRA:
 		rtllib_start_bss(ieee);
-	} else if (ieee->iw_mode == IW_MODE_ADHOC) {
+		break;
+	case IW_MODE_ADHOC:
 		rtllib_start_ibss(ieee);
-
-	} else if (ieee->iw_mode == IW_MODE_MASTER) {
+		break;
+	case IW_MODE_MASTER:
 		rtllib_start_master_bss(ieee);
-	} else if (ieee->iw_mode == IW_MODE_MONITOR) {
+		break;
+	case IW_MODE_MONITOR:
 		rtllib_start_monitor_mode(ieee);
+		break;
 	}
 }
 
-- 
2.41.0


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

* [PATCH 3/4] staging: rtl8192e: remove return statement from void function
  2023-06-19 15:09 [PATCH 0/4] staging: rtl8192e: some simple cleanups Michael Straube
  2023-06-19 15:09 ` [PATCH 1/4] staging: rtl8192e: clean up brace coding style issues Michael Straube
  2023-06-19 15:09 ` [PATCH 2/4] staging: rtl8192e: convert else if sequence to switch Michael Straube
@ 2023-06-19 15:09 ` Michael Straube
  2023-06-19 15:09 ` [PATCH 4/4] staging: rtl8192e: remove comparison to true Michael Straube
  2023-06-19 20:04 ` [PATCH 0/4] staging: rtl8192e: some simple cleanups Philipp Hortmann
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2023-06-19 15:09 UTC (permalink / raw)
  To: gregkh; +Cc: philipp.g.hortmann, linux-staging, linux-kernel, Michael Straube

Remove unnecessary return statement from the void function
rtl92e_config_mac(). Issue found by checkpatch.

WARNING: void function return statements are not generally useful

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 24180670ea0b..b0857c5709dd 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -268,7 +268,6 @@ void rtl92e_config_mac(struct net_device *dev)
 		rtl92e_set_bb_reg(dev, pdwArray[i], pdwArray[i + 1],
 				  pdwArray[i + 2]);
 	}
-	return;
 }
 
 static void _rtl92e_phy_config_bb(struct net_device *dev, u8 ConfigType)
-- 
2.41.0


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

* [PATCH 4/4] staging: rtl8192e: remove comparison to true
  2023-06-19 15:09 [PATCH 0/4] staging: rtl8192e: some simple cleanups Michael Straube
                   ` (2 preceding siblings ...)
  2023-06-19 15:09 ` [PATCH 3/4] staging: rtl8192e: remove return statement from void function Michael Straube
@ 2023-06-19 15:09 ` Michael Straube
  2023-06-19 20:04 ` [PATCH 0/4] staging: rtl8192e: some simple cleanups Philipp Hortmann
  4 siblings, 0 replies; 6+ messages in thread
From: Michael Straube @ 2023-06-19 15:09 UTC (permalink / raw)
  To: gregkh; +Cc: philipp.g.hortmann, linux-staging, linux-kernel, Michael Straube

Remove a comparison to true reported by checkpatch.

CHECK: Using comparison to true is error prone

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index b680757cfcf6..88975dc804c6 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -391,7 +391,7 @@ static int _rtl92e_wx_set_scan(struct net_device *dev,
 	rt_state = priv->rtllib->rf_power_state;
 	if (!priv->up)
 		return -ENETDOWN;
-	if (priv->rtllib->link_detect_info.bBusyTraffic == true)
+	if (priv->rtllib->link_detect_info.bBusyTraffic)
 		return -EAGAIN;
 
 	if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
-- 
2.41.0


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

* Re: [PATCH 0/4] staging: rtl8192e: some simple cleanups
  2023-06-19 15:09 [PATCH 0/4] staging: rtl8192e: some simple cleanups Michael Straube
                   ` (3 preceding siblings ...)
  2023-06-19 15:09 ` [PATCH 4/4] staging: rtl8192e: remove comparison to true Michael Straube
@ 2023-06-19 20:04 ` Philipp Hortmann
  4 siblings, 0 replies; 6+ messages in thread
From: Philipp Hortmann @ 2023-06-19 20:04 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: linux-staging, linux-kernel

On 6/19/23 17:09, Michael Straube wrote:
> Four patches with simple coding style cleanups.
> 
> Michael Straube (4):
>    staging: rtl8192e: clean up brace coding style issues
>    staging: rtl8192e: convert else if sequence to switch
>    staging: rtl8192e: remove return statement from void function
>    staging: rtl8192e: remove comparison to true
> 
>   .../staging/rtl8192e/rtl8192e/r8192E_dev.c    |  3 +-
>   .../staging/rtl8192e/rtl8192e/r8192E_phy.c    | 11 +++---
>   drivers/staging/rtl8192e/rtl8192e/rtl_dm.c    |  3 +-
>   drivers/staging/rtl8192e/rtl8192e/rtl_ps.c    |  3 +-
>   drivers/staging/rtl8192e/rtl8192e/rtl_wx.c    |  6 +--
>   drivers/staging/rtl8192e/rtllib_softmac.c     | 39 +++++++++++--------
>   drivers/staging/rtl8192e/rtllib_softmac_wx.c  |  4 +-
>   7 files changed, 40 insertions(+), 29 deletions(-)
> 
Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>

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

end of thread, other threads:[~2023-06-19 20:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-19 15:09 [PATCH 0/4] staging: rtl8192e: some simple cleanups Michael Straube
2023-06-19 15:09 ` [PATCH 1/4] staging: rtl8192e: clean up brace coding style issues Michael Straube
2023-06-19 15:09 ` [PATCH 2/4] staging: rtl8192e: convert else if sequence to switch Michael Straube
2023-06-19 15:09 ` [PATCH 3/4] staging: rtl8192e: remove return statement from void function Michael Straube
2023-06-19 15:09 ` [PATCH 4/4] staging: rtl8192e: remove comparison to true Michael Straube
2023-06-19 20:04 ` [PATCH 0/4] staging: rtl8192e: some simple cleanups Philipp Hortmann

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.