diff mbox series

[v2] wifi: ath12k: Modify print_array_to_buf() to support arrays with 1-based semantics

Message ID 20241004085915.1788951-1-quic_rdevanat@quicinc.com (mailing list archive)
State Under Review
Delegated to: Jeff Johnson
Headers show
Series [v2] wifi: ath12k: Modify print_array_to_buf() to support arrays with 1-based semantics | expand

Commit Message

Roopni Devanathan Oct. 4, 2024, 8:59 a.m. UTC
The API print_array_to_buf() currently supports printing
arrays with 0 indexing. In some cases, a few arrays need
to be printed with 1-based indexing, i.e., array should be
printed, starting with 1.

Add a new version of print_array_to_buf(), named
print_array_to_buf_index(), which implements the functionality
of print_array_to_index(), but with an extra variable, pointing
to the index starting with which the array should be printed.
Modify print_array_to_buf() to call
print_array_to_buf_index() with 0 as the starting index.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com>
---
 .../net/wireless/ath/ath12k/debugfs_htt_stats.c    | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)


base-commit: 8ed36fe71fd60c851540839b105fd1fddc870c61

Comments

Jeff Johnson Oct. 4, 2024, 3:17 p.m. UTC | #1
On 10/4/2024 1:59 AM, Roopni Devanathan wrote:
> The API print_array_to_buf() currently supports printing
> arrays with 0 indexing. In some cases, a few arrays need
> to be printed with 1-based indexing, i.e., array should be
> printed, starting with 1.
> 
> Add a new version of print_array_to_buf(), named
> print_array_to_buf_index(), which implements the functionality
> of print_array_to_index(), but with an extra variable, pointing
> to the index starting with which the array should be printed.
> Modify print_array_to_buf() to call
> print_array_to_buf_index() with 0 as the starting index.
> 
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> 
> Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com>
> ---
>  .../net/wireless/ath/ath12k/debugfs_htt_stats.c    | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> index f1b7e74aefe4..ec7add76ec85 100644
> --- a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> +++ b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> @@ -12,8 +12,8 @@
>  #include "dp_rx.h"
>  
>  static u32
> -print_array_to_buf(u8 *buf, u32 offset, const char *header,
> -		   const __le32 *array, u32 array_len, const char *footer)
> +print_array_to_buf_index(u8 *buf, u32 offset, const char *header, u32 stats_index,
> +			 const __le32 *array, u32 array_len, const char *footer)
>  {
>  	int index = 0;
>  	u8 i;
> @@ -26,7 +26,7 @@ print_array_to_buf(u8 *buf, u32 offset, const char *header,
>  	for (i = 0; i < array_len; i++) {
>  		index += scnprintf(buf + offset + index,
>  				   (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
> -				   " %u:%u,", i, le32_to_cpu(array[i]));
> +				   " %u:%u,", stats_index++, le32_to_cpu(array[i]));
>  	}
>  	/* To overwrite the last trailing comma */
>  	index--;
> @@ -40,6 +40,14 @@ print_array_to_buf(u8 *buf, u32 offset, const char *header,
>  	return index;
>  }
>  
> +static u32
> +print_array_to_buf(u8 *buf, u32 offset, const char *header,
> +		   const __le32 *array, u32 array_len, const char *footer)
> +{
> +	return print_array_to_buf_index(buf, offset, header, 0, array, array_len,
> +					footer);
> +}
> +
>  static void
>  htt_print_tx_pdev_stats_cmn_tlv(const void *tag_buf, u16 tag_len,
>  				struct debug_htt_stats_req *stats_req)
> 
> base-commit: 8ed36fe71fd60c851540839b105fd1fddc870c61

LGTM, please rebase your other debugfs_htt_stats changes on top of this
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
index f1b7e74aefe4..ec7add76ec85 100644
--- a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
+++ b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
@@ -12,8 +12,8 @@ 
 #include "dp_rx.h"
 
 static u32
-print_array_to_buf(u8 *buf, u32 offset, const char *header,
-		   const __le32 *array, u32 array_len, const char *footer)
+print_array_to_buf_index(u8 *buf, u32 offset, const char *header, u32 stats_index,
+			 const __le32 *array, u32 array_len, const char *footer)
 {
 	int index = 0;
 	u8 i;
@@ -26,7 +26,7 @@  print_array_to_buf(u8 *buf, u32 offset, const char *header,
 	for (i = 0; i < array_len; i++) {
 		index += scnprintf(buf + offset + index,
 				   (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
-				   " %u:%u,", i, le32_to_cpu(array[i]));
+				   " %u:%u,", stats_index++, le32_to_cpu(array[i]));
 	}
 	/* To overwrite the last trailing comma */
 	index--;
@@ -40,6 +40,14 @@  print_array_to_buf(u8 *buf, u32 offset, const char *header,
 	return index;
 }
 
+static u32
+print_array_to_buf(u8 *buf, u32 offset, const char *header,
+		   const __le32 *array, u32 array_len, const char *footer)
+{
+	return print_array_to_buf_index(buf, offset, header, 0, array, array_len,
+					footer);
+}
+
 static void
 htt_print_tx_pdev_stats_cmn_tlv(const void *tag_buf, u16 tag_len,
 				struct debug_htt_stats_req *stats_req)