diff mbox series

[v4,2/4] wifi: ath11k: optimize ath11k_tm_cmd_get_version

Message ID 20230517135934.16408-3-quic_rajkbhag@quicinc.com
State New
Headers show
Series ath11k: factory test mode support | expand

Commit Message

Raj Kumar Bhagat May 17, 2023, 1:59 p.m. UTC
From: Govindaraj Saminathan <quic_gsaminat@quicinc.com>

Currently ath11k_tm_cmd_get_version() uses local variable ret.
optimize ath11k_tm_cmd_get_version() to avoid local variable use.

Tested-on : IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

Signed-off-by: Govindaraj Saminathan <quic_gsaminat@quicinc.com>
Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/testmode.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

Comments

Kalle Valo June 1, 2023, 10:28 a.m. UTC | #1
Raj Kumar Bhagat <quic_rajkbhag@quicinc.com> writes:

> From: Govindaraj Saminathan <quic_gsaminat@quicinc.com>
>
> Currently ath11k_tm_cmd_get_version() uses local variable ret.
> optimize ath11k_tm_cmd_get_version() to avoid local variable use.
>
> Tested-on : IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
>
> Signed-off-by: Govindaraj Saminathan <quic_gsaminat@quicinc.com>
> Signed-off-by: Raj Kumar Bhagat <quic_rajkbhag@quicinc.com>
> ---
>  drivers/net/wireless/ath/ath11k/testmode.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath11k/testmode.c b/drivers/net/wireless/ath/ath11k/testmode.c
> index ebeca5eb6a67..f562f860ebf3 100644
> --- a/drivers/net/wireless/ath/ath11k/testmode.c
> +++ b/drivers/net/wireless/ath/ath11k/testmode.c
> @@ -24,7 +24,6 @@ static const struct nla_policy ath11k_tm_policy[ATH11K_TM_ATTR_MAX + 1] = {
>  static int ath11k_tm_cmd_get_version(struct ath11k *ar, struct nlattr *tb[])
>  {
>  	struct sk_buff *skb;
> -	int ret;
>  
>  	ath11k_dbg(ar->ab, ATH11K_DBG_TESTMODE,
>  		   "testmode cmd get version_major %d version_minor %d\n",
> @@ -36,18 +35,12 @@ static int ath11k_tm_cmd_get_version(struct ath11k *ar, struct nlattr *tb[])
>  	if (!skb)
>  		return -ENOMEM;
>  
> -	ret = nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MAJOR,
> -			  ATH11K_TESTMODE_VERSION_MAJOR);
> -	if (ret) {
> -		kfree_skb(skb);
> -		return ret;
> -	}
> -
> -	ret = nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MINOR,
> -			  ATH11K_TESTMODE_VERSION_MINOR);
> -	if (ret) {
> +	if (nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MAJOR,
> +			ATH11K_TESTMODE_VERSION_MAJOR) ||
> +	    nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MINOR,
> +			ATH11K_TESTMODE_VERSION_MINOR)) {
>  		kfree_skb(skb);
> -		return ret;
> +		return -ENOBUFS;
>  	}

When optimising something it's always good to provide numbers to show
the improvement. But I can't see how this really improves anything so I
dropped this patch 2.
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/testmode.c b/drivers/net/wireless/ath/ath11k/testmode.c
index ebeca5eb6a67..f562f860ebf3 100644
--- a/drivers/net/wireless/ath/ath11k/testmode.c
+++ b/drivers/net/wireless/ath/ath11k/testmode.c
@@ -24,7 +24,6 @@  static const struct nla_policy ath11k_tm_policy[ATH11K_TM_ATTR_MAX + 1] = {
 static int ath11k_tm_cmd_get_version(struct ath11k *ar, struct nlattr *tb[])
 {
 	struct sk_buff *skb;
-	int ret;
 
 	ath11k_dbg(ar->ab, ATH11K_DBG_TESTMODE,
 		   "testmode cmd get version_major %d version_minor %d\n",
@@ -36,18 +35,12 @@  static int ath11k_tm_cmd_get_version(struct ath11k *ar, struct nlattr *tb[])
 	if (!skb)
 		return -ENOMEM;
 
-	ret = nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MAJOR,
-			  ATH11K_TESTMODE_VERSION_MAJOR);
-	if (ret) {
-		kfree_skb(skb);
-		return ret;
-	}
-
-	ret = nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MINOR,
-			  ATH11K_TESTMODE_VERSION_MINOR);
-	if (ret) {
+	if (nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MAJOR,
+			ATH11K_TESTMODE_VERSION_MAJOR) ||
+	    nla_put_u32(skb, ATH11K_TM_ATTR_VERSION_MINOR,
+			ATH11K_TESTMODE_VERSION_MINOR)) {
 		kfree_skb(skb);
-		return ret;
+		return -ENOBUFS;
 	}
 
 	return cfg80211_testmode_reply(skb);