aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/isl6271a-regulator.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-09-04 02:30:58 -0400
committerMark Brown <broonie@linaro.org>2013-09-16 19:28:42 -0400
commit0ab6e8ca54d22f986a488bbc493e01f1394a3b2b (patch)
tree9df89fc541b6411ec8a8dd2000a7d51494438848 /drivers/regulator/isl6271a-regulator.c
parentbe1221e893775d8447623475a01f877b902fc8b4 (diff)
regulator: isl6271a-regulator: Use devm_regulator_register
devm_* simplifies the code. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Acked-by: Marek Vasut <marex@denx.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/isl6271a-regulator.c')
-rw-r--r--drivers/regulator/isl6271a-regulator.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index 88c1a3acf563..6e5da95fa025 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -112,7 +112,7 @@ static int isl6271a_probe(struct i2c_client *i2c,
112 struct regulator_config config = { }; 112 struct regulator_config config = { };
113 struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); 113 struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev);
114 struct isl_pmic *pmic; 114 struct isl_pmic *pmic;
115 int err, i; 115 int i;
116 116
117 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 117 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
118 return -EIO; 118 return -EIO;
@@ -133,32 +133,17 @@ static int isl6271a_probe(struct i2c_client *i2c,
133 config.init_data = NULL; 133 config.init_data = NULL;
134 config.driver_data = pmic; 134 config.driver_data = pmic;
135 135
136 pmic->rdev[i] = regulator_register(&isl_rd[i], &config); 136 pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i],
137 &config);
137 if (IS_ERR(pmic->rdev[i])) { 138 if (IS_ERR(pmic->rdev[i])) {
138 dev_err(&i2c->dev, "failed to register %s\n", id->name); 139 dev_err(&i2c->dev, "failed to register %s\n", id->name);
139 err = PTR_ERR(pmic->rdev[i]); 140 return PTR_ERR(pmic->rdev[i]);
140 goto error;
141 } 141 }
142 } 142 }
143 143
144 i2c_set_clientdata(i2c, pmic); 144 i2c_set_clientdata(i2c, pmic);
145 145
146 return 0; 146 return 0;
147
148error:
149 while (--i >= 0)
150 regulator_unregister(pmic->rdev[i]);
151 return err;
152}
153
154static int isl6271a_remove(struct i2c_client *i2c)
155{
156 struct isl_pmic *pmic = i2c_get_clientdata(i2c);
157 int i;
158
159 for (i = 0; i < 3; i++)
160 regulator_unregister(pmic->rdev[i]);
161 return 0;
162} 147}
163 148
164static const struct i2c_device_id isl6271a_id[] = { 149static const struct i2c_device_id isl6271a_id[] = {
@@ -174,7 +159,6 @@ static struct i2c_driver isl6271a_i2c_driver = {
174 .owner = THIS_MODULE, 159 .owner = THIS_MODULE,
175 }, 160 },
176 .probe = isl6271a_probe, 161 .probe = isl6271a_probe,
177 .remove = isl6271a_remove,
178 .id_table = isl6271a_id, 162 .id_table = isl6271a_id,
179}; 163};
180 164