Search Linux Wireless

Re: [PATCH] ath9k: Add debug information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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";
	}
}


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux