diff options
author | Azael Avalos <coproscefalo@gmail.com> | 2015-02-26 10:58:30 -0700 |
---|---|---|
committer | Darren Hart <dvhart@linux.intel.com> | 2015-05-11 10:38:22 -0700 |
commit | a882003714ec94a3108b47ea5c0cf2a6ec1f3e98 (patch) | |
tree | 8b54097b3110392916041ecb079002010f5dbc7d /drivers/platform | |
parent | 63ba3e28fd7302905052fc1b5fdcdd6bcd38a999 (diff) | |
download | op-kernel-dev-a882003714ec94a3108b47ea5c0cf2a6ec1f3e98.zip op-kernel-dev-a882003714ec94a3108b47ea5c0cf2a6ec1f3e98.tar.gz |
toshiba_haps: Replace sscanf with kstrtoint
This patch simply replaces the use of sscanf with kstrtoint returning
the error code in case that something went bad.
Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/toshiba_haps.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/platform/x86/toshiba_haps.c b/drivers/platform/x86/toshiba_haps.c index 65300b6..db6cc53 100644 --- a/drivers/platform/x86/toshiba_haps.c +++ b/drivers/platform/x86/toshiba_haps.c @@ -78,15 +78,20 @@ static ssize_t protection_level_store(struct device *dev, const char *buf, size_t count) { struct toshiba_haps_dev *haps = dev_get_drvdata(dev); - int level, ret; - - if (sscanf(buf, "%d", &level) != 1 || level < 0 || level > 3) - return -EINVAL; + int level; + int ret; - /* Set the sensor level. - * Acceptable levels are: + ret = kstrtoint(buf, 0, &level); + if (ret) + return ret; + /* + * Check for supported levels, which can be: * 0 - Disabled | 1 - Low | 2 - Medium | 3 - High */ + if (level < 0 || level > 3) + return -EINVAL; + + /* Set the sensor level */ ret = toshiba_haps_protection_level(haps->acpi_dev->handle, level); if (ret != 0) return ret; @@ -101,9 +106,14 @@ static ssize_t reset_protection_store(struct device *dev, const char *buf, size_t count) { struct toshiba_haps_dev *haps = dev_get_drvdata(dev); - int reset, ret; + int reset; + int ret; - if (sscanf(buf, "%d", &reset) != 1 || reset != 1) + ret = kstrtoint(buf, 0, &reset); + if (ret) + return ret; + /* The only accepted value is 1 */ + if (reset != 1) return -EINVAL; /* Reset the protection interface */ |