regulator: max8660: Use devm_kzalloc()
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
b7bd05b8d5
commit
4d26f7d581
|
@ -367,16 +367,14 @@ static int __devinit max8660_probe(struct i2c_client *client,
|
||||||
|
|
||||||
if (pdata->num_subdevs > MAX8660_V_END) {
|
if (pdata->num_subdevs > MAX8660_V_END) {
|
||||||
dev_err(&client->dev, "Too many regulators found!\n");
|
dev_err(&client->dev, "Too many regulators found!\n");
|
||||||
goto out;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
max8660 = kzalloc(sizeof(struct max8660) +
|
max8660 = kzalloc(sizeof(struct max8660) +
|
||||||
sizeof(struct regulator_dev *) * MAX8660_V_END,
|
sizeof(struct regulator_dev *) * MAX8660_V_END,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!max8660) {
|
if (!max8660)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
max8660->client = client;
|
max8660->client = client;
|
||||||
rdev = max8660->rdev;
|
rdev = max8660->rdev;
|
||||||
|
@ -405,7 +403,7 @@ static int __devinit max8660_probe(struct i2c_client *client,
|
||||||
for (i = 0; i < pdata->num_subdevs; i++) {
|
for (i = 0; i < pdata->num_subdevs; i++) {
|
||||||
|
|
||||||
if (!pdata->subdevs[i].platform_data)
|
if (!pdata->subdevs[i].platform_data)
|
||||||
goto err_free;
|
goto err_out;
|
||||||
|
|
||||||
boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
|
boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
|
||||||
|
|
||||||
|
@ -431,7 +429,7 @@ static int __devinit max8660_probe(struct i2c_client *client,
|
||||||
case MAX8660_V7:
|
case MAX8660_V7:
|
||||||
if (!strcmp(i2c_id->name, "max8661")) {
|
if (!strcmp(i2c_id->name, "max8661")) {
|
||||||
dev_err(&client->dev, "Regulator not on this chip!\n");
|
dev_err(&client->dev, "Regulator not on this chip!\n");
|
||||||
goto err_free;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot_on)
|
if (boot_on)
|
||||||
|
@ -441,7 +439,7 @@ static int __devinit max8660_probe(struct i2c_client *client,
|
||||||
default:
|
default:
|
||||||
dev_err(&client->dev, "invalid regulator %s\n",
|
dev_err(&client->dev, "invalid regulator %s\n",
|
||||||
pdata->subdevs[i].name);
|
pdata->subdevs[i].name);
|
||||||
goto err_free;
|
goto err_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,9 +467,7 @@ static int __devinit max8660_probe(struct i2c_client *client,
|
||||||
err_unregister:
|
err_unregister:
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
regulator_unregister(rdev[i]);
|
regulator_unregister(rdev[i]);
|
||||||
err_free:
|
err_out:
|
||||||
kfree(max8660);
|
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,8 +479,6 @@ static int __devexit max8660_remove(struct i2c_client *client)
|
||||||
for (i = 0; i < MAX8660_V_END; i++)
|
for (i = 0; i < MAX8660_V_END; i++)
|
||||||
if (max8660->rdev[i])
|
if (max8660->rdev[i])
|
||||||
regulator_unregister(max8660->rdev[i]);
|
regulator_unregister(max8660->rdev[i]);
|
||||||
kfree(max8660);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue