Skip to content

Commit

Permalink
iwlwifi: use strict_strtoul instead of simple_strtoul
Browse files Browse the repository at this point in the history
This patch makes use of strict_srtoul in sysfs code.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Tomas Winkler authored and John W. Linville committed Sep 8, 2008
1 parent 8f4807a commit 9257746
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3619,11 +3619,11 @@ static ssize_t store_debug_level(struct device *d,
const char *buf, size_t count)
{
struct iwl_priv *priv = d->driver_data;
char *p = (char *)buf;
u32 val;
unsigned long val;
int ret;

val = simple_strtoul(p, &p, 0);
if (p == buf)
ret = strict_strtoul(buf, 0, &val);
if (ret)
printk(KERN_INFO DRV_NAME
": %s is not in hex or decimal form.\n", buf);
else
Expand Down Expand Up @@ -3695,11 +3695,11 @@ static ssize_t store_tx_power(struct device *d,
const char *buf, size_t count)
{
struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
char *p = (char *)buf;
u32 val;
unsigned long val;
int ret;

val = simple_strtoul(p, &p, 10);
if (p == buf)
ret = strict_strtoul(buf, 10, &val);
if (ret)
printk(KERN_INFO DRV_NAME
": %s is not in decimal form.\n", buf);
else
Expand All @@ -3723,16 +3723,20 @@ static ssize_t store_flags(struct device *d,
const char *buf, size_t count)
{
struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
u32 flags = simple_strtoul(buf, NULL, 0);
unsigned long val;
u32 flags;
int ret = strict_strtoul(buf, 0, &val);
if (!ret)
return ret;
flags = (u32)val;

mutex_lock(&priv->mutex);
if (le32_to_cpu(priv->staging_rxon.flags) != flags) {
/* Cancel any currently running scans... */
if (iwl_scan_cancel_timeout(priv, 100))
IWL_WARNING("Could not cancel scan.\n");
else {
IWL_DEBUG_INFO("Committing rxon.flags = 0x%04X\n",
flags);
IWL_DEBUG_INFO("Commit rxon.flags = 0x%04X\n", flags);
priv->staging_rxon.flags = cpu_to_le32(flags);
iwl4965_commit_rxon(priv);
}
Expand All @@ -3758,7 +3762,12 @@ static ssize_t store_filter_flags(struct device *d,
const char *buf, size_t count)
{
struct iwl_priv *priv = (struct iwl_priv *)d->driver_data;
u32 filter_flags = simple_strtoul(buf, NULL, 0);
unsigned long val;
u32 filter_flags;
int ret = strict_strtoul(buf, 0, &val);
if (!ret)
return ret;
filter_flags = (u32)val;

mutex_lock(&priv->mutex);
if (le32_to_cpu(priv->staging_rxon.filter_flags) != filter_flags) {
Expand Down Expand Up @@ -3859,10 +3868,12 @@ static ssize_t store_retry_rate(struct device *d,
const char *buf, size_t count)
{
struct iwl_priv *priv = dev_get_drvdata(d);
long val;
int ret = strict_strtol(buf, 10, &val);
if (!ret)
return ret;

priv->retry_rate = simple_strtoul(buf, NULL, 0);
if (priv->retry_rate <= 0)
priv->retry_rate = 1;
priv->retry_rate = (val > 0) ? val : 1;

return count;
}
Expand All @@ -3883,16 +3894,20 @@ static ssize_t store_power_level(struct device *d,
{
struct iwl_priv *priv = dev_get_drvdata(d);
int ret;
int mode;
unsigned long mode;


mode = simple_strtoul(buf, NULL, 0);
mutex_lock(&priv->mutex);

if (!iwl_is_ready(priv)) {
ret = -EAGAIN;
goto out;
}

ret = strict_strtoul(buf, 10, &mode);
if (!ret)
goto out;

ret = iwl_power_set_user_mode(priv, mode);
if (ret) {
IWL_DEBUG_MAC80211("failed setting power mode.\n");
Expand Down

0 comments on commit 9257746

Please sign in to comment.