Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sachin Kamat and committed by
Mark Brown
0ab6e8ca be1221e8

+4 -20
+4 -20
drivers/regulator/isl6271a-regulator.c
··· 112 112 struct regulator_config config = { }; 113 113 struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); 114 114 struct isl_pmic *pmic; 115 - int err, i; 115 + int i; 116 116 117 117 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 118 118 return -EIO; ··· 133 133 config.init_data = NULL; 134 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 138 if (IS_ERR(pmic->rdev[i])) { 138 139 dev_err(&i2c->dev, "failed to register %s\n", id->name); 139 - err = PTR_ERR(pmic->rdev[i]); 140 - goto error; 140 + return PTR_ERR(pmic->rdev[i]); 141 141 } 142 142 } 143 143 144 144 i2c_set_clientdata(i2c, pmic); 145 145 146 - return 0; 147 - 148 - error: 149 - while (--i >= 0) 150 - regulator_unregister(pmic->rdev[i]); 151 - return err; 152 - } 153 - 154 - static 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 146 return 0; 162 147 } 163 148 ··· 159 174 .owner = THIS_MODULE, 160 175 }, 161 176 .probe = isl6271a_probe, 162 - .remove = isl6271a_remove, 163 177 .id_table = isl6271a_id, 164 178 }; 165 179