Skip to content

Commit 5189952

Browse files
andy-shevlag-linaro
authored andcommitted
mfd: intel_soc_pmic_bxtwc: Don't shadow error codes in show()/store()
kstrtox() along with regmap API can return different error codes based on circumstances. Don't shadow them when returning to the caller. While at it, remove rather confusing message from addr_store(). Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 37e8ba7 commit 5189952

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/mfd/intel_soc_pmic_bxtwc.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@ static ssize_t addr_show(struct device *dev,
339339
static ssize_t addr_store(struct device *dev,
340340
struct device_attribute *attr, const char *buf, size_t count)
341341
{
342-
if (kstrtoul(buf, 0, &bxtwc_reg_addr)) {
343-
dev_err(dev, "Invalid register address\n");
344-
return -EINVAL;
345-
}
342+
int ret;
343+
344+
ret = kstrtoul(buf, 0, &bxtwc_reg_addr);
345+
if (ret)
346+
return ret;
347+
346348
return (ssize_t)count;
347349
}
348350

@@ -354,9 +356,9 @@ static ssize_t val_show(struct device *dev,
354356
struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
355357

356358
ret = regmap_read(pmic->regmap, bxtwc_reg_addr, &val);
357-
if (ret < 0) {
359+
if (ret) {
358360
dev_err(dev, "Failed to read 0x%lx\n", bxtwc_reg_addr);
359-
return -EIO;
361+
return ret;
360362
}
361363

362364
return sprintf(buf, "0x%02x\n", val);
@@ -377,7 +379,7 @@ static ssize_t val_store(struct device *dev,
377379
if (ret) {
378380
dev_err(dev, "Failed to write value 0x%02x to address 0x%lx",
379381
val, bxtwc_reg_addr);
380-
return -EIO;
382+
return ret;
381383
}
382384
return count;
383385
}

0 commit comments

Comments
 (0)