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

drivers/rtc/rtc-ds3232.c: use devm_* APIs

devm_* functions are device managed and make cleanup code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Sachin Kamat and committed by
Linus Torvalds
66714612 d1a96639

+7 -18
+7 -18
drivers/rtc/rtc-ds3232.c
··· 397 397 struct ds3232 *ds3232; 398 398 int ret; 399 399 400 - ds3232 = kzalloc(sizeof(struct ds3232), GFP_KERNEL); 400 + ds3232 = devm_kzalloc(&client->dev, sizeof(struct ds3232), GFP_KERNEL); 401 401 if (!ds3232) 402 402 return -ENOMEM; 403 403 ··· 409 409 410 410 ret = ds3232_check_rtc_status(client); 411 411 if (ret) 412 - goto out_free; 412 + return ret; 413 413 414 - ds3232->rtc = rtc_device_register(client->name, &client->dev, 414 + ds3232->rtc = devm_rtc_device_register(&client->dev, client->name, 415 415 &ds3232_rtc_ops, THIS_MODULE); 416 416 if (IS_ERR(ds3232->rtc)) { 417 - ret = PTR_ERR(ds3232->rtc); 418 417 dev_err(&client->dev, "unable to register the class device\n"); 419 - goto out_irq; 418 + return PTR_ERR(ds3232->rtc); 420 419 } 421 420 422 421 if (client->irq >= 0) { 423 - ret = request_irq(client->irq, ds3232_irq, 0, 422 + ret = devm_request_irq(&client->dev, client->irq, ds3232_irq, 0, 424 423 "ds3232", client); 425 424 if (ret) { 426 425 dev_err(&client->dev, "unable to request IRQ\n"); 427 - goto out_free; 426 + return ret; 428 427 } 429 428 } 430 429 431 430 return 0; 432 - 433 - out_irq: 434 - if (client->irq >= 0) 435 - free_irq(client->irq, client); 436 - 437 - out_free: 438 - kfree(ds3232); 439 - return ret; 440 431 } 441 432 442 433 static int ds3232_remove(struct i2c_client *client) ··· 439 448 ds3232->exiting = 1; 440 449 mutex_unlock(&ds3232->mutex); 441 450 442 - free_irq(client->irq, client); 451 + devm_free_irq(&client->dev, client->irq, client); 443 452 cancel_work_sync(&ds3232->work); 444 453 } 445 454 446 - rtc_device_unregister(ds3232->rtc); 447 - kfree(ds3232); 448 455 return 0; 449 456 } 450 457