Commit 54d13ab1 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Liam Girdwood

Regulators: tps65023-regulator - mark probe method as __devinit

Also move error handling in probe() out of line and do not bother
to reset fields in structures that are about to be freed.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 24c29020
...@@ -457,8 +457,8 @@ static struct regulator_ops tps65023_ldo_ops = { ...@@ -457,8 +457,8 @@ static struct regulator_ops tps65023_ldo_ops = {
.list_voltage = tps65023_ldo_list_voltage, .list_voltage = tps65023_ldo_list_voltage,
}; };
static static int __devinit tps_65023_probe(struct i2c_client *client,
int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
static int desc_id; static int desc_id;
const struct tps_info *info = (void *)id->driver_data; const struct tps_info *info = (void *)id->driver_data;
...@@ -466,6 +466,7 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -466,6 +466,7 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct tps_pmic *tps; struct tps_pmic *tps;
int i; int i;
int error;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -EIO; return -EIO;
...@@ -475,7 +476,6 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -475,7 +476,6 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
* coming from the board-evm file. * coming from the board-evm file.
*/ */
init_data = client->dev.platform_data; init_data = client->dev.platform_data;
if (!init_data) if (!init_data)
return -EIO; return -EIO;
...@@ -502,21 +502,12 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -502,21 +502,12 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
/* Register the regulators */ /* Register the regulators */
rdev = regulator_register(&tps->desc[i], &client->dev, rdev = regulator_register(&tps->desc[i], &client->dev,
init_data, tps); init_data, tps);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(&client->dev, "failed to register %s\n", dev_err(&client->dev, "failed to register %s\n",
id->name); id->name);
error = PTR_ERR(rdev);
/* Unregister */ goto fail;
while (i)
regulator_unregister(tps->rdev[--i]);
tps->client = NULL;
/* clear the client data in i2c */
i2c_set_clientdata(client, NULL);
kfree(tps);
return PTR_ERR(rdev);
} }
/* Save regulator for cleanup */ /* Save regulator for cleanup */
...@@ -526,6 +517,13 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -526,6 +517,13 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
i2c_set_clientdata(client, tps); i2c_set_clientdata(client, tps);
return 0; return 0;
fail:
while (--i >= 0)
regulator_unregister(tps->rdev[i]);
kfree(tps);
return error;
} }
/** /**
...@@ -539,13 +537,12 @@ static int __devexit tps_65023_remove(struct i2c_client *client) ...@@ -539,13 +537,12 @@ static int __devexit tps_65023_remove(struct i2c_client *client)
struct tps_pmic *tps = i2c_get_clientdata(client); struct tps_pmic *tps = i2c_get_clientdata(client);
int i; int i;
/* clear the client data in i2c */
i2c_set_clientdata(client, NULL);
for (i = 0; i < TPS65023_NUM_REGULATOR; i++) for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
regulator_unregister(tps->rdev[i]); regulator_unregister(tps->rdev[i]);
tps->client = NULL;
/* clear the client data in i2c */
i2c_set_clientdata(client, NULL);
kfree(tps); kfree(tps);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment