linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: rtw89: chan: Use swap() to improve rtw89_swap_sub_entity()
@ 2024-07-10 19:04 Thorsten Blum
  2024-07-11  0:13 ` Ping-Ke Shih
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2024-07-10 19:04 UTC (permalink / raw)
  To: pkshih, kvalo; +Cc: linux-wireless, linux-kernel, Thorsten Blum

Use the swap() macro to simplify the rtw89_swap_sub_entity() function
and improve its readability. Remove the local variable tmp.

Fixes the following Coccinelle/coccicheck warning reported by
swap.cocci:

  WARNING opportunity for swap()

Compile-tested only.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 drivers/net/wireless/realtek/rtw89/chan.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
index 051a3cad6101..3b1997223cc5 100644
--- a/drivers/net/wireless/realtek/rtw89/chan.c
+++ b/drivers/net/wireless/realtek/rtw89/chan.c
@@ -2322,7 +2322,6 @@ static void rtw89_swap_sub_entity(struct rtw89_dev *rtwdev,
 				  enum rtw89_sub_entity_idx idx2)
 {
 	struct rtw89_hal *hal = &rtwdev->hal;
-	struct rtw89_sub_entity tmp;
 	struct rtw89_vif *rtwvif;
 	u8 cur;
 
@@ -2332,9 +2331,7 @@ static void rtw89_swap_sub_entity(struct rtw89_dev *rtwdev,
 	hal->sub[idx1].cfg->idx = idx2;
 	hal->sub[idx2].cfg->idx = idx1;
 
-	tmp = hal->sub[idx1];
-	hal->sub[idx1] = hal->sub[idx2];
-	hal->sub[idx2] = tmp;
+	swap(hal->sub[idx1], hal->sub[idx2]);
 
 	rtw89_for_each_rtwvif(rtwdev, rtwvif) {
 		if (!rtwvif->chanctx_assigned)
-- 
2.45.2


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

* RE: [PATCH] wifi: rtw89: chan: Use swap() to improve rtw89_swap_sub_entity()
  2024-07-10 19:04 [PATCH] wifi: rtw89: chan: Use swap() to improve rtw89_swap_sub_entity() Thorsten Blum
@ 2024-07-11  0:13 ` Ping-Ke Shih
  0 siblings, 0 replies; 2+ messages in thread
From: Ping-Ke Shih @ 2024-07-11  0:13 UTC (permalink / raw)
  To: Thorsten Blum, kvalo@kernel.org
  Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org

Thorsten Blum <thorsten.blum@toblux.com> wrote:
> Use the swap() macro to simplify the rtw89_swap_sub_entity() function
> and improve its readability. Remove the local variable tmp.
> 
> Fixes the following Coccinelle/coccicheck warning reported by
> swap.cocci:
> 
>   WARNING opportunity for swap()
> 
> Compile-tested only.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

The same patch [1] has been applied. 

[1] https://lore.kernel.org/all/20240529020244.129027-1-jiapeng.chong@linux.alibaba.com/


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

end of thread, other threads:[~2024-07-11  0:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 19:04 [PATCH] wifi: rtw89: chan: Use swap() to improve rtw89_swap_sub_entity() Thorsten Blum
2024-07-11  0:13 ` Ping-Ke Shih

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