From d310aecfcc9545ba0abbfb5e2638497ae924b34d Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Mon, 26 Oct 2015 14:46:56 +0100 Subject: mwlwifi: avoid downloading firmware to non-responding device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bjørn Mork --- fwcmd.c | 11 +++++++---- fwcmd.h | 2 +- fwdl.c | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fwcmd.c b/fwcmd.c index 62ed88a..42eee94 100644 --- a/fwcmd.c +++ b/fwcmd.c @@ -661,13 +661,16 @@ static int mwl_fwcmd_encryption_set_cmd_info(struct hostcmd_cmd_set_key *cmd, return 0; } -void mwl_fwcmd_reset(struct ieee80211_hw *hw) +int mwl_fwcmd_reset(struct ieee80211_hw *hw) { struct mwl_priv *priv = hw->priv; - if (mwl_fwcmd_chk_adapter(priv)) - writel(ISR_RESET, - priv->iobase1 + MACREG_REG_H2A_INTERRUPT_EVENTS); + if (!mwl_fwcmd_chk_adapter(priv)) + return -ENODEV; + + writel(ISR_RESET, + priv->iobase1 + MACREG_REG_H2A_INTERRUPT_EVENTS); + return 0; } void mwl_fwcmd_int_enable(struct ieee80211_hw *hw) diff --git a/fwcmd.h b/fwcmd.h index 6775c98..3abd493 100644 --- a/fwcmd.h +++ b/fwcmd.h @@ -55,7 +55,7 @@ enum encr_type { ENCR_TYPE_MIX = 7, }; -void mwl_fwcmd_reset(struct ieee80211_hw *hw); +int mwl_fwcmd_reset(struct ieee80211_hw *hw); void mwl_fwcmd_int_enable(struct ieee80211_hw *hw); diff --git a/fwdl.c b/fwdl.c index 48c8c3e..f775caa 100644 --- a/fwdl.c +++ b/fwdl.c @@ -60,7 +60,9 @@ int mwl_fwdl_download_firmware(struct ieee80211_hw *hw) fw = priv->fw_ucode; - mwl_fwcmd_reset(hw); + /* if reset fails, then dl will most likely hang */ + if (mwl_fwcmd_reset(hw) < 0) + goto err_reset; /* FW before jumping to boot rom, it will enable PCIe transaction retry, * wait for boot code to stop it. @@ -178,5 +180,6 @@ err_download: mwl_fwcmd_reset(hw); +err_reset: return -EIO; } -- cgit v1.2.3