diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-05-15 16:22:37 +0300 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-05-30 17:43:31 +0300 |
commit | 7640cd0b123f999f7845759dd2f78469bfe05b97 (patch) | |
tree | 770afb86e7ae1b07ad524d201fac7aaab3d75a63 /drivers/platform | |
parent | c0f61c51b78a68dbf06bf639f2f3164c13b28d98 (diff) | |
download | linux-7640cd0b123f999f7845759dd2f78469bfe05b97.tar.bz2 |
platform/x86: hp-wmi: Refactor postcode_store() to follow standard patterns
Refactor postcode_store() to follow standard patterns of error handling.
While at it, switch to use kstrtobool().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/hp-wmi.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index a881b709af25..3487c80c4b5d 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -473,22 +473,20 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr, static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - long unsigned int tmp2; + u32 tmp = 1; + bool clear; int ret; - u32 tmp; - ret = kstrtoul(buf, 10, &tmp2); - if (!ret && tmp2 != 1) - ret = -EINVAL; + ret = kstrtobool(buf, &clear); if (ret) - goto out; + return ret; + + if (clear == false) + return -EINVAL; /* Clear the POST error code. It is kept until until cleared. */ - tmp = (u32) tmp2; ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, HPWMI_WRITE, &tmp, sizeof(tmp), sizeof(tmp)); - -out: if (ret) return ret < 0 ? ret : -EINVAL; |