diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:38 -0400 |
commit | 4ad21183da64a27fbe4bb547ae385ad1ff912690 (patch) | |
tree | aadcf9b4598eec1ce4ae4fe6a554a0a5a20266ab /drivers/rtc | |
parent | d6fbdc34c2eb7ad1309eaf83ead60dabf6e85352 (diff) |
rtc: rtc-pcf8583: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-pcf8583.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/rtc/rtc-pcf8583.c b/drivers/rtc/rtc-pcf8583.c index 5f97c61247d5..95886dcf4a39 100644 --- a/drivers/rtc/rtc-pcf8583.c +++ b/drivers/rtc/rtc-pcf8583.c | |||
@@ -268,39 +268,29 @@ static int pcf8583_probe(struct i2c_client *client, | |||
268 | const struct i2c_device_id *id) | 268 | const struct i2c_device_id *id) |
269 | { | 269 | { |
270 | struct pcf8583 *pcf8583; | 270 | struct pcf8583 *pcf8583; |
271 | int err; | ||
272 | 271 | ||
273 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 272 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
274 | return -ENODEV; | 273 | return -ENODEV; |
275 | 274 | ||
276 | pcf8583 = kzalloc(sizeof(struct pcf8583), GFP_KERNEL); | 275 | pcf8583 = devm_kzalloc(&client->dev, sizeof(struct pcf8583), |
276 | GFP_KERNEL); | ||
277 | if (!pcf8583) | 277 | if (!pcf8583) |
278 | return -ENOMEM; | 278 | return -ENOMEM; |
279 | 279 | ||
280 | i2c_set_clientdata(client, pcf8583); | 280 | i2c_set_clientdata(client, pcf8583); |
281 | 281 | ||
282 | pcf8583->rtc = rtc_device_register(pcf8583_driver.driver.name, | 282 | pcf8583->rtc = devm_rtc_device_register(&client->dev, |
283 | &client->dev, &pcf8583_rtc_ops, THIS_MODULE); | 283 | pcf8583_driver.driver.name, |
284 | &pcf8583_rtc_ops, THIS_MODULE); | ||
284 | 285 | ||
285 | if (IS_ERR(pcf8583->rtc)) { | 286 | if (IS_ERR(pcf8583->rtc)) |
286 | err = PTR_ERR(pcf8583->rtc); | 287 | return PTR_ERR(pcf8583->rtc); |
287 | goto exit_kfree; | ||
288 | } | ||
289 | 288 | ||
290 | return 0; | 289 | return 0; |
291 | |||
292 | exit_kfree: | ||
293 | kfree(pcf8583); | ||
294 | return err; | ||
295 | } | 290 | } |
296 | 291 | ||
297 | static int pcf8583_remove(struct i2c_client *client) | 292 | static int pcf8583_remove(struct i2c_client *client) |
298 | { | 293 | { |
299 | struct pcf8583 *pcf8583 = i2c_get_clientdata(client); | ||
300 | |||
301 | if (pcf8583->rtc) | ||
302 | rtc_device_unregister(pcf8583->rtc); | ||
303 | kfree(pcf8583); | ||
304 | return 0; | 294 | return 0; |
305 | } | 295 | } |
306 | 296 | ||