Skip to content

Commit 7640cd0

Browse files
committed
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 <[email protected]>
1 parent c0f61c5 commit 7640cd0

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/platform/x86/hp-wmi.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -473,22 +473,20 @@ static ssize_t als_store(struct device *dev, struct device_attribute *attr,
473473
static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,
474474
const char *buf, size_t count)
475475
{
476-
long unsigned int tmp2;
476+
u32 tmp = 1;
477+
bool clear;
477478
int ret;
478-
u32 tmp;
479479

480-
ret = kstrtoul(buf, 10, &tmp2);
481-
if (!ret && tmp2 != 1)
482-
ret = -EINVAL;
480+
ret = kstrtobool(buf, &clear);
483481
if (ret)
484-
goto out;
482+
return ret;
483+
484+
if (clear == false)
485+
return -EINVAL;
485486

486487
/* Clear the POST error code. It is kept until until cleared. */
487-
tmp = (u32) tmp2;
488488
ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, HPWMI_WRITE, &tmp,
489489
sizeof(tmp), sizeof(tmp));
490-
491-
out:
492490
if (ret)
493491
return ret < 0 ? ret : -EINVAL;
494492

0 commit comments

Comments
 (0)