aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-02-24 02:38:06 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-03-03 09:49:27 -0500
commit54d13ab1038911249fc5769efee87fed000623c0 (patch)
treecd0e4b3bc8be562f9bb0ca1c852c54973a672a3f /drivers/regulator
parent24c29020bac8a35729e1f58270b3622abc2941a2 (diff)
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: 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/tps65023-regulator.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c
index 07fda0a75adf..1f183543bdbd 100644
--- a/drivers/regulator/tps65023-regulator.c
+++ b/drivers/regulator/tps65023-regulator.c
@@ -457,8 +457,8 @@ static struct regulator_ops tps65023_ldo_ops = {
457 .list_voltage = tps65023_ldo_list_voltage, 457 .list_voltage = tps65023_ldo_list_voltage,
458}; 458};
459 459
460static 460static int __devinit tps_65023_probe(struct i2c_client *client,
461int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id) 461 const struct i2c_device_id *id)
462{ 462{
463 static int desc_id; 463 static int desc_id;
464 const struct tps_info *info = (void *)id->driver_data; 464 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 struct regulator_dev *rdev; 466 struct regulator_dev *rdev;
467 struct tps_pmic *tps; 467 struct tps_pmic *tps;
468 int i; 468 int i;
469 int error;
469 470
470 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 471 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
471 return -EIO; 472 return -EIO;
@@ -475,7 +476,6 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
475 * coming from the board-evm file. 476 * coming from the board-evm file.
476 */ 477 */
477 init_data = client->dev.platform_data; 478 init_data = client->dev.platform_data;
478
479 if (!init_data) 479 if (!init_data)
480 return -EIO; 480 return -EIO;
481 481
@@ -502,21 +502,12 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
502 502
503 /* Register the regulators */ 503 /* Register the regulators */
504 rdev = regulator_register(&tps->desc[i], &client->dev, 504 rdev = regulator_register(&tps->desc[i], &client->dev,
505 init_data, tps); 505 init_data, tps);
506 if (IS_ERR(rdev)) { 506 if (IS_ERR(rdev)) {
507 dev_err(&client->dev, "failed to register %s\n", 507 dev_err(&client->dev, "failed to register %s\n",
508 id->name); 508 id->name);
509 509 error = PTR_ERR(rdev);
510 /* Unregister */ 510 goto fail;
511 while (i)
512 regulator_unregister(tps->rdev[--i]);
513
514 tps->client = NULL;
515
516 /* clear the client data in i2c */
517 i2c_set_clientdata(client, NULL);
518 kfree(tps);
519 return PTR_ERR(rdev);
520 } 511 }
521 512
522 /* Save regulator for cleanup */ 513 /* Save regulator for cleanup */
@@ -526,6 +517,13 @@ int tps_65023_probe(struct i2c_client *client, const struct i2c_device_id *id)
526 i2c_set_clientdata(client, tps); 517 i2c_set_clientdata(client, tps);
527 518
528 return 0; 519 return 0;
520
521 fail:
522 while (--i >= 0)
523 regulator_unregister(tps->rdev[i]);
524
525 kfree(tps);
526 return error;
529} 527}
530 528
531/** 529/**
@@ -539,13 +537,12 @@ static int __devexit tps_65023_remove(struct i2c_client *client)
539 struct tps_pmic *tps = i2c_get_clientdata(client); 537 struct tps_pmic *tps = i2c_get_clientdata(client);
540 int i; 538 int i;
541 539
540 /* clear the client data in i2c */
541 i2c_set_clientdata(client, NULL);
542
542 for (i = 0; i < TPS65023_NUM_REGULATOR; i++) 543 for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
543 regulator_unregister(tps->rdev[i]); 544 regulator_unregister(tps->rdev[i]);
544 545
545 tps->client = NULL;
546
547 /* clear the client data in i2c */
548 i2c_set_clientdata(client, NULL);
549 kfree(tps); 546 kfree(tps);
550 547
551 return 0; 548 return 0;