From a70cf8c3ee6449de11f86bc964483a9000857097 Mon Sep 17 00:00:00 2001 From: Wenzhuo Lu Date: Fri, 16 Oct 2015 10:50:55 +0800 Subject: [PATCH] e1000/base: check more NVM read errors Adding code to a case where e1000_nvn_read is called, but there is no consideration for when the read fails (returns an error code). Also, this patch adds an error message to a base NVM reading function that is missing it for consistency. This patch is not covering all cases of these conditions, it only covers the code used by the e1000e driver. Signed-off-by: Wenzhuo Lu --- drivers/net/e1000/base/e1000_82571.c | 6 +++++- drivers/net/e1000/base/e1000_manage.c | 5 ++++- drivers/net/e1000/base/e1000_nvm.c | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/e1000/base/e1000_82571.c b/drivers/net/e1000/base/e1000_82571.c index 5e0e43c9fc..7c279dbb3c 100644 --- a/drivers/net/e1000/base/e1000_82571.c +++ b/drivers/net/e1000/base/e1000_82571.c @@ -1452,10 +1452,14 @@ STATIC void e1000_clear_vfta_82571(struct e1000_hw *hw) STATIC bool e1000_check_mng_mode_82574(struct e1000_hw *hw) { u16 data; + s32 ret_val; DEBUGFUNC("e1000_check_mng_mode_82574"); - hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &data); + ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &data); + if (ret_val) + return false; + return (data & E1000_NVM_INIT_CTRL2_MNGM) != 0; } diff --git a/drivers/net/e1000/base/e1000_manage.c b/drivers/net/e1000/base/e1000_manage.c index ac4c08a382..8564a7f866 100644 --- a/drivers/net/e1000/base/e1000_manage.c +++ b/drivers/net/e1000/base/e1000_manage.c @@ -363,9 +363,12 @@ bool e1000_enable_mng_pass_thru(struct e1000_hw *hw) } else if ((hw->mac.type == e1000_82574) || (hw->mac.type == e1000_82583)) { u16 data; + s32 ret_val; factps = E1000_READ_REG(hw, E1000_FACTPS); - e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); + ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &data); + if (ret_val) + return false; if (!(factps & E1000_FACTPS_MNGCG) && ((data & E1000_NVM_INIT_CTRL2_MNGM) == diff --git a/drivers/net/e1000/base/e1000_nvm.c b/drivers/net/e1000/base/e1000_nvm.c index 966a34cc51..01be9e4de9 100644 --- a/drivers/net/e1000/base/e1000_nvm.c +++ b/drivers/net/e1000/base/e1000_nvm.c @@ -585,6 +585,9 @@ s32 e1000_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) E1000_NVM_RW_REG_DATA); } + if (ret_val) + DEBUGOUT1("NVM read error: %d\n", ret_val); + return ret_val; } -- 2.20.1