linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: ath9k: simplify ar9003_hw_process_ini()
@ 2023-08-23 12:52 Dmitry Antipov
  2023-08-23 15:10 ` Jeff Johnson
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Antipov @ 2023-08-23 12:52 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Since commit 8896934c1684 ("ath9k_hw: remove direct accesses to channel
mode flags") changes 'ar9550_hw_get_modes_txgain_index()' so it never
returns -EINVAL, and 'ar9561_hw_get_modes_txgain_index()' never returns
negative value too, an extra check in 'ar9003_hw_process_ini()' may be
dropped.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index a29c11f944a5..4731e6618209 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -925,9 +925,6 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
 			modes_txgain_index =
 				ar9561_hw_get_modes_txgain_index(ah, chan);
 
-		if (modes_txgain_index < 0)
-			return -EINVAL;
-
 		REG_WRITE_ARRAY(&ah->iniModesTxGain, modes_txgain_index,
 				regWrites);
 	} else {
-- 
2.41.0


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

* Re: [PATCH] wifi: ath9k: simplify ar9003_hw_process_ini()
  2023-08-23 12:52 [PATCH] wifi: ath9k: simplify ar9003_hw_process_ini() Dmitry Antipov
@ 2023-08-23 15:10 ` Jeff Johnson
  2023-08-23 18:23   ` [PATCH 1/2] " Dmitry Antipov
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff Johnson @ 2023-08-23 15:10 UTC (permalink / raw)
  To: Dmitry Antipov, Toke Høiland-Jørgensen
  Cc: Kalle Valo, linux-wireless, lvc-project

On 8/23/2023 5:52 AM, Dmitry Antipov wrote:
> Since commit 8896934c1684 ("ath9k_hw: remove direct accesses to channel
> mode flags") changes 'ar9550_hw_get_modes_txgain_index()' so it never
> returns -EINVAL, and 'ar9561_hw_get_modes_txgain_index()' never returns
> negative value too, an extra check in 'ar9003_hw_process_ini()' may be
> dropped.

Can you change the return type of those two functions from int to u32 to 
further signify that they always return a valid index and never return a 
negative errno

> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>   drivers/net/wireless/ath/ath9k/ar9003_phy.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> index a29c11f944a5..4731e6618209 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> @@ -925,9 +925,6 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
>   			modes_txgain_index =
>   				ar9561_hw_get_modes_txgain_index(ah, chan);
>   
> -		if (modes_txgain_index < 0)
> -			return -EINVAL;
> -
>   		REG_WRITE_ARRAY(&ah->iniModesTxGain, modes_txgain_index,
>   				regWrites);
>   	} else {


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

* [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini()
  2023-08-23 15:10 ` Jeff Johnson
@ 2023-08-23 18:23   ` Dmitry Antipov
  2023-08-23 18:23     ` [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes Dmitry Antipov
                       ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Dmitry Antipov @ 2023-08-23 18:23 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless,
	lvc-project, Dmitry Antipov

Since commit 8896934c1684 ("ath9k_hw: remove direct accesses to channel
mode flags") changes 'ar9550_hw_get_modes_txgain_index()' so it never
returns -EINVAL, and 'ar9561_hw_get_modes_txgain_index()' never returns
negative value too, an extra check in 'ar9003_hw_process_ini()' may be
dropped.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index a29c11f944a5..4731e6618209 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -925,9 +925,6 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
 			modes_txgain_index =
 				ar9561_hw_get_modes_txgain_index(ah, chan);
 
-		if (modes_txgain_index < 0)
-			return -EINVAL;
-
 		REG_WRITE_ARRAY(&ah->iniModesTxGain, modes_txgain_index,
 				regWrites);
 	} else {
-- 
2.41.0


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

* [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes
  2023-08-23 18:23   ` [PATCH 1/2] " Dmitry Antipov
@ 2023-08-23 18:23     ` Dmitry Antipov
  2023-08-23 19:45       ` Jeff Johnson
  2023-09-01 10:56       ` Toke Høiland-Jørgensen
  2023-08-23 19:44     ` [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini() Jeff Johnson
                       ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: Dmitry Antipov @ 2023-08-23 18:23 UTC (permalink / raw)
  To: Jeff Johnson
  Cc: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless,
	lvc-project, Dmitry Antipov

Since both 'ar9550_hw_get_modes_txgain_index()' and
'ar9561_hw_get_modes_txgain_index()' never returns
negative values, prefer 'u32' over 'int' and adjust
'ar9003_hw_process_ini()' accordingly.

Suggested-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath9k/ar9003_phy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 4731e6618209..6274d1624261 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -766,10 +766,10 @@ static void ar9003_hw_prog_ini(struct ath_hw *ah,
 	}
 }
 
-static int ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
+static u32 ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
 					    struct ath9k_channel *chan)
 {
-	int ret;
+	u32 ret;
 
 	if (IS_CHAN_2GHZ(chan)) {
 		if (IS_CHAN_HT40(chan))
@@ -791,7 +791,7 @@ static int ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
 	return ret;
 }
 
-static int ar9561_hw_get_modes_txgain_index(struct ath_hw *ah,
+static u32 ar9561_hw_get_modes_txgain_index(struct ath_hw *ah,
 					    struct ath9k_channel *chan)
 {
 	if (IS_CHAN_2GHZ(chan)) {
@@ -916,7 +916,7 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
 	 * TXGAIN initvals.
 	 */
 	if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
-		int modes_txgain_index = 1;
+		u32 modes_txgain_index = 1;
 
 		if (AR_SREV_9550(ah))
 			modes_txgain_index = ar9550_hw_get_modes_txgain_index(ah, chan);
-- 
2.41.0


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

* Re: [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini()
  2023-08-23 18:23   ` [PATCH 1/2] " Dmitry Antipov
  2023-08-23 18:23     ` [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes Dmitry Antipov
@ 2023-08-23 19:44     ` Jeff Johnson
  2023-09-01 10:56     ` Toke Høiland-Jørgensen
  2023-09-20 13:16     ` Kalle Valo
  3 siblings, 0 replies; 9+ messages in thread
From: Jeff Johnson @ 2023-08-23 19:44 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless,
	lvc-project

On 8/23/2023 11:23 AM, Dmitry Antipov wrote:
> Since commit 8896934c1684 ("ath9k_hw: remove direct accesses to channel
> mode flags") changes 'ar9550_hw_get_modes_txgain_index()' so it never
> returns -EINVAL, and 'ar9561_hw_get_modes_txgain_index()' never returns
> negative value too, an extra check in 'ar9003_hw_process_ini()' may be
> dropped.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>

> ---
>   drivers/net/wireless/ath/ath9k/ar9003_phy.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> index a29c11f944a5..4731e6618209 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> @@ -925,9 +925,6 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
>   			modes_txgain_index =
>   				ar9561_hw_get_modes_txgain_index(ah, chan);
>   
> -		if (modes_txgain_index < 0)
> -			return -EINVAL;
> -
>   		REG_WRITE_ARRAY(&ah->iniModesTxGain, modes_txgain_index,
>   				regWrites);
>   	} else {


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

* Re: [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes
  2023-08-23 18:23     ` [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes Dmitry Antipov
@ 2023-08-23 19:45       ` Jeff Johnson
  2023-09-01 10:56       ` Toke Høiland-Jørgensen
  1 sibling, 0 replies; 9+ messages in thread
From: Jeff Johnson @ 2023-08-23 19:45 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: Toke Høiland-Jørgensen, Kalle Valo, linux-wireless,
	lvc-project

On 8/23/2023 11:23 AM, Dmitry Antipov wrote:
> Since both 'ar9550_hw_get_modes_txgain_index()' and
> 'ar9561_hw_get_modes_txgain_index()' never returns
> negative values, prefer 'u32' over 'int' and adjust
> 'ar9003_hw_process_ini()' accordingly.
> 
> Suggested-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>

> ---
>   drivers/net/wireless/ath/ath9k/ar9003_phy.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> index 4731e6618209..6274d1624261 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
> @@ -766,10 +766,10 @@ static void ar9003_hw_prog_ini(struct ath_hw *ah,
>   	}
>   }
>   
> -static int ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
> +static u32 ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
>   					    struct ath9k_channel *chan)
>   {
> -	int ret;
> +	u32 ret;
>   
>   	if (IS_CHAN_2GHZ(chan)) {
>   		if (IS_CHAN_HT40(chan))
> @@ -791,7 +791,7 @@ static int ar9550_hw_get_modes_txgain_index(struct ath_hw *ah,
>   	return ret;
>   }
>   
> -static int ar9561_hw_get_modes_txgain_index(struct ath_hw *ah,
> +static u32 ar9561_hw_get_modes_txgain_index(struct ath_hw *ah,
>   					    struct ath9k_channel *chan)
>   {
>   	if (IS_CHAN_2GHZ(chan)) {
> @@ -916,7 +916,7 @@ static int ar9003_hw_process_ini(struct ath_hw *ah,
>   	 * TXGAIN initvals.
>   	 */
>   	if (AR_SREV_9550(ah) || AR_SREV_9531(ah) || AR_SREV_9561(ah)) {
> -		int modes_txgain_index = 1;
> +		u32 modes_txgain_index = 1;
>   
>   		if (AR_SREV_9550(ah))
>   			modes_txgain_index = ar9550_hw_get_modes_txgain_index(ah, chan);


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

* Re: [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini()
  2023-08-23 18:23   ` [PATCH 1/2] " Dmitry Antipov
  2023-08-23 18:23     ` [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes Dmitry Antipov
  2023-08-23 19:44     ` [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini() Jeff Johnson
@ 2023-09-01 10:56     ` Toke Høiland-Jørgensen
  2023-09-20 13:16     ` Kalle Valo
  3 siblings, 0 replies; 9+ messages in thread
From: Toke Høiland-Jørgensen @ 2023-09-01 10:56 UTC (permalink / raw)
  To: Dmitry Antipov, Jeff Johnson
  Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Dmitry Antipov <dmantipov@yandex.ru> writes:

> Since commit 8896934c1684 ("ath9k_hw: remove direct accesses to channel
> mode flags") changes 'ar9550_hw_get_modes_txgain_index()' so it never
> returns -EINVAL, and 'ar9561_hw_get_modes_txgain_index()' never returns
> negative value too, an extra check in 'ar9003_hw_process_ini()' may be
> dropped.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

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

* Re: [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes
  2023-08-23 18:23     ` [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes Dmitry Antipov
  2023-08-23 19:45       ` Jeff Johnson
@ 2023-09-01 10:56       ` Toke Høiland-Jørgensen
  1 sibling, 0 replies; 9+ messages in thread
From: Toke Høiland-Jørgensen @ 2023-09-01 10:56 UTC (permalink / raw)
  To: Dmitry Antipov, Jeff Johnson
  Cc: Kalle Valo, linux-wireless, lvc-project, Dmitry Antipov

Dmitry Antipov <dmantipov@yandex.ru> writes:

> Since both 'ar9550_hw_get_modes_txgain_index()' and
> 'ar9561_hw_get_modes_txgain_index()' never returns
> negative values, prefer 'u32' over 'int' and adjust
> 'ar9003_hw_process_ini()' accordingly.
>
> Suggested-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>

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

* Re: [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini()
  2023-08-23 18:23   ` [PATCH 1/2] " Dmitry Antipov
                       ` (2 preceding siblings ...)
  2023-09-01 10:56     ` Toke Høiland-Jørgensen
@ 2023-09-20 13:16     ` Kalle Valo
  3 siblings, 0 replies; 9+ messages in thread
From: Kalle Valo @ 2023-09-20 13:16 UTC (permalink / raw)
  To: Dmitry Antipov
  Cc: Jeff Johnson, Toke Høiland-Jørgensen, linux-wireless,
	lvc-project, Dmitry Antipov

Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Since commit 8896934c1684 ("ath9k_hw: remove direct accesses to channel
> mode flags") changes 'ar9550_hw_get_modes_txgain_index()' so it never
> returns -EINVAL, and 'ar9561_hw_get_modes_txgain_index()' never returns
> negative value too, an extra check in 'ar9003_hw_process_ini()' may be
> dropped.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
> Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

2 patches applied to ath-next branch of ath.git, thanks.

e6a1107bf5eb wifi: ath9k: simplify ar9003_hw_process_ini()
352281e4a0a0 wifi: ath9k: use u32 for txgain indexes

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20230823182401.196270-1-dmantipov@yandex.ru/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2023-09-20 13:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 12:52 [PATCH] wifi: ath9k: simplify ar9003_hw_process_ini() Dmitry Antipov
2023-08-23 15:10 ` Jeff Johnson
2023-08-23 18:23   ` [PATCH 1/2] " Dmitry Antipov
2023-08-23 18:23     ` [PATCH 2/2] wifi: ath9k: use u32 for txgain indexes Dmitry Antipov
2023-08-23 19:45       ` Jeff Johnson
2023-09-01 10:56       ` Toke Høiland-Jørgensen
2023-08-23 19:44     ` [PATCH 1/2] wifi: ath9k: simplify ar9003_hw_process_ini() Jeff Johnson
2023-09-01 10:56     ` Toke Høiland-Jørgensen
2023-09-20 13:16     ` Kalle Valo

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