diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/regulator/tps6507x-regulator.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/regulator/tps6507x-regulator.c')
-rw-r--r-- | drivers/regulator/tps6507x-regulator.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index f8a6dfbef751..74841abcc9cc 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | ||
27 | 28 | ||
28 | /* Register definitions */ | 29 | /* Register definitions */ |
29 | #define TPS6507X_REG_PPATH1 0X01 | 30 | #define TPS6507X_REG_PPATH1 0X01 |
@@ -538,8 +539,8 @@ static struct regulator_ops tps6507x_ldo_ops = { | |||
538 | .list_voltage = tps6507x_ldo_list_voltage, | 539 | .list_voltage = tps6507x_ldo_list_voltage, |
539 | }; | 540 | }; |
540 | 541 | ||
541 | static | 542 | static int __devinit tps_6507x_probe(struct i2c_client *client, |
542 | int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id) | 543 | const struct i2c_device_id *id) |
543 | { | 544 | { |
544 | static int desc_id; | 545 | static int desc_id; |
545 | const struct tps_info *info = (void *)id->driver_data; | 546 | const struct tps_info *info = (void *)id->driver_data; |
@@ -547,6 +548,7 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
547 | struct regulator_dev *rdev; | 548 | struct regulator_dev *rdev; |
548 | struct tps_pmic *tps; | 549 | struct tps_pmic *tps; |
549 | int i; | 550 | int i; |
551 | int error; | ||
550 | 552 | ||
551 | if (!i2c_check_functionality(client->adapter, | 553 | if (!i2c_check_functionality(client->adapter, |
552 | I2C_FUNC_SMBUS_BYTE_DATA)) | 554 | I2C_FUNC_SMBUS_BYTE_DATA)) |
@@ -557,7 +559,6 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
557 | * coming from the board-evm file. | 559 | * coming from the board-evm file. |
558 | */ | 560 | */ |
559 | init_data = client->dev.platform_data; | 561 | init_data = client->dev.platform_data; |
560 | |||
561 | if (!init_data) | 562 | if (!init_data) |
562 | return -EIO; | 563 | return -EIO; |
563 | 564 | ||
@@ -586,18 +587,8 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
586 | if (IS_ERR(rdev)) { | 587 | if (IS_ERR(rdev)) { |
587 | dev_err(&client->dev, "failed to register %s\n", | 588 | dev_err(&client->dev, "failed to register %s\n", |
588 | id->name); | 589 | id->name); |
589 | 590 | error = PTR_ERR(rdev); | |
590 | /* Unregister */ | 591 | 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 | } | 592 | } |
602 | 593 | ||
603 | /* Save regulator for cleanup */ | 594 | /* Save regulator for cleanup */ |
@@ -607,6 +598,13 @@ int tps_6507x_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
607 | i2c_set_clientdata(client, tps); | 598 | i2c_set_clientdata(client, tps); |
608 | 599 | ||
609 | return 0; | 600 | return 0; |
601 | |||
602 | fail: | ||
603 | while (--i >= 0) | ||
604 | regulator_unregister(tps->rdev[i]); | ||
605 | |||
606 | kfree(tps); | ||
607 | return error; | ||
610 | } | 608 | } |
611 | 609 | ||
612 | /** | 610 | /** |
@@ -620,13 +618,12 @@ static int __devexit tps_6507x_remove(struct i2c_client *client) | |||
620 | struct tps_pmic *tps = i2c_get_clientdata(client); | 618 | struct tps_pmic *tps = i2c_get_clientdata(client); |
621 | int i; | 619 | int i; |
622 | 620 | ||
621 | /* clear the client data in i2c */ | ||
622 | i2c_set_clientdata(client, NULL); | ||
623 | |||
623 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) | 624 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) |
624 | regulator_unregister(tps->rdev[i]); | 625 | regulator_unregister(tps->rdev[i]); |
625 | 626 | ||
626 | tps->client = NULL; | ||
627 | |||
628 | /* clear the client data in i2c */ | ||
629 | i2c_set_clientdata(client, NULL); | ||
630 | kfree(tps); | 627 | kfree(tps); |
631 | 628 | ||
632 | return 0; | 629 | return 0; |