+-static void ath9k_init_crypto(struct ath9k_htc_priv *priv)
+-{
+- struct ath_common *common = ath9k_hw_common(priv->ah);
+- int i = 0;
+-
+- /* Get the hardware key cache size. */
+- common->keymax = AR_KEYTABLE_SIZE;
+-
+- if (priv->ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA)
+- common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
+-
+- /*
+- * Reset the key cache since some parts do not
+- * reset the contents on initial power up.
+- */
+- for (i = 0; i < common->keymax; i++)
+- ath_hw_keyreset(common, (u16) i);
+-}
+-
+ static void ath9k_init_channels_rates(struct ath9k_htc_priv *priv)
+ {
+ if (priv->ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
+@@ -720,7 +701,7 @@ static int ath9k_init_priv(struct ath9k_
+ for (i = 0; i < ATH9K_HTC_MAX_BCN_VIF; i++)
+ priv->cur_beacon_conf.bslot[i] = NULL;
+
+- ath9k_init_crypto(priv);
++ ath9k_cmn_init_crypto(ah);
+ ath9k_init_channels_rates(priv);
+ ath9k_init_misc(priv);
+
+--- a/drivers/net/wireless/ath/ath9k/init.c
++++ b/drivers/net/wireless/ath/ath9k/init.c
+@@ -404,31 +404,6 @@ fail:
+ return error;
+ }
+
+-void ath9k_init_crypto(struct ath_softc *sc)
+-{
+- struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+- int i = 0;
+-
+- /* Get the hardware key cache size. */
+- common->keymax = AR_KEYTABLE_SIZE;
+-
+- /*
+- * Reset the key cache since some parts do not
+- * reset the contents on initial power up.
+- */
+- for (i = 0; i < common->keymax; i++)
+- ath_hw_keyreset(common, (u16) i);
+-
+- /*
+- * Check whether the separate key cache entries
+- * are required to handle both tx+rx MIC keys.
+- * With split mic keys the number of stations is limited
+- * to 27 otherwise 59.
+- */
+- if (sc->sc_ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA)
+- common->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;
+-}
+-
+ static int ath9k_init_btcoex(struct ath_softc *sc)
+ {
+ struct ath_txq *txq;
+@@ -630,7 +605,7 @@ static int ath9k_init_softc(u16 devid, s
+ if (ret)
+ goto err_btcoex;
+
+- ath9k_init_crypto(sc);
++ ath9k_cmn_init_crypto(sc->sc_ah);
+ ath9k_init_misc(sc);
+
+ return 0;
+--- a/drivers/net/wireless/ath/ath9k/pci.c
++++ b/drivers/net/wireless/ath/ath9k/pci.c
+@@ -129,7 +129,7 @@ static void ath_pci_aspm_init(struct ath
+ return;
+
+ parent = pdev->bus->self;
+- if (WARN_ON(!parent))
++ if (!parent)
+ return;
+
+ pos = pci_pcie_cap(parent);
+@@ -338,7 +338,7 @@ static int ath_pci_resume(struct device
+ * semi-random values after suspend/resume.
+ */
+ ath9k_ps_wakeup(sc);
+- ath9k_init_crypto(sc);
++ ath9k_cmn_init_crypto(sc->sc_ah);
+ ath9k_ps_restore(sc);
+
+ sc->ps_idle = true;
+--- a/drivers/net/wireless/ath/ath9k/calib.c
++++ b/drivers/net/wireless/ath/ath9k/calib.c
+@@ -82,7 +82,6 @@ static void ath9k_hw_update_nfcal_hist_b
+ int16_t *nfarray)
+ {
+ struct ath_common *common = ath9k_hw_common(ah);
+- struct ieee80211_conf *conf = &common->hw->conf;
+ struct ath_nf_limits *limit;
+ struct ath9k_nfcal_hist *h;
+ bool high_nf_mid = false;
+@@ -94,7 +93,7 @@ static void ath9k_hw_update_nfcal_hist_b
+
+ for (i = 0; i < NUM_NF_READINGS; i++) {
+ if (!(chainmask & (1 << i)) ||
+- ((i >= AR5416_MAX_CHAINS) && !conf_is_ht40(conf)))
++ ((i >= AR5416_MAX_CHAINS) && !IS_CHAN_HT40(ah->curchan)))
+ continue;
+
+ h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -1163,6 +1163,59 @@ static const struct file_operations fops
+ .llseek = default_llseek,/* read accesses f_pos */
+ };
+
++static ssize_t read_file_dump_nfcal(struct file *file, char __user *user_buf,
++ size_t count, loff_t *ppos)
++{
++ struct ath_softc *sc = file->private_data;
++ struct ath_hw *ah = sc->sc_ah;
++ struct ath9k_nfcal_hist *h = sc->caldata.nfCalHist;
++ struct ath_common *common = ath9k_hw_common(ah);
++ struct ieee80211_conf *conf = &common->hw->conf;
++ u32 len = 0, size = 1500;
++ u32 i, j;
++ ssize_t retval = 0;
++ char *buf;
++ u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
++ u8 nread;