Linux wireless drivers development
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Sujith Manoharan <sujith@msujith.org>
Cc: John Linville <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org, ath9k-devel@qca.qualcomm.com
Subject: Re: [PATCH] ath9k: Add debug information
Date: Thu, 21 Aug 2014 08:35:30 -0700	[thread overview]
Message-ID: <1408635330.23250.47.camel@joe-AO725> (raw)
In-Reply-To: <1408633582-6378-1-git-send-email-sujith@msujith.org>

On Thu, 2014-08-21 at 20:36 +0530, Sujith Manoharan wrote:

> Add a few statements to debug channel context operation.
[]
> diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
> index 0ce9e40..da5b522 100644
> --- a/drivers/net/wireless/ath/ath9k/channel.c
> +++ b/drivers/net/wireless/ath/ath9k/channel.c
> @@ -16,6 +16,16 @@
>  
>  #include "ath9k.h"
>  
> +static const char *offchannel_state[] = {
> +	"ATH_OFFCHANNEL_IDLE",
> +	"ATH_OFFCHANNEL_PROBE_SEND",
> +	"ATH_OFFCHANNEL_PROBE_WAIT",
> +	"ATH_OFFCHANNEL_SUSPEND",
> +	"ATH_OFFCHANNEL_ROC_START",
> +	"ATH_OFFCHANNEL_ROC_WAIT",
> +	"ATH_OFFCHANNEL_ROC_DONE",
> +};

Perhaps:
static const char * const offchannel_state[] = {...

It is typically is an unsafe practice to
index an char * array with an enum.

It might be safer to use a lookup function
(and smaller when ath_dbg is not enabled)

Something like:

static const char *offchannel_state_string(enum ath_offchannel_state state)
{
#define case_rtn_string(val) case val: return #val
	switch (state) {
	case_rtn_string(ATH_OFFCHANNEL_IDLE);
	case_rtn_string(ATH_OFFCHANNEL_PROBE_SEND);
	case_rtn_string(ATH_OFFCHANNEL_PROBE_WAIT);
	case_rtn_string(ATH_OFFCHANNEL_SUSPEND);
	case_rtn_string(ATH_OFFCHANNEL_ROC_START);
	case_rtn_string(ATH_OFFCHANNEL_ROC_WAIT);
	case_rtn_string(ATH_OFFCHANNEL_ROC_DONE);
	default:
		return "unknown";
	}
}



  reply	other threads:[~2014-08-21 15:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-21 15:06 [PATCH] ath9k: Add debug information Sujith Manoharan
2014-08-21 15:35 ` Joe Perches [this message]
2014-08-22  2:25   ` Sujith Manoharan

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=1408635330.23250.47.camel@joe-AO725 \
    --to=joe@perches.com \
    --cc=ath9k-devel@qca.qualcomm.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=sujith@msujith.org \
    /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