mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Chen <jeff.chen_1@nxp.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>
Cc: Brian Norris <briannorris@chromium.org>,
	Francesco Dolcini <francesco@dolcini.it>,
	Johannes Berg <johannes.berg@intel.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Kalle Valo <kvalo@kernel.org>, David Lin <yu-hao.lin@nxp.com>,
	Aditya Kumar Singh <quic_adisi@quicinc.com>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	"open list:MARVELL MWIFIEX WIRELESS DRIVER"
	<linux-wireless@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 10/12] wifi: mwifiex: Use max() to improve code
Date: Wed, 9 Jul 2025 13:42:41 +0800	[thread overview]
Message-ID: <aG4BUWM8o8S7bR9p@nxpwireless-Inspiron-14-Plus-7440> (raw)
In-Reply-To: <20250709022210.304030-11-rongqianfeng@vivo.com>

Hi Qianfeng,
Thanks for the cleanup.

On Wed, Jul 09, 2025 at 10:21:38 AM +0800, Qianfeng Rong wrote:
> Use max() to reduce the code and improve its readability.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
>  drivers/net/wireless/marvell/mwifiex/cfg80211.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> index 286378770e9e..d81db73ac77f 100644
> --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> @@ -4783,10 +4783,8 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
>  		wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta;
>  	wiphy->n_iface_combinations = 1;
>  
> -	if (adapter->max_sta_conn > adapter->max_p2p_conn)
> -		wiphy->max_ap_assoc_sta = adapter->max_sta_conn;
> -	else
> -		wiphy->max_ap_assoc_sta = adapter->max_p2p_conn;
> +	wiphy->max_ap_assoc_sta = max(adapter->max_sta_conn,
> +				      adapter->max_p2p_conn);

adapter->max_sta_conn and adapter->max_p2p_conn are u8, and wiphy->max_ap_assoc_sta is u16.
To ensure type safety and maintainability, I recommend using max_t() with typeof():
wiphy->max_ap_assoc_sta = max_t(typeof(wiphy->max_ap_assoc_sta),
                                adapter->max_sta_conn,
                                adapter->max_p2p_conn);

>  
>  	/* Initialize cipher suits */
>  	wiphy->cipher_suites = mwifiex_cipher_suites;
> -- 
> 2.34.1
> 

  reply	other threads:[~2025-07-09  5:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09  2:21 [PATCH 00/12] net: Use min()/max() " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 01/12] ethernet: liquidio: Use min() " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 02/12] ethernet: cxgb4: " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 03/12] ethernet: octeon_ep: " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 04/12] ethernet: nfp: Use min()/max() " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 05/12] ethernet: qlcnic: Use min() " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 06/12] net: usb: " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 07/12] wifi: ath5k: Use max() " Qianfeng Rong
2025-07-09  4:55   ` Jiri Slaby
2025-07-09  2:21 ` [PATCH 08/12] wifi: ath9k: " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 09/12] wifi: brcm80211: Use min() " Qianfeng Rong
2025-07-09  2:21 ` [PATCH 10/12] wifi: mwifiex: Use max() " Qianfeng Rong
2025-07-09  5:42   ` Jeff Chen [this message]
2025-07-09  6:42     ` Qianfeng Rong
2025-07-09  2:21 ` [PATCH 11/12] wifi: wilc1000: Use min() " Qianfeng Rong
2025-07-09 13:58   ` Alexis Lothoré
2025-07-09  2:21 ` [PATCH 12/12] wifi: rtlwifi: Use min()/max() " Qianfeng Rong
2025-07-09  6:57   ` Ping-Ke Shih
2025-07-11  0:59 ` [PATCH 00/12] net: " Jakub Kicinski
2025-07-14  2:08   ` Qianfeng Rong

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=aG4BUWM8o8S7bR9p@nxpwireless-Inspiron-14-Plus-7440 \
    --to=jeff.chen_1@nxp.com \
    --cc=briannorris@chromium.org \
    --cc=dan.carpenter@linaro.org \
    --cc=francesco@dolcini.it \
    --cc=johannes.berg@intel.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_adisi@quicinc.com \
    --cc=rongqianfeng@vivo.com \
    --cc=s.hauer@pengutronix.de \
    --cc=yu-hao.lin@nxp.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®