rsi: use BUILD_BUG_ON check for fsm_state
authorAmitkumar Karwar <amit.karwar@redpinesignals.com>
Thu, 6 Jul 2017 14:37:04 +0000 (20:07 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 28 Jul 2017 14:22:32 +0000 (17:22 +0300)
Whenever new fsm_state enum element is added, fsm_state array
also needs to be updated. If this change is missed, we may end
up doing invalid access in array. BUILD_BUG_ON check will help
to avoid this problem.

Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/rsi/rsi_91x_debugfs.c
drivers/net/wireless/rsi/rsi_main.h

index 4c0a493bd44efc23ee8cd21890955a047051121f..f3b91b656351fbd9713e664ee740933247a49140 100644 (file)
@@ -138,6 +138,8 @@ static int rsi_stats_read(struct seq_file *seq, void *data)
        seq_puts(seq, "==> RSI STA DRIVER STATUS <==\n");
        seq_puts(seq, "DRIVER_FSM_STATE: ");
 
+       BUILD_BUG_ON(ARRAY_SIZE(fsm_state) != NUM_FSM_STATES);
+
        if (common->fsm_state <= FSM_MAC_INIT_DONE)
                seq_printf(seq, "%s", fsm_state[common->fsm_state]);
 
index f3985250b5933ca68212b2e6857f5d21cd364e76..72675ebcd454ffcd817adb5a98f573905206e7a7 100644 (file)
@@ -40,7 +40,9 @@ enum RSI_FSM_STATES {
        FSM_RESET_MAC_SENT,
        FSM_RADIO_CAPS_SENT,
        FSM_BB_RF_PROG_SENT,
-       FSM_MAC_INIT_DONE
+       FSM_MAC_INIT_DONE,
+
+       NUM_FSM_STATES
 };
 
 extern u32 rsi_zone_enabled;