Skip to content

Commit

Permalink
regulator: max8952: Use devm_kzalloc
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Axel Lin authored and Mark Brown committed May 16, 2012
1 parent dde2b72 commit 372de4a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/regulator/max8952.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
return -EIO;

max8952 = kzalloc(sizeof(struct max8952_data), GFP_KERNEL);
max8952 = devm_kzalloc(&client->dev, sizeof(struct max8952_data),
GFP_KERNEL);
if (!max8952)
return -ENOMEM;

Expand All @@ -198,7 +199,7 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
if (IS_ERR(max8952->rdev)) {
ret = PTR_ERR(max8952->rdev);
dev_err(max8952->dev, "regulator init failed (%d)\n", ret);
goto err_reg;
return ret;
}

max8952->en = !!(pdata->reg_data.constraints.boot_on);
Expand Down Expand Up @@ -295,10 +296,6 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
i2c_set_clientdata(client, max8952);

return 0;

err_reg:
kfree(max8952);
return ret;
}

static int __devexit max8952_pmic_remove(struct i2c_client *client)
Expand All @@ -312,8 +309,6 @@ static int __devexit max8952_pmic_remove(struct i2c_client *client)
gpio_free(pdata->gpio_vid0);
gpio_free(pdata->gpio_vid1);
gpio_free(pdata->gpio_en);

kfree(max8952);
return 0;
}

Expand Down

0 comments on commit 372de4a

Please sign in to comment.