linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: lp3971: Convert to devm_regulator_register
@ 2013-11-13  6:52 Axel Lin
  2013-11-13  6:55 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
  2013-11-13 13:25 ` [PATCH 1/2] regulator: lp3971: " Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2013-11-13  6:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: Marek Szyprowski, Liam Girdwood, linux-kernel

Both num_regulators and **rdev are no longer required after this conversion,
thus remove them from struct lp3971.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/lp3971.c | 43 ++++++-------------------------------------
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index 947c05f..3b1102b 100644
--- a/drivers/regulator/lp3971.c
+++ b/drivers/regulator/lp3971.c
@@ -25,8 +25,6 @@ struct lp3971 {
 	struct device *dev;
 	struct mutex io_lock;
 	struct i2c_client *i2c;
-	int num_regulators;
-	struct regulator_dev **rdev;
 };
 
 static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg);
@@ -383,42 +381,27 @@ static int setup_regulators(struct lp3971 *lp3971,
 {
 	int i, err;
 
-	lp3971->num_regulators = pdata->num_regulators;
-	lp3971->rdev = kcalloc(pdata->num_regulators,
-				sizeof(struct regulator_dev *), GFP_KERNEL);
-	if (!lp3971->rdev) {
-		err = -ENOMEM;
-		goto err_nomem;
-	}
-
 	/* Instantiate the regulators */
 	for (i = 0; i < pdata->num_regulators; i++) {
 		struct regulator_config config = { };
 		struct lp3971_regulator_subdev *reg = &pdata->regulators[i];
+		struct regulator_dev *rdev;
 
 		config.dev = lp3971->dev;
 		config.init_data = reg->initdata;
 		config.driver_data = lp3971;
 
-		lp3971->rdev[i] = regulator_register(&regulators[reg->id],
-						     &config);
-		if (IS_ERR(lp3971->rdev[i])) {
-			err = PTR_ERR(lp3971->rdev[i]);
+		rdev = devm_regulator_register(lp3971->dev,
+					       &regulators[reg->id], &config);
+		if (IS_ERR(rdev)) {
+			err = PTR_ERR(rdev);
 			dev_err(lp3971->dev, "regulator init failed: %d\n",
 				err);
-			goto error;
+			return err;
 		}
 	}
 
 	return 0;
-
-error:
-	while (--i >= 0)
-		regulator_unregister(lp3971->rdev[i]);
-	kfree(lp3971->rdev);
-	lp3971->rdev = NULL;
-err_nomem:
-	return err;
 }
 
 static int lp3971_i2c_probe(struct i2c_client *i2c,
@@ -460,19 +443,6 @@ static int lp3971_i2c_probe(struct i2c_client *i2c,
 	return 0;
 }
 
-static int lp3971_i2c_remove(struct i2c_client *i2c)
-{
-	struct lp3971 *lp3971 = i2c_get_clientdata(i2c);
-	int i;
-
-	for (i = 0; i < lp3971->num_regulators; i++)
-		regulator_unregister(lp3971->rdev[i]);
-
-	kfree(lp3971->rdev);
-
-	return 0;
-}
-
 static const struct i2c_device_id lp3971_i2c_id[] = {
 	{ "lp3971", 0 },
 	{ }
@@ -485,7 +455,6 @@ static struct i2c_driver lp3971_i2c_driver = {
 		.owner = THIS_MODULE,
 	},
 	.probe    = lp3971_i2c_probe,
-	.remove   = lp3971_i2c_remove,
 	.id_table = lp3971_i2c_id,
 };
 
-- 
1.8.1.2




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] regulator: lp3972: Convert to devm_regulator_register
  2013-11-13  6:52 [PATCH 1/2] regulator: lp3971: Convert to devm_regulator_register Axel Lin
@ 2013-11-13  6:55 ` Axel Lin
  2013-11-13 13:26   ` Mark Brown
  2013-11-13 13:25 ` [PATCH 1/2] regulator: lp3971: " Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Axel Lin @ 2013-11-13  6:55 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, linux-kernel

Both num_regulators and **rdev are no longer required after this conversion,
thus remove them from struct lp3972.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/regulator/lp3972.c | 41 ++++++-----------------------------------
 1 file changed, 6 insertions(+), 35 deletions(-)

diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 093e6f4..aea485a 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -22,8 +22,6 @@ struct lp3972 {
 	struct device *dev;
 	struct mutex io_lock;
 	struct i2c_client *i2c;
-	int num_regulators;
-	struct regulator_dev **rdev;
 };
 
 /* LP3972 Control Registers */
@@ -478,41 +476,27 @@ static int setup_regulators(struct lp3972 *lp3972,
 {
 	int i, err;
 
-	lp3972->num_regulators = pdata->num_regulators;
-	lp3972->rdev = kcalloc(pdata->num_regulators,
-				sizeof(struct regulator_dev *), GFP_KERNEL);
-	if (!lp3972->rdev) {
-		err = -ENOMEM;
-		goto err_nomem;
-	}
-
 	/* Instantiate the regulators */
 	for (i = 0; i < pdata->num_regulators; i++) {
 		struct lp3972_regulator_subdev *reg = &pdata->regulators[i];
 		struct regulator_config config = { };
+		struct regulator_dev *rdev;
 
 		config.dev = lp3972->dev;
 		config.init_data = reg->initdata;
 		config.driver_data = lp3972;
 
-		lp3972->rdev[i] = regulator_register(&regulators[reg->id],
-						     &config);
-		if (IS_ERR(lp3972->rdev[i])) {
-			err = PTR_ERR(lp3972->rdev[i]);
+		rdev = devm_regulator_register(lp3972->dev,
+					       &regulators[reg->id], &config);
+		if (IS_ERR(rdev)) {
+			err = PTR_ERR(rdev);
 			dev_err(lp3972->dev, "regulator init failed: %d\n",
 				err);
-			goto error;
+			return err;
 		}
 	}
 
 	return 0;
-error:
-	while (--i >= 0)
-		regulator_unregister(lp3972->rdev[i]);
-	kfree(lp3972->rdev);
-	lp3972->rdev = NULL;
-err_nomem:
-	return err;
 }
 
 static int lp3972_i2c_probe(struct i2c_client *i2c,
@@ -557,18 +541,6 @@ static int lp3972_i2c_probe(struct i2c_client *i2c,
 	return 0;
 }
 
-static int lp3972_i2c_remove(struct i2c_client *i2c)
-{
-	struct lp3972 *lp3972 = i2c_get_clientdata(i2c);
-	int i;
-
-	for (i = 0; i < lp3972->num_regulators; i++)
-		regulator_unregister(lp3972->rdev[i]);
-	kfree(lp3972->rdev);
-
-	return 0;
-}
-
 static const struct i2c_device_id lp3972_i2c_id[] = {
 	{ "lp3972", 0 },
 	{ }
@@ -581,7 +553,6 @@ static struct i2c_driver lp3972_i2c_driver = {
 		.owner = THIS_MODULE,
 	},
 	.probe    = lp3972_i2c_probe,
-	.remove   = lp3972_i2c_remove,
 	.id_table = lp3972_i2c_id,
 };
 
-- 
1.8.1.2




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] regulator: lp3971: Convert to devm_regulator_register
  2013-11-13  6:52 [PATCH 1/2] regulator: lp3971: Convert to devm_regulator_register Axel Lin
  2013-11-13  6:55 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
@ 2013-11-13 13:25 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-11-13 13:25 UTC (permalink / raw)
  To: Axel Lin; +Cc: Marek Szyprowski, Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

On Wed, Nov 13, 2013 at 02:52:26PM +0800, Axel Lin wrote:
> Both num_regulators and **rdev are no longer required after this conversion,
> thus remove them from struct lp3971.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] regulator: lp3972: Convert to devm_regulator_register
  2013-11-13  6:55 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
@ 2013-11-13 13:26   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-11-13 13:26 UTC (permalink / raw)
  To: Axel Lin; +Cc: Liam Girdwood, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

On Wed, Nov 13, 2013 at 02:55:14PM +0800, Axel Lin wrote:
> Both num_regulators and **rdev are no longer required after this conversion,
> thus remove them from struct lp3972.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-13 13:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-13  6:52 [PATCH 1/2] regulator: lp3971: Convert to devm_regulator_register Axel Lin
2013-11-13  6:55 ` [PATCH 2/2] regulator: lp3972: " Axel Lin
2013-11-13 13:26   ` Mark Brown
2013-11-13 13:25 ` [PATCH 1/2] regulator: lp3971: " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).