Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 302249
b: refs/heads/master
c: 0f80ea1
h: refs/heads/master
i:
  302247: e408e42
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed Apr 23, 2012
1 parent 9fcab5d commit d93c33e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8ae5767ba1c4e149ee9970aa7a4e9bf6b251bb77
refs/heads/master: 0f80ea1499ae047dcaa29ccecfe0d58bb229c4e9
45 changes: 17 additions & 28 deletions trunk/drivers/regulator/max8998.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,16 +718,15 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
return -ENODEV;
}

max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL);
max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_data),
GFP_KERNEL);
if (!max8998)
return -ENOMEM;

size = sizeof(struct regulator_dev *) * pdata->num_regulators;
max8998->rdev = kzalloc(size, GFP_KERNEL);
if (!max8998->rdev) {
kfree(max8998);
max8998->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
if (!max8998->rdev)
return -ENOMEM;
}

rdev = max8998->rdev;
max8998->dev = &pdev->dev;
Expand All @@ -751,14 +750,14 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
WARN_ON(!pdata->buck1_set1);
ret = -EIO;
goto err_free_mem;
goto err_out;
}
/* Check if SET2 is not equal to 0 */
if (!pdata->buck1_set2) {
printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
WARN_ON(!pdata->buck1_set2);
ret = -EIO;
goto err_free_mem;
goto err_out;
}

gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
Expand All @@ -778,7 +777,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck1_vol[0] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
if (ret)
goto err_free_mem;
goto err_out;

/* Set predefined value for BUCK1 register 2 */
i = 0;
Expand All @@ -790,7 +789,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck1_vol[1] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
if (ret)
goto err_free_mem;
goto err_out;

/* Set predefined value for BUCK1 register 3 */
i = 0;
Expand All @@ -802,7 +801,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck1_vol[2] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
if (ret)
goto err_free_mem;
goto err_out;

/* Set predefined value for BUCK1 register 4 */
i = 0;
Expand All @@ -814,7 +813,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck1_vol[3] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
if (ret)
goto err_free_mem;
goto err_out;

}

Expand All @@ -824,7 +823,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
WARN_ON(!pdata->buck2_set3);
ret = -EIO;
goto err_free_mem;
goto err_out;
}
gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
gpio_direction_output(pdata->buck2_set3,
Expand All @@ -839,7 +838,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck2_vol[0] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
if (ret)
goto err_free_mem;
goto err_out;

/* BUCK2 register 2 */
i = 0;
Expand All @@ -850,7 +849,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck2_vol[1] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
if (ret)
goto err_free_mem;
goto err_out;
}

for (i = 0; i < pdata->num_regulators; i++) {
Expand Down Expand Up @@ -880,14 +879,9 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)

return 0;
err:
for (i = 0; i < max8998->num_regulators; i++)
if (rdev[i])
regulator_unregister(rdev[i]);

err_free_mem:
kfree(max8998->rdev);
kfree(max8998);

while (--i >= 0)
regulator_unregister(rdev[i]);
err_out:
return ret;
}

Expand All @@ -898,12 +892,7 @@ static int __devexit max8998_pmic_remove(struct platform_device *pdev)
int i;

for (i = 0; i < max8998->num_regulators; i++)
if (rdev[i])
regulator_unregister(rdev[i]);

kfree(max8998->rdev);
kfree(max8998);

regulator_unregister(rdev[i]);
return 0;
}

Expand Down

0 comments on commit d93c33e

Please sign in to comment.