From patchwork Thu Jul 6 14:37:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitkumar Karwar X-Patchwork-Id: 9828403 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6674F60361 for ; Thu, 6 Jul 2017 14:41:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58BA3285FB for ; Thu, 6 Jul 2017 14:41:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D84B286B6; Thu, 6 Jul 2017 14:41:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4288528645 for ; Thu, 6 Jul 2017 14:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751861AbdGFOld (ORCPT ); Thu, 6 Jul 2017 10:41:33 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33432 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbdGFOld (ORCPT ); Thu, 6 Jul 2017 10:41:33 -0400 Received: by mail-pg0-f65.google.com with SMTP id u62so500519pgb.0 for ; Thu, 06 Jul 2017 07:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HREMxGmWMW+eHwTysIDFLuVV9sA4j3JSbEdl9uTQolE=; b=Oq5KVNCW25DH+CuC+dG2MxgZG/RjuZL6nh4LIGxJMsbzH0cW18i6g6lQKFWY3TjGID 85b0aaafhg7pOQ1wwm73kZ7Ojkeu0FnFyEdIKjXq5Bq8tt5NTXLapbR4HKMCRzZFML6H 9Q2vffUWgqw6p7zaeWvQmu5O4kk8v6vvHZX+Qc+StQfvafCxE3A7zND3RyGRGnW9migF eOuf/eJmGOSKA05LWwxy4HqwQYbZwQFq5IqNKOAdp1JthRCkykRTJ301F89hVjcpH8m/ uI0oL/ZesXcUj36h0PIRxmOlpvQz3E0M7SkwPU5NkL6hvq0CF/joQLGpAJ+wdgnRTO40 wGqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HREMxGmWMW+eHwTysIDFLuVV9sA4j3JSbEdl9uTQolE=; b=PcuCY6AiayOauauBdxpTiYQu1QMg94LpfV82HmmtOgjPHvXAEOZ26nl7s3oAyjd8rJ 4SlQM4trhDGOybp9TSB5ym1sweVq0KCGXgbHk34K681YMopgf3czuscmKkwhQ8rPRmsB Wt+RMjhZ79aFa7ZK0nP0HberkoTXzKJ6LukGAZGy2zFvDhNkrX8ketAYio5uxYzhgdW2 uq8h9N6O8pwHmS2y2dj/lodibwn/oXh0+11G1daDwh9cIXECJT/6dr8nbEbjYGOAErGf twX2SpCIeX7+f3+mbeWFhwj/WhQzLq3jxs4sKyEnZ69oIG7uD4VzZox1k2yEU+7hkHVl vOZQ== X-Gm-Message-State: AIVw111+bkv+O3I0dMyjevIp6eAlvj1ldsAZISBdSn82sKbviE4EnrmK QMx2GT8y+IH3Yw== X-Received: by 10.84.142.1 with SMTP id 1mr29084735plw.130.1499352092378; Thu, 06 Jul 2017 07:41:32 -0700 (PDT) Received: from cpu185.redpinesignals.com ([203.196.161.90]) by smtp.gmail.com with ESMTPSA id i27sm1016460pfi.82.2017.07.06.07.41.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 07:41:31 -0700 (PDT) From: Amitkumar Karwar To: Kalle Valo Cc: linux-wireless@vger.kernel.org, Amitkumar Karwar , Prameela Rani Garnepudi Subject: [v3 01/21] rsi: use BUILD_BUG_ON check for fsm_state Date: Thu, 6 Jul 2017 20:07:04 +0530 Message-Id: <1499351844-2046-2-git-send-email-amitkarwar@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499351844-2046-1-git-send-email-amitkarwar@gmail.com> References: <1499351844-2046-1-git-send-email-amitkarwar@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Amitkumar Karwar 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 --- drivers/net/wireless/rsi/rsi_91x_debugfs.c | 2 ++ drivers/net/wireless/rsi/rsi_main.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_debugfs.c b/drivers/net/wireless/rsi/rsi_91x_debugfs.c index 4c0a493..f3b91b6 100644 --- a/drivers/net/wireless/rsi/rsi_91x_debugfs.c +++ b/drivers/net/wireless/rsi/rsi_91x_debugfs.c @@ -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]); diff --git a/drivers/net/wireless/rsi/rsi_main.h b/drivers/net/wireless/rsi/rsi_main.h index f398525..72675eb 100644 --- a/drivers/net/wireless/rsi/rsi_main.h +++ b/drivers/net/wireless/rsi/rsi_main.h @@ -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;