Commit 46b65a8f authored by Axel Lin's avatar Axel Lin Committed by Samuel Ortiz

mfd: Fix checking return value of 88pm8xx regmap_read()

Check the return value of regmap_read() rather than the read value.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent e102befe
...@@ -419,22 +419,24 @@ static int __devinit device_800_init(struct pm80x_chip *chip, ...@@ -419,22 +419,24 @@ static int __devinit device_800_init(struct pm80x_chip *chip,
struct pm80x_platform_data *pdata) struct pm80x_platform_data *pdata)
{ {
int ret, pmic_id; 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) { if (ret < 0) {
dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret); dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
goto out; 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)) { if ((pmic_id >= PM800_CHIP_A0) && (pmic_id <= PM800_CHIP_END)) {
chip->version = ret; chip->version = val;
dev_info(chip->dev, dev_info(chip->dev,
"88PM80x:Marvell 88PM800 (ID:0x%x) detected\n", ret); "88PM80x:Marvell 88PM800 (ID:0x%x) detected\n", val);
} else { } else {
dev_err(chip->dev, 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; goto out;
} }
...@@ -442,12 +444,12 @@ static int __devinit device_800_init(struct pm80x_chip *chip, ...@@ -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(), * alarm wake up bit will be clear in device_irq_init(),
* read before that * read before that
*/ */
regmap_read(chip->regmap, PM800_RTC_CONTROL, &ret); ret = regmap_read(chip->regmap, PM800_RTC_CONTROL, &val);
if (ret < 0) { if (ret < 0) {
dev_err(chip->dev, "Failed to read RTC register: %d\n", ret); dev_err(chip->dev, "Failed to read RTC register: %d\n", ret);
goto out; goto out;
} }
if (ret & PM800_ALARM_WAKEUP) { if (val & PM800_ALARM_WAKEUP) {
if (pdata && pdata->rtc) if (pdata && pdata->rtc)
pdata->rtc->rtc_wakeup = 1; pdata->rtc->rtc_wakeup = 1;
} }
......
...@@ -192,6 +192,7 @@ static struct regmap_irq_chip pm805_irq_chip = { ...@@ -192,6 +192,7 @@ static struct regmap_irq_chip pm805_irq_chip = {
static int __devinit device_805_init(struct pm80x_chip *chip) static int __devinit device_805_init(struct pm80x_chip *chip)
{ {
int ret = 0; int ret = 0;
unsigned int val;
struct regmap *map = chip->regmap; struct regmap *map = chip->regmap;
if (!map) { if (!map) {
...@@ -199,12 +200,12 @@ static int __devinit device_805_init(struct pm80x_chip *chip) ...@@ -199,12 +200,12 @@ static int __devinit device_805_init(struct pm80x_chip *chip)
return -EINVAL; return -EINVAL;
} }
regmap_read(map, PM805_CHIP_ID, &ret); ret = regmap_read(map, PM805_CHIP_ID, &val);
if (ret < 0) { if (ret < 0) {
dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret); dev_err(chip->dev, "Failed to read CHIP ID: %d\n", ret);
goto out_irq_init; goto out_irq_init;
} }
chip->version = ret; chip->version = val;
chip->regmap_irq_chip = &pm805_irq_chip; chip->regmap_irq_chip = &pm805_irq_chip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment