All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v1 01/11] mfd: intel_soc_pmic_bxtwc: Don't shadow error codes in show()/store()
Date: Mon, 27 Jun 2022 10:05:07 +0100	[thread overview]
Message-ID: <Yrlyw1eMFy4kd0JB@google.com> (raw)
In-Reply-To: <20220616165823.4919-1-andriy.shevchenko@linux.intel.com>

On Thu, 16 Jun 2022, Andy Shevchenko wrote:

> kstrtox() along with regmap API can return different error codes based on
> circumstances.
> 
> Don't shadow them when returning to the caller.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/mfd/intel_soc_pmic_bxtwc.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mfd/intel_soc_pmic_bxtwc.c b/drivers/mfd/intel_soc_pmic_bxtwc.c
> index bc069c4daa60..3148a319d467 100644
> --- a/drivers/mfd/intel_soc_pmic_bxtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
> @@ -339,10 +339,14 @@ static ssize_t addr_show(struct device *dev,
>  static ssize_t addr_store(struct device *dev,
>  			  struct device_attribute *attr, const char *buf, size_t count)
>  {
> -	if (kstrtoul(buf, 0, &bxtwc_reg_addr)) {
> +	int ret;
> +
> +	ret = kstrtoul(buf, 0, &bxtwc_reg_addr);
> +	if (ret) {
>  		dev_err(dev, "Invalid register address\n");

Is that really what failure means, on every failure?

  "Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing
   error."

> -		return -EINVAL;
> +		return ret;
>  	}
> +
>  	return (ssize_t)count;
>  }
>  
> @@ -354,9 +358,9 @@ static ssize_t val_show(struct device *dev,
>  	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
>  
>  	ret = regmap_read(pmic->regmap, bxtwc_reg_addr, &val);
> -	if (ret < 0) {
> +	if (ret) {
>  		dev_err(dev, "Failed to read 0x%lx\n", bxtwc_reg_addr);
> -		return -EIO;
> +		return ret;
>  	}
>  
>  	return sprintf(buf, "0x%02x\n", val);
> @@ -377,7 +381,7 @@ static ssize_t val_store(struct device *dev,
>  	if (ret) {
>  		dev_err(dev, "Failed to write value 0x%02x to address 0x%lx",
>  			val, bxtwc_reg_addr);
> -		return -EIO;
> +		return ret;
>  	}
>  	return count;
>  }

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

  parent reply	other threads:[~2022-06-27  9:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 16:58 [PATCH v1 01/11] mfd: intel_soc_pmic_bxtwc: Don't shadow error codes in show()/store() Andy Shevchenko
2022-06-16 16:58 ` [PATCH v1 02/11] mfd: intel_soc_pmic_bxtwc: Create sysfs attributes using core driver's facility Andy Shevchenko
2022-06-27  9:07   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 03/11] mfd: intel_soc_pmic_bxtwc: Convert to use platform_get/set_drvdata() Andy Shevchenko
2022-06-27  9:08   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 04/11] mfd: intel_soc_pmic_bxtwc: Use dev_err_probe() Andy Shevchenko
2022-06-27  9:22   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 05/11] mfd: intel_soc_pmic_bxtwc: Extend use of temporary variable for struct device Andy Shevchenko
2022-06-27  9:27   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 06/11] mfd: intel_soc_pmic_bxtwc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Andy Shevchenko
2022-06-27  9:27   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 07/11] mfd: intel_soc_pmic_bxtwc: Drop redundant ACPI_PTR() Andy Shevchenko
2022-06-27  9:28   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 08/11] mfd: intel_soc_pmic_bxtwc: Use bits.h macros for all masks Andy Shevchenko
2022-06-27  9:30   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 09/11] mfd: intel_soc_pmic_bxtwc: Use sysfs_emit() instead of sprintf() Andy Shevchenko
2022-06-27  9:30   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 10/11] mfd: intel_soc_pmic_bxtwc: Drop unneeded casting Andy Shevchenko
2022-06-27  9:31   ` Lee Jones
2022-06-16 16:58 ` [PATCH v1 11/11] mfd: intel_soc_pmic_bxtwc: Fix spelling in the comment Andy Shevchenko
2022-06-27  9:33   ` Lee Jones
2022-06-28  9:38     ` Andy Shevchenko
2022-06-28  9:56       ` Lee Jones
2022-06-28 10:36         ` Andy Shevchenko
2022-06-27  9:05 ` Lee Jones [this message]
2022-06-28  9:45   ` [PATCH v1 01/11] mfd: intel_soc_pmic_bxtwc: Don't shadow error codes in show()/store() Andy Shevchenko
2022-06-28  9:47     ` Lee Jones
2022-06-28 10:38       ` Andy Shevchenko
2022-06-29 14:34         ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yrlyw1eMFy4kd0JB@google.com \
    --to=lee.jones@linaro.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.