Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 302248
b: refs/heads/master
c: 8ae5767
h: refs/heads/master
v: v3
  • Loading branch information
Axel Lin authored and Mark Brown committed Apr 23, 2012
1 parent e408e42 commit 9fcab5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 26 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: 6c9eeb0f5cac0d9fd05c138f1eec86a7f70630ce
refs/heads/master: 8ae5767ba1c4e149ee9970aa7a4e9bf6b251bb77
40 changes: 15 additions & 25 deletions trunk/drivers/regulator/max8997.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,16 +949,15 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
return -ENODEV;
}

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

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

rdev = max8997->rdev;
max8997->dev = &pdev->dev;
Expand All @@ -982,7 +981,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
pdata->buck1_voltage[i] / 1000 +
buck1245_voltage_map_desc.step);
if (ret < 0)
goto err_alloc;
goto err_out;

max8997->buck2_vol[i] = ret =
max8997_get_voltage_proper_val(
Expand All @@ -991,7 +990,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
pdata->buck2_voltage[i] / 1000 +
buck1245_voltage_map_desc.step);
if (ret < 0)
goto err_alloc;
goto err_out;

max8997->buck5_vol[i] = ret =
max8997_get_voltage_proper_val(
Expand All @@ -1000,7 +999,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
pdata->buck5_voltage[i] / 1000 +
buck1245_voltage_map_desc.step);
if (ret < 0)
goto err_alloc;
goto err_out;

if (max_buck1 < max8997->buck1_vol[i])
max_buck1 = max8997->buck1_vol[i];
Expand Down Expand Up @@ -1033,7 +1032,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
!gpio_is_valid(pdata->buck125_gpios[2])) {
dev_err(&pdev->dev, "GPIO NOT VALID\n");
ret = -EINVAL;
goto err_alloc;
goto err_out;
}

ret = gpio_request(pdata->buck125_gpios[0],
Expand All @@ -1042,7 +1041,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "Duplicated gpio request"
" on SET1\n");
else if (ret)
goto err_alloc;
goto err_out;
else
gpio1set = true;

Expand All @@ -1054,7 +1053,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
else if (ret) {
if (gpio1set)
gpio_free(pdata->buck125_gpios[0]);
goto err_alloc;
goto err_out;
} else
gpio2set = true;

Expand All @@ -1068,7 +1067,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)
gpio_free(pdata->buck125_gpios[0]);
if (gpio2set)
gpio_free(pdata->buck125_gpios[1]);
goto err_alloc;
goto err_out;
}

gpio_direction_output(pdata->buck125_gpios[0],
Expand Down Expand Up @@ -1137,13 +1136,9 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev)

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

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

Expand All @@ -1154,12 +1149,7 @@ static int __devexit max8997_pmic_remove(struct platform_device *pdev)
int i;

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

kfree(max8997->rdev);
kfree(max8997);

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

Expand Down

0 comments on commit 9fcab5d

Please sign in to comment.