libertas: Use lbs_is_cmd_allowed() check in command handling routines.
lbs_is_cmd_allowed() check is added in __lbs_cmd_async() and
lbs_prepare_and_send_command(). The check is removed from other places.
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 3a3e894..0fb3125 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -75,6 +75,30 @@
}
/**
+ * @brief This function checks if the command is allowed.
+ *
+ * @param priv A pointer to lbs_private structure
+ * @return allowed or not allowed.
+ */
+
+static int lbs_is_cmd_allowed(struct lbs_private *priv)
+{
+ int ret = 1;
+
+ lbs_deb_enter(LBS_DEB_CMD);
+
+ if (!priv->is_auto_deep_sleep_enabled) {
+ if (priv->is_deep_sleep) {
+ lbs_deb_cmd("command not allowed in deep sleep\n");
+ ret = 0;
+ }
+ }
+
+ lbs_deb_leave(LBS_DEB_CMD);
+ return ret;
+}
+
+/**
* @brief Updates the hardware details like MAC address and regulatory region
*
* @param priv A pointer to struct lbs_private structure
@@ -1452,6 +1476,11 @@
goto done;
}
+ if (!lbs_is_cmd_allowed(priv)) {
+ ret = -EBUSY;
+ goto done;
+ }
+
cmdnode = lbs_get_cmd_ctrl_node(priv);
if (cmdnode == NULL) {
@@ -2104,6 +2133,11 @@
goto done;
}
+ if (!lbs_is_cmd_allowed(priv)) {
+ cmdnode = ERR_PTR(-EBUSY);
+ goto done;
+ }
+
cmdnode = lbs_get_cmd_ctrl_node(priv);
if (cmdnode == NULL) {
lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 8a7e9319..893a55c 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -117,11 +117,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out_unlock;
- }
-
buf_size = min(count, len - 1);
if (copy_from_user(buf, user_buf, buf_size)) {
ret = -EFAULT;
@@ -162,11 +157,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out_unlock;
- }
-
ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp);
if (ret)
goto out_unlock;
@@ -233,9 +223,6 @@
u8 freq;
int events = 0;
- if (!lbs_is_cmd_allowed(priv))
- return -EBUSY;
-
buf = (char *)get_zeroed_page(GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -288,9 +275,6 @@
char *buf;
int ret;
- if (!lbs_is_cmd_allowed(priv))
- return -EBUSY;
-
buf = (char *)get_zeroed_page(GFP_KERNEL);
if (!buf)
return -ENOMEM;
@@ -460,11 +444,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- free_page(addr);
- return -EBUSY;
- }
-
offval.offset = priv->mac_offset;
offval.value = 0;
@@ -517,11 +496,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- res = -EBUSY;
- goto out_unlock;
- }
-
buf_size = min(count, len - 1);
if (copy_from_user(buf, userbuf, buf_size)) {
res = -EFAULT;
@@ -558,11 +532,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- free_page(addr);
- return -EBUSY;
- }
-
offval.offset = priv->bbp_offset;
offval.value = 0;
@@ -616,11 +585,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- res = -EBUSY;
- goto out_unlock;
- }
-
buf_size = min(count, len - 1);
if (copy_from_user(buf, userbuf, buf_size)) {
res = -EFAULT;
@@ -657,11 +621,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- free_page(addr);
- return -EBUSY;
- }
-
offval.offset = priv->rf_offset;
offval.value = 0;
@@ -715,11 +674,6 @@
if (!buf)
return -ENOMEM;
- if (!lbs_is_cmd_allowed(priv)) {
- res = -EBUSY;
- goto out_unlock;
- }
-
buf_size = min(count, len - 1);
if (copy_from_user(buf, userbuf, buf_size)) {
res = -EFAULT;
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 44f0b24..fb91c36 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -34,7 +34,6 @@
void lbs_queue_event(struct lbs_private *priv, u32 event);
void lbs_notify_command_response(struct lbs_private *priv, u8 resp_idx);
int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep);
-int lbs_is_cmd_allowed(struct lbs_private *priv);
int lbs_enter_auto_deep_sleep(struct lbs_private *priv);
int lbs_exit_auto_deep_sleep(struct lbs_private *priv);
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index e468e15..6c95af3 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -950,11 +950,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
if (!priv->radio_on) {
ret = -EINVAL;
goto out;
@@ -1022,12 +1017,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- err = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", err);
- return err;
- }
-
/* iwlist should wait until the current scan is finished */
if (priv->scan_channel)
return -EAGAIN;
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 38a451e..69dd19b 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -46,32 +46,6 @@
}
/**
- * @brief This function checks if the command is allowed.
- *
- * @param priv A pointer to lbs_private structure
- * @return allowed or not allowed.
- */
-
-int lbs_is_cmd_allowed(struct lbs_private *priv)
-{
- int ret = 1;
-
- lbs_deb_enter(LBS_DEB_WEXT);
-
- if (!priv->is_auto_deep_sleep_enabled) {
- if (priv->is_deep_sleep) {
- lbs_deb_wext("IOCTLS called when station"
- "is in deep sleep\n");
- ret = 0;
- }
- }
-
- lbs_deb_leave(LBS_DEB_WEXT);
- return ret;
-}
-
-
-/**
* @brief Find the channel frequency power info with specific channel
*
* @param priv A pointer to struct lbs_private structure
@@ -193,11 +167,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- lbs_deb_leave(LBS_DEB_WEXT);
- return -EBUSY;
- }
-
cfp = lbs_find_cfp_by_band_and_channel(priv, 0,
priv->curbssparams.channel);
@@ -308,12 +277,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
if (vwrq->disabled)
val = MRVDRV_RTS_MAX_VALUE;
@@ -335,11 +298,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_RTS_THRESHOLD, &val);
if (ret)
goto out;
@@ -362,12 +320,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
if (vwrq->disabled)
val = MRVDRV_FRAG_MAX_VALUE;
@@ -389,11 +341,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
ret = lbs_get_snmp_mib(priv, SNMP_MIB_OID_FRAG_THRESHOLD, &val);
if (ret)
goto out;
@@ -443,11 +390,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
if (!priv->radio_on) {
lbs_deb_wext("tx power off\n");
vwrq->value = 0;
@@ -481,11 +423,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
if ((vwrq->flags & IW_RETRY_TYPE) != IW_RETRY_LIMIT)
return -EOPNOTSUPP;
@@ -534,11 +471,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
vwrq->disabled = 0;
if (vwrq->flags & IW_RETRY_LONG) {
@@ -907,9 +839,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv))
- return NULL;
-
priv->wstats.status = priv->mode;
/* If we're not associated, all quality values are meaningless */
@@ -1010,12 +939,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
mutex_lock(&priv->lock);
assoc_req = lbs_get_association_request(priv);
if (!assoc_req) {
@@ -1125,11 +1048,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
lbs_deb_wext("vwrq->value %d\n", vwrq->value);
lbs_deb_wext("vwrq->fixed %d\n", vwrq->fixed);
@@ -1188,11 +1106,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- lbs_deb_leave(LBS_DEB_WEXT);
- return -EBUSY;
- }
-
if (priv->connect_status == LBS_CONNECTED) {
vwrq->value = priv->cur_rate * 500000;
@@ -1219,11 +1132,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
if ( (*uwrq != IW_MODE_ADHOC)
&& (*uwrq != IW_MODE_INFRA)
&& (*uwrq != IW_MODE_AUTO)) {
@@ -1465,12 +1373,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
mutex_lock(&priv->lock);
assoc_req = lbs_get_association_request(priv);
if (!assoc_req) {
@@ -1654,12 +1556,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
mutex_lock(&priv->lock);
assoc_req = lbs_get_association_request(priv);
if (!assoc_req) {
@@ -1872,12 +1768,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
mutex_lock(&priv->lock);
assoc_req = lbs_get_association_request(priv);
if (!assoc_req) {
@@ -1980,12 +1870,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
switch (dwrq->flags & IW_AUTH_INDEX) {
case IW_AUTH_KEY_MGMT:
dwrq->value = priv->secinfo.key_mgmt;
@@ -2028,11 +1912,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- goto out;
- }
-
if (vwrq->disabled) {
lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
goto out;
@@ -2152,12 +2031,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
if (!priv->radio_on) {
ret = -EINVAL;
goto out;
@@ -2285,12 +2158,6 @@
lbs_deb_enter(LBS_DEB_WEXT);
- if (!lbs_is_cmd_allowed(priv)) {
- ret = -EBUSY;
- lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
- return ret;
- }
-
if (!priv->radio_on)
return -EINVAL;