]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
platform/x86: hp-wmi: Refactor postcode_store() to follow standard patterns
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 15 May 2020 13:22:37 +0000 (16:22 +0300)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Sat, 30 May 2020 14:43:31 +0000 (17:43 +0300)
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>
drivers/platform/x86/hp-wmi.c

index a881b709af25633274690daea073b13cdc61609c..3487c80c4b5de6c1e2ce1b20207c0cef7b7d1983 100644 (file)
@@ -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;