iwlwifi: reduce debug ifdefs using the optimiser
authorJohannes Berg <johannes.berg@intel.com>
Wed, 12 Jun 2013 07:56:51 +0000 (09:56 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 13 Jun 2013 10:05:50 +0000 (12:05 +0200)
Instead of using #ifdef CONFIG_IWLWIFI_DEBUG, remove the
iwlwifi_mod_params.debug_level variable completely and
make iwl_have_debug_level() always return false in the
non-debug case. This way, the optimiser will elide all
code for it automatically without having to add #ifdefs.

Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/iwlwifi/dvm/main.c
drivers/net/wireless/iwlwifi/iwl-debug.h
drivers/net/wireless/iwlwifi/iwl-modparams.h
drivers/net/wireless/iwlwifi/pcie/rx.c

index 68f75465957008ee133d470cfe5354ade4a62e68..7aa9c8dc33ef6a51a7a64f60fa8c76130690393a 100644 (file)
@@ -1859,14 +1859,9 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
                return pos;
        }
 
-#ifdef CONFIG_IWLWIFI_DEBUG
        if (!(iwl_have_debug_level(IWL_DL_FW_ERRORS)) && !full_log)
                size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
                        ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
-#else
-       size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
-               ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
-#endif
        IWL_ERR(priv, "Start IWL Event Log Dump: display last %u entries\n",
                size);
 
@@ -1910,10 +1905,8 @@ static void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
        unsigned int reload_msec;
        unsigned long reload_jiffies;
 
-#ifdef CONFIG_IWLWIFI_DEBUG
        if (iwl_have_debug_level(IWL_DL_FW_ERRORS))
                iwl_print_rx_config_cmd(priv, IWL_RXON_CTX_BSS);
-#endif
 
        /* uCode is no longer loaded. */
        priv->ucode_loaded = false;
index 8cf5db7fb5c9ce309349add2dd2222df3c75ebe2..7edb8519c8a49eadc3f5798fa8fa08bfbd25fe04 100644 (file)
 
 static inline bool iwl_have_debug_level(u32 level)
 {
+#ifdef CONFIG_IWLWIFI_DEBUG
        return iwlwifi_mod_params.debug_level & level;
+#else
+       return false;
+#endif
 }
 
 void __iwl_err(struct device *dev, bool rfkill_prefix, bool only_trace,
index 36dfe0919f6b72c03b0e4b480075363c9ac9beca..d4ad505b0a4bb9668cdc2d788f46986194d592ef 100644 (file)
@@ -115,7 +115,9 @@ struct iwl_mod_params {
        int led_mode;
        bool power_save;
        int power_level;
+#ifdef CONFIG_IWLWIFI_DEBUG
        u32 debug_level;
+#endif
        int ant_coupling;
        bool bt_ch_announce;
        bool auto_agg;
index 63ba21e51f8dfcc26409e394b33facd701b17673..3688dc5ba1aca0fb8f1bc4b90af285ff623fa553 100644 (file)
@@ -802,9 +802,6 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
        u32 handled = 0;
        unsigned long flags;
        u32 i;
-#ifdef CONFIG_IWLWIFI_DEBUG
-       u32 inta_mask;
-#endif
 
        lock_map_acquire(&trans->sync_cmd_lockdep_map);
 
@@ -826,14 +823,9 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
 
        inta = trans_pcie->inta;
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_have_debug_level(IWL_DL_ISR)) {
-               /* just for debug */
-               inta_mask = iwl_read32(trans, CSR_INT_MASK);
+       if (iwl_have_debug_level(IWL_DL_ISR))
                IWL_DEBUG_ISR(trans, "inta 0x%08x, enabled 0x%08x\n",
-                             inta, inta_mask);
-       }
-#endif
+                             inta, iwl_read32(trans, CSR_INT_MASK));
 
        /* saved interrupt in inta variable now we can reset trans_pcie->inta */
        trans_pcie->inta = 0;
@@ -855,12 +847,11 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
                goto out;
        }
 
-#ifdef CONFIG_IWLWIFI_DEBUG
        if (iwl_have_debug_level(IWL_DL_ISR)) {
                /* NIC fires this, but we don't use it, redundant with WAKEUP */
                if (inta & CSR_INT_BIT_SCD) {
-                       IWL_DEBUG_ISR(trans, "Scheduler finished to transmit "
-                                     "the frame/frames.\n");
+                       IWL_DEBUG_ISR(trans,
+                                     "Scheduler finished to transmit the frame/frames.\n");
                        isr_stats->sch++;
                }
 
@@ -870,7 +861,7 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
                        isr_stats->alive++;
                }
        }
-#endif
+
        /* Safely ignore these bits for debug checks below */
        inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE);
 
@@ -1118,9 +1109,6 @@ static irqreturn_t iwl_pcie_isr(int irq, void *data)
        struct iwl_trans *trans = data;
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
        u32 inta, inta_mask;
-#ifdef CONFIG_IWLWIFI_DEBUG
-       u32 inta_fh;
-#endif
 
        lockdep_assert_held(&trans_pcie->irq_lock);
 
@@ -1159,13 +1147,11 @@ static irqreturn_t iwl_pcie_isr(int irq, void *data)
                return IRQ_HANDLED;
        }
 
-#ifdef CONFIG_IWLWIFI_DEBUG
-       if (iwl_have_debug_level(IWL_DL_ISR)) {
-               inta_fh = iwl_read32(trans, CSR_FH_INT_STATUS);
-               IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled 0x%08x, "
-                             "fh 0x%08x\n", inta, inta_mask, inta_fh);
-       }
-#endif
+       if (iwl_have_debug_level(IWL_DL_ISR))
+               IWL_DEBUG_ISR(trans,
+                             "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
+                             inta, inta_mask,
+                             iwl_read32(trans, CSR_FH_INT_STATUS));
 
        trans_pcie->inta |= inta;
        /* the thread will service interrupts and re-enable them */
@@ -1272,11 +1258,9 @@ irqreturn_t iwl_pcie_isr_ict(int irq, void *data)
        inta = (0xff & val) | ((0xff00 & val) << 16);
        IWL_DEBUG_ISR(trans, "ISR inta 0x%08x, enabled(sw) 0x%08x ict 0x%08x\n",
                      inta, trans_pcie->inta_mask, val);
-#ifdef CONFIG_IWLWIFI_DEBUG
        if (iwl_have_debug_level(IWL_DL_ISR))
                IWL_DEBUG_ISR(trans, "enabled(hw) 0x%08x\n",
                              iwl_read32(trans, CSR_INT_MASK));
-#endif
 
        inta &= trans_pcie->inta_mask;
        trans_pcie->inta |= inta;