Skip to content

Commit

Permalink
libertas: Use lbs_is_cmd_allowed() check in command handling routines.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Amitkumar Karwar authored and John W. Linville committed Oct 7, 2009
1 parent 536b3a7 commit 63f275d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 191 deletions.
34 changes: 34 additions & 0 deletions drivers/net/wireless/libertas/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ static u8 is_command_allowed_in_ps(u16 cmd)
return 0;
}

/**
* @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
*
Expand Down Expand Up @@ -1452,6 +1476,11 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
goto done;
}

if (!lbs_is_cmd_allowed(priv)) {
ret = -EBUSY;
goto done;
}

cmdnode = lbs_get_cmd_ctrl_node(priv);

if (cmdnode == NULL) {
Expand Down Expand Up @@ -2104,6 +2133,11 @@ static struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
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");
Expand Down
46 changes: 0 additions & 46 deletions drivers/net/wireless/libertas/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ static ssize_t lbs_sleepparams_write(struct file *file,
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;
Expand Down Expand Up @@ -162,11 +157,6 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
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;
Expand Down Expand Up @@ -233,9 +223,6 @@ static ssize_t lbs_threshold_read(uint16_t tlv_type, uint16_t event_mask,
u8 freq;
int events = 0;

if (!lbs_is_cmd_allowed(priv))
return -EBUSY;

buf = (char *)get_zeroed_page(GFP_KERNEL);
if (!buf)
return -ENOMEM;
Expand Down Expand Up @@ -288,9 +275,6 @@ static ssize_t lbs_threshold_write(uint16_t tlv_type, uint16_t event_mask,
char *buf;
int ret;

if (!lbs_is_cmd_allowed(priv))
return -EBUSY;

buf = (char *)get_zeroed_page(GFP_KERNEL);
if (!buf)
return -ENOMEM;
Expand Down Expand Up @@ -460,11 +444,6 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
if (!buf)
return -ENOMEM;

if (!lbs_is_cmd_allowed(priv)) {
free_page(addr);
return -EBUSY;
}

offval.offset = priv->mac_offset;
offval.value = 0;

Expand Down Expand Up @@ -517,11 +496,6 @@ static ssize_t lbs_wrmac_write(struct file *file,
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;
Expand Down Expand Up @@ -558,11 +532,6 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
if (!buf)
return -ENOMEM;

if (!lbs_is_cmd_allowed(priv)) {
free_page(addr);
return -EBUSY;
}

offval.offset = priv->bbp_offset;
offval.value = 0;

Expand Down Expand Up @@ -616,11 +585,6 @@ static ssize_t lbs_wrbbp_write(struct file *file,
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;
Expand Down Expand Up @@ -657,11 +621,6 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
if (!buf)
return -ENOMEM;

if (!lbs_is_cmd_allowed(priv)) {
free_page(addr);
return -EBUSY;
}

offval.offset = priv->rf_offset;
offval.value = 0;

Expand Down Expand Up @@ -715,11 +674,6 @@ static ssize_t lbs_wrrf_write(struct file *file,
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;
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wireless/libertas/decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ int lbs_process_event(struct lbs_private *priv, u32 event);
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);

Expand Down
11 changes: 0 additions & 11 deletions drivers/net/wireless/libertas/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,6 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,

lbs_deb_enter(LBS_DEB_WEXT);

if (!lbs_is_cmd_allowed(priv)) {
ret = -EBUSY;
goto out;
}

if (!priv->radio_on) {
ret = -EINVAL;
goto out;
Expand Down Expand Up @@ -1022,12 +1017,6 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,

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;
Expand Down
Loading

0 comments on commit 63f275d

Please sign in to comment.