aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-02-24 02:38:12 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-03-03 09:49:28 -0500
commit56c23492b2266fcbe38f26a3de217902c70a895b (patch)
tree83d53e7e1390a641babd0ada9e5c9dc65ef622c1 /drivers/regulator
parent54d13ab1038911249fc5769efee87fed000623c0 (diff)
Regulators: tps6507x-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: Dmitry Torokhov <dtor@mail.ru> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/tps6507x-regulator.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index f8a6dfbef751..c2a9539acd72 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -538,8 +538,8 @@ static struct regulator_ops tps6507x_ldo_ops = {
538 .list_voltage = tps6507x_ldo_list_voltage, 538 .list_voltage = tps6507x_ldo_list_voltage,
539}; 539};
540 540
541static 541static int __devinit tps_6507x_probe(struct i2c_client *client,
542int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id) 542 const struct i2c_device_id *id)
543{ 543{
544 static int desc_id; 544 static int desc_id;
545 const struct tps_info *info = (void *)id->driver_data; 545 const struct tps_info *info = (void *)id->driver_data;
@@ -547,6 +547,7 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id)
547 struct regulator_dev *rdev; 547 struct regulator_dev *rdev;
548 struct tps_pmic *tps; 548 struct tps_pmic *tps;
549 int i; 549 int i;
550 int error;
550 551
551 if (!i2c_check_functionality(client->adapter, 552 if (!i2c_check_functionality(client->adapter,
552 I2C_FUNC_SMBUS_BYTE_DATA)) 553 I2C_FUNC_SMBUS_BYTE_DATA))
@@ -557,7 +558,6 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id)
557 * coming from the board-evm file. 558 * coming from the board-evm file.
558 */ 559 */
559 init_data = client->dev.platform_data; 560 init_data = client->dev.platform_data;
560
561 if (!init_data) 561 if (!init_data)
562 return -EIO; 562 return -EIO;
563 563
@@ -586,18 +586,8 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id)
586 if (IS_ERR(rdev)) { 586 if (IS_ERR(rdev)) {
587 dev_err(&client->dev, "failed to register %s\n", 587 dev_err(&client->dev, "failed to register %s\n",
588 id->name); 588 id->name);
589 589 error = PTR_ERR(rdev);
590 /* Unregister */ 590 goto fail;
591 while (i)
592 regulator_unregister(tps->rdev[--i]);
593
594 tps->client = NULL;
595
596 /* clear the client data in i2c */
597 i2c_set_clientdata(client, NULL);
598
599 kfree(tps);
600 return PTR_ERR(rdev);
601 } 591 }
602 592
603 /* Save regulator for cleanup */ 593 /* Save regulator for cleanup */
@@ -607,6 +597,13 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id)
607 i2c_set_clientdata(client, tps); 597 i2c_set_clientdata(client, tps);
608 598
609 return 0; 599 return 0;
600
601fail:
602 while (--i >= 0)
603 regulator_unregister(tps->rdev[i]);
604
605 kfree(tps);
606 return error;
610} 607}
611 608
612/** 609/**
@@ -620,13 +617,12 @@ static int __devexit tps_6507x_remove(struct i2c_client *client)
620 struct tps_pmic *tps = i2c_get_clientdata(client); 617 struct tps_pmic *tps = i2c_get_clientdata(client);
621 int i; 618 int i;
622 619
620 /* clear the client data in i2c */
621 i2c_set_clientdata(client, NULL);
622
623 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) 623 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++)
624 regulator_unregister(tps->rdev[i]); 624 regulator_unregister(tps->rdev[i]);
625 625
626 tps->client = NULL;
627
628 /* clear the client data in i2c */
629 i2c_set_clientdata(client, NULL);
630 kfree(tps); 626 kfree(tps);
631 627
632 return 0; 628 return 0;