diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2019-08-16 12:46:25 +0300 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2019-08-16 12:50:12 +0300 |
commit | 84d8e80b0a3612aad746837e95d8efe324fdc5c6 (patch) | |
tree | f8245b33eef3d191c153ae13ca7e2b6214eea03d /drivers/platform/x86/asus-wmi.c | |
parent | d507a54f5865d8dcbdd16c66a1a2da15640878ca (diff) |
platform/x86: asus-wmi: Refactor charge_threshold_store()
There are few issues with the current code:
- the error code from kstrtouint() is shadowed
- the error code from asus_wmi_set_devstate() is ignored
- the extra check against 0 for count (this is guaranteed by sysfs)
Fix these issues by doing a slight refactoring of charge_threshold_store().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86/asus-wmi.c')
-rw-r--r-- | drivers/platform/x86/asus-wmi.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 22ae350e0a96..1a76d878852f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -2086,13 +2086,15 @@ static ssize_t charge_threshold_store(struct device *dev, int value, ret, rv; ret = kstrtouint(buf, 10, &value); + if (ret) + return ret; - if (!count || ret != 0) - return -EINVAL; if (value < 0 || value > 100) return -EINVAL; - asus_wmi_set_devstate(ASUS_WMI_CHARGE_THRESHOLD, value, &rv); + ret = asus_wmi_set_devstate(ASUS_WMI_CHARGE_THRESHOLD, value, &rv); + if (!ret) + return ret; if (rv != 1) return -EIO; |