From: Axel Lin Date: Wed, 13 Nov 2013 06:55:14 +0000 (+0800) Subject: regulator: lp3972: Convert to devm_regulator_register X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=93227c801372522d6f667aac0de2cacc7995d8b9;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git regulator: lp3972: Convert to devm_regulator_register Both num_regulators and **rdev are no longer required after this conversion, thus remove them from struct lp3972. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index 093e6f44ff8a..aea485afcc1a 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(®ulators[reg->id], - &config); - if (IS_ERR(lp3972->rdev[i])) { - err = PTR_ERR(lp3972->rdev[i]); + rdev = devm_regulator_register(lp3972->dev, + ®ulators[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, };