From dbb48e7c3db4871803fc990864e37917e413ccb2 Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Tue, 21 Jun 2011 09:08:59 +0530 Subject: [PATCH] regulator: MAX8997: Fix for divide by zero error Currently, ramp_delay variable is used uninitialzed in max8997_set_voltage_ldobuck which gets called through regulator_register calls. To fix the problem, in max8997_pmic_probe, ramp_delay initialization code is moved before calls to regulator_register. Cc: Liam Girdwood Cc: Mark Brown Cc: MyungJoo Ham Cc: Kyungmin Park Cc: Samuel Ortiz Signed-off-by: Tushar Behera Acked-by: MyungJoo Ham Acked-by: Mark Brown Signed-off-by: Liam Girdwood --- drivers/regulator/max8997.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 10d5a1d9768e..0fc7b8c720d2 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c @@ -1124,6 +1124,10 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) 0x3f); } + /* Misc Settings */ + max8997->ramp_delay = 10; /* set 10mV/us, which is the default */ + max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9); + for (i = 0; i < pdata->num_regulators; i++) { const struct voltage_map_desc *desc; int id = pdata->regulators[i].id; @@ -1148,10 +1152,6 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) } } - /* Misc Settings */ - max8997->ramp_delay = 10; /* set 10mV/us, which is the default */ - max8997_write_reg(i2c, MAX8997_REG_BUCKRAMP, (0xf << 4) | 0x9); - return 0; err: for (i = 0; i < max8997->num_regulators; i++) -- 2.20.1