Commit 6922ffcfad1a5ff8cd0e44bbcee3686dd6caf13c
Committed by
Lee Jones
1 parent
b2cdcfacfe
mfd: max8997: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Showing 1 changed file with 5 additions and 9 deletions Side-by-side Diff
drivers/mfd/max8997.c
... | ... | @@ -191,7 +191,8 @@ |
191 | 191 | struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev); |
192 | 192 | int ret = 0; |
193 | 193 | |
194 | - max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL); | |
194 | + max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev), | |
195 | + GFP_KERNEL); | |
195 | 196 | if (max8997 == NULL) |
196 | 197 | return -ENOMEM; |
197 | 198 | |
198 | 199 | |
... | ... | @@ -203,14 +204,12 @@ |
203 | 204 | |
204 | 205 | if (max8997->dev->of_node) { |
205 | 206 | pdata = max8997_i2c_parse_dt_pdata(max8997->dev); |
206 | - if (IS_ERR(pdata)) { | |
207 | - ret = PTR_ERR(pdata); | |
208 | - goto err; | |
209 | - } | |
207 | + if (IS_ERR(pdata)) | |
208 | + return PTR_ERR(pdata); | |
210 | 209 | } |
211 | 210 | |
212 | 211 | if (!pdata) |
213 | - goto err; | |
212 | + return ret; | |
214 | 213 | |
215 | 214 | max8997->pdata = pdata; |
216 | 215 | max8997->ono = pdata->ono; |
... | ... | @@ -250,8 +249,6 @@ |
250 | 249 | i2c_unregister_device(max8997->muic); |
251 | 250 | i2c_unregister_device(max8997->haptic); |
252 | 251 | i2c_unregister_device(max8997->rtc); |
253 | -err: | |
254 | - kfree(max8997); | |
255 | 252 | return ret; |
256 | 253 | } |
257 | 254 | |
... | ... | @@ -263,7 +260,6 @@ |
263 | 260 | i2c_unregister_device(max8997->muic); |
264 | 261 | i2c_unregister_device(max8997->haptic); |
265 | 262 | i2c_unregister_device(max8997->rtc); |
266 | - kfree(max8997); | |
267 | 263 | |
268 | 264 | return 0; |
269 | 265 | } |