From: Krzysztof Kozlowski Date: Tue, 4 Nov 2014 08:49:43 +0000 (+0100) Subject: regulator: max77802: Don't ignore return value of current opmode X-Git-Tag: MMI-PSA29.97-13-9~11084^2~2^4~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a26ed45c912d46cedac5f15c2872aa7e462fcdf1;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git regulator: max77802: Don't ignore return value of current opmode The return value of regmap_read() of current opmode for regulator was silently ignored and whatever happened to be in 'val' variable was used as new opmode. This could lead to using bogus opmode. Don't ignore what regmap_read() returns. If it fails just fall back to normal opmode. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index f8f06ece2f3c..d076df1d2166 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -606,7 +606,13 @@ static int max77802_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].of_node; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); - val = val >> shift & MAX77802_OPMODE_MASK; + if (ret < 0) { + dev_warn(&pdev->dev, + "cannot read current mode for %d\n", i); + val = MAX77802_OPMODE_NORMAL; + } else { + val = val >> shift & MAX77802_OPMODE_MASK; + } /* * If the regulator is disabled and the system warm rebooted,