All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qiao Zhou <zhouqiao@marvell.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: SamuelOrtiz <sameo@linux.intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mfd: Fix checking return value of regmap_read()
Date: Wed, 11 Jul 2012 09:50:46 +0800	[thread overview]
Message-ID: <4FFCDBF6.4030005@marvell.com> (raw)
In-Reply-To: <1341970074.11561.1.camel@phoenix>

On 07/11/2012 09:27 AM, Axel Lin wrote:
> Check the return value of regmap_read() rather than the read value.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>   drivers/mfd/88pm800.c |   16 +++++++++-------
>   drivers/mfd/88pm805.c |    5 +++--
>   2 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/mfd/88pm800.c b/drivers/mfd/88pm800.c
> index ec7d9b8..b67a301 100644
> --- a/drivers/mfd/88pm800.c
> +++ b/drivers/mfd/88pm800.c
> @@ -419,22 +419,24 @@ static int __devinit device_800_init(struct pm80x_chip *chip,
>   				     struct pm80x_platform_data *pdata)
>   {
>   	int ret, pmic_id;
> +	unsigned int val;
>
> -	regmap_read(chip->regmap, PM800_CHIP_ID, &ret);
> +	ret = regmap_read(chip->regmap, PM800_CHIP_ID, &val);
>   	if (ret < 0) {
>   		dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
>   		goto out;
>   	}
>
> -	pmic_id = ret & PM80X_VERSION_MASK;
> +	pmic_id = val & PM80X_VERSION_MASK;
>
>   	if ((pmic_id >= PM800_CHIP_A0) && (pmic_id <= PM800_CHIP_END)) {
> -		chip->version = ret;
> +		chip->version = val;
>   		dev_info(chip->dev,
> -			 "88PM80x:Marvell 88PM800 (ID:0x%x) detected\n", ret);
> +			 "88PM80x:Marvell 88PM800 (ID:0x%x) detected\n", val);
>   	} else {
>   		dev_err(chip->dev,
> -			"Failed to detect Marvell 88PM800:ChipID[0x%x]\n", ret);
> +			"Failed to detect Marvell 88PM800:ChipID[0x%x]\n", val);
> +		ret = -EINVAL;
>   		goto out;
>   	}
>
> @@ -442,12 +444,12 @@ static int __devinit device_800_init(struct pm80x_chip *chip,
>   	 * alarm wake up bit will be clear in device_irq_init(),
>   	 * read before that
>   	 */
> -	regmap_read(chip->regmap, PM800_RTC_CONTROL, &ret);
> +	ret = regmap_read(chip->regmap, PM800_RTC_CONTROL, &val);
>   	if (ret < 0) {
>   		dev_err(chip->dev, "Failed to read RTC register: %d\n", ret);
>   		goto out;
>   	}
> -	if (ret & PM800_ALARM_WAKEUP) {
> +	if (val & PM800_ALARM_WAKEUP) {
>   		if (pdata && pdata->rtc)
>   			pdata->rtc->rtc_wakeup = 1;
>   	}
> diff --git a/drivers/mfd/88pm805.c b/drivers/mfd/88pm805.c
> index d59ca6b..6146583 100644
> --- a/drivers/mfd/88pm805.c
> +++ b/drivers/mfd/88pm805.c
> @@ -192,6 +192,7 @@ static struct regmap_irq_chip pm805_irq_chip = {
>   static int __devinit device_805_init(struct pm80x_chip *chip)
>   {
>   	int ret = 0;
> +	unsigned int val;
>   	struct regmap *map = chip->regmap;
>
>   	if (!map) {
> @@ -199,12 +200,12 @@ static int __devinit device_805_init(struct pm80x_chip *chip)
>   		return -EINVAL;
>   	}
>
> -	regmap_read(map, PM805_CHIP_ID, &ret);
> +	ret = regmap_read(map, PM805_CHIP_ID, &val);
>   	if (ret < 0) {
>   		dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
>   		goto out_irq_init;
>   	}
> -	chip->version = ret;
> +	chip->version = val;
>
>   	chip->regmap_irq_chip = &pm805_irq_chip;
>
>
Axel,

thanks for the fixing.

-- 

Best Regards
Qiao



  reply	other threads:[~2012-07-11  1:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11  1:27 [PATCH] mfd: Fix checking return value of regmap_read() Axel Lin
2012-07-11  1:50 ` Qiao Zhou [this message]
2012-07-16 13:28 ` Samuel Ortiz

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=4FFCDBF6.4030005@marvell.com \
    --to=zhouqiao@marvell.com \
    --cc=arnd@arndb.de \
    --cc=axel.lin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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.