提交 aab6930d 编写于 作者: J Johannes Berg 提交者: Luca Coelho

iwlwifi: mvm: add and use iwl_mvm_device_running()

This will help refactor this later.
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
上级 86bbb1e1
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
* Copyright(c) 2016 Intel Deutschland GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as * it under the terms of version 2 of the GNU General Public License as
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
* *
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -82,7 +83,8 @@ static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file, ...@@ -82,7 +83,8 @@ static ssize_t iwl_dbgfs_ctdp_budget_read(struct file *file,
char buf[16]; char buf[16];
int pos, budget; int pos, budget;
if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR)
return -EIO; return -EIO;
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
...@@ -102,7 +104,8 @@ static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf, ...@@ -102,7 +104,8 @@ static ssize_t iwl_dbgfs_stop_ctdp_write(struct iwl_mvm *mvm, char *buf,
{ {
int ret; int ret;
if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR)
return -EIO; return -EIO;
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
...@@ -118,7 +121,8 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf, ...@@ -118,7 +121,8 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
int ret; int ret;
u32 scd_q_msk; u32 scd_q_msk;
if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR)
return -EIO; return -EIO;
if (sscanf(buf, "%x", &scd_q_msk) != 1) if (sscanf(buf, "%x", &scd_q_msk) != 1)
...@@ -139,7 +143,8 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf, ...@@ -139,7 +143,8 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
struct iwl_mvm_sta *mvmsta; struct iwl_mvm_sta *mvmsta;
int sta_id, drain, ret; int sta_id, drain, ret;
if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR)
return -EIO; return -EIO;
if (sscanf(buf, "%d %d", &sta_id, &drain) != 2) if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
...@@ -172,7 +177,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf, ...@@ -172,7 +177,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, char __user *user_buf,
size_t ret; size_t ret;
u8 *ptr; u8 *ptr;
if (!mvm->ucode_loaded) if (!iwl_mvm_firmware_running(mvm))
return -EINVAL; return -EINVAL;
/* default is to dump the entire data segment */ /* default is to dump the entire data segment */
...@@ -205,7 +210,7 @@ static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf, ...@@ -205,7 +210,7 @@ static ssize_t iwl_dbgfs_sram_write(struct iwl_mvm *mvm, char *buf,
u32 offset, len; u32 offset, len;
u32 img_offset, img_len; u32 img_offset, img_len;
if (!mvm->ucode_loaded) if (!iwl_mvm_firmware_running(mvm))
return -EINVAL; return -EINVAL;
img = &mvm->fw->img[mvm->cur_ucode]; img = &mvm->fw->img[mvm->cur_ucode];
...@@ -258,7 +263,7 @@ static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm, ...@@ -258,7 +263,7 @@ static ssize_t iwl_dbgfs_set_nic_temperature_write(struct iwl_mvm *mvm,
{ {
int temperature; int temperature;
if (!mvm->ucode_loaded && !mvm->temperature_test) if (!iwl_mvm_firmware_running(mvm) && !mvm->temperature_test)
return -EIO; return -EIO;
if (kstrtoint(buf, 10, &temperature)) if (kstrtoint(buf, 10, &temperature))
...@@ -305,7 +310,7 @@ static ssize_t iwl_dbgfs_nic_temp_read(struct file *file, ...@@ -305,7 +310,7 @@ static ssize_t iwl_dbgfs_nic_temp_read(struct file *file,
int pos, ret; int pos, ret;
s32 temp; s32 temp;
if (!mvm->ucode_loaded) if (!iwl_mvm_firmware_running(mvm))
return -EIO; return -EIO;
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
...@@ -371,7 +376,7 @@ static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf, ...@@ -371,7 +376,7 @@ static ssize_t iwl_dbgfs_disable_power_off_write(struct iwl_mvm *mvm, char *buf,
{ {
int ret, val; int ret, val;
if (!mvm->ucode_loaded) if (!iwl_mvm_firmware_running(mvm))
return -EIO; return -EIO;
if (!strncmp("disable_power_off_d0=", buf, 21)) { if (!strncmp("disable_power_off_d0=", buf, 21)) {
......
...@@ -4028,7 +4028,7 @@ static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx, ...@@ -4028,7 +4028,7 @@ static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
if (mvm->ucode_loaded) { if (iwl_mvm_firmware_running(mvm)) {
ret = iwl_mvm_request_statistics(mvm, false); ret = iwl_mvm_request_statistics(mvm, false);
if (ret) if (ret)
goto out; goto out;
......
...@@ -1109,6 +1109,11 @@ static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm) ...@@ -1109,6 +1109,11 @@ static inline bool iwl_mvm_is_radio_hw_killed(struct iwl_mvm *mvm)
return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status); return test_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
} }
static inline bool iwl_mvm_firmware_running(struct iwl_mvm *mvm)
{
return mvm->ucode_loaded;
}
/* Must be called with rcu_read_lock() held and it can only be /* Must be called with rcu_read_lock() held and it can only be
* released when mvmsta is not needed anymore. * released when mvmsta is not needed anymore.
*/ */
......
...@@ -628,7 +628,8 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, ...@@ -628,7 +628,8 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) { if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR) {
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
...@@ -678,7 +679,8 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, ...@@ -678,7 +679,8 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) { if (!iwl_mvm_firmware_running(mvm) ||
mvm->cur_ucode != IWL_UCODE_REGULAR) {
ret = -EIO; ret = -EIO;
goto out; goto out;
} }
...@@ -790,8 +792,11 @@ static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev, ...@@ -790,8 +792,11 @@ static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev,
struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata);
int ret; int ret;
if (!mvm->ucode_loaded || !(mvm->cur_ucode == IWL_UCODE_REGULAR)) if (!iwl_mvm_firmware_running(mvm) ||
return -EIO; mvm->cur_ucode != IWL_UCODE_REGULAR) {
ret = -EIO;
goto unlock;
}
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册