public inbox for ath12k@lists.infradead.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@kernel.org>
To: Roopni Devanathan <quic_rdevanat@quicinc.com>
Cc: <ath12k@lists.infradead.org>,  <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 4/6] wifi: ath12k: Add API to print s8 arrays in HTT stats
Date: Thu, 19 Dec 2024 13:58:22 +0200	[thread overview]
Message-ID: <87zfkrhokh.fsf@kernel.org> (raw)
In-Reply-To: <20241217095216.1543923-5-quic_rdevanat@quicinc.com> (Roopni Devanathan's message of "Tue, 17 Dec 2024 15:22:14 +0530")

Roopni Devanathan <quic_rdevanat@quicinc.com> writes:

> Currently, print_array_to_buf() is used to print arrays to HTT
> stats buffer. This API supports printing only arrays with 32-bit
> unsigned integers. Add API print_array_to_buf_s8(), which
> implements print_array_to_buf()'s functionality to all the
> arrays with 8-bit signed integers.
>
> Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1
> Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
>
> Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com>

s/API/function/

And maybe not even use the term 'function' that, saying foo() should be
clear anyone that it's a function.

An example output would be nice.

> ---
>  .../wireless/ath/ath12k/debugfs_htt_stats.c   | 28 +++++++++++++++++++
>  1 file changed, 28 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> index 4569ff40e9d8..621676daf971 100644
> --- a/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> +++ b/drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c
> @@ -48,6 +48,34 @@ print_array_to_buf(u8 *buf, u32 offset, const char *header,
>  					footer);
>  }
>  
> +static u32
> +print_array_to_buf_s8(u8 *buf, u32 offset, const char *header, u32 stats_index,
> +		      const s8 *array, u32 array_len, const char *footer)
> +{

I would rather have a separate buf_len variable instead of silently
assuming it's ATH12K_HTT_STATS_BUF_SIZE, much safer that way.

> +	int index = 0;
> +	u8 i;
> +
> +	if (header) {
> +		index += scnprintf(buf + offset,
> +				   ATH12K_HTT_STATS_BUF_SIZE - offset,
> +				   "%s = ", header);
> +	}

Empty line here.

> +	for (i = 0; i < array_len; i++) {
> +		index += scnprintf(buf + offset + index,
> +				   (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
> +				   " %u:%d,", stats_index++, array[i]);
> +	}

Empty line.

> +	index--;
> +	*(buf + offset + index) = '\0';

Avoid pointer arithmetic:

buf[offset + index] = '\0'

But first check that 'offset + index < buf_len'.

> +	if (footer) {
> +		index += scnprintf(buf + offset + index,
> +				   (ATH12K_HTT_STATS_BUF_SIZE - offset) - index,
> +				   "%s", footer);
> +	}

Empty line.

> +	return index;
> +}
> +
>  static const char *ath12k_htt_ax_tx_rx_ru_size_to_str(u8 ru_size)
>  {
>  	switch (ru_size) {

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

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


  reply	other threads:[~2024-12-19 11:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17  9:52 [PATCH 0/6] wifi: ath12k: Support Sounding, Latency, Trigger, FSE stats Roopni Devanathan
2024-12-17  9:52 ` [PATCH 1/6] wifi: ath12k: Support Sounding Stats Roopni Devanathan
2024-12-19 11:41   ` Kalle Valo
2024-12-17  9:52 ` [PATCH 2/6] wifi: ath12k: Support Latency Stats Roopni Devanathan
2024-12-19 11:45   ` Kalle Valo
2024-12-17  9:52 ` [PATCH 3/6] wifi: ath12k: Support Uplink OFDMA Trigger Stats Roopni Devanathan
2024-12-19 11:46   ` Kalle Valo
2024-12-17  9:52 ` [PATCH 4/6] wifi: ath12k: Add API to print s8 arrays in HTT stats Roopni Devanathan
2024-12-19 11:58   ` Kalle Valo [this message]
2024-12-24 10:19     ` Roopni Devanathan
2024-12-17  9:52 ` [PATCH 5/6] wifi: ath12k: Support Uplink MUMIMO Trigger Stats Roopni Devanathan
2024-12-19 13:18   ` Kalle Valo
2024-12-17  9:52 ` [PATCH 6/6] wifi: ath12k: Support Received FSE Stats Roopni Devanathan
2024-12-19 13:21   ` Kalle Valo
2024-12-24 10:20     ` Roopni Devanathan

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=87zfkrhokh.fsf@kernel.org \
    --to=kvalo@kernel.org \
    --cc=ath12k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=quic_rdevanat@quicinc.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