rtc: rtc-m41t80: 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>
This commit is contained in:
Jingoo Han 2013-04-29 16:20:42 -07:00 committed by Linus Torvalds
parent dc831f9768
commit 4ebabb78e4

View File

@ -637,7 +637,8 @@ static int m41t80_probe(struct i2c_client *client,
dev_info(&client->dev, dev_info(&client->dev,
"chip found, driver version " DRV_VERSION "\n"); "chip found, driver version " DRV_VERSION "\n");
clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL); clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata),
GFP_KERNEL);
if (!clientdata) { if (!clientdata) {
rc = -ENOMEM; rc = -ENOMEM;
goto exit; goto exit;
@ -646,8 +647,8 @@ static int m41t80_probe(struct i2c_client *client,
clientdata->features = id->driver_data; clientdata->features = id->driver_data;
i2c_set_clientdata(client, clientdata); i2c_set_clientdata(client, clientdata);
rtc = rtc_device_register(client->name, &client->dev, rtc = devm_rtc_device_register(&client->dev, client->name,
&m41t80_rtc_ops, THIS_MODULE); &m41t80_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) { if (IS_ERR(rtc)) {
rc = PTR_ERR(rtc); rc = PTR_ERR(rtc);
rtc = NULL; rtc = NULL;
@ -718,26 +719,19 @@ ht_err:
goto exit; goto exit;
exit: exit:
if (rtc)
rtc_device_unregister(rtc);
kfree(clientdata);
return rc; return rc;
} }
static int m41t80_remove(struct i2c_client *client) static int m41t80_remove(struct i2c_client *client)
{ {
struct m41t80_data *clientdata = i2c_get_clientdata(client);
struct rtc_device *rtc = clientdata->rtc;
#ifdef CONFIG_RTC_DRV_M41T80_WDT #ifdef CONFIG_RTC_DRV_M41T80_WDT
struct m41t80_data *clientdata = i2c_get_clientdata(client);
if (clientdata->features & M41T80_FEATURE_HT) { if (clientdata->features & M41T80_FEATURE_HT) {
misc_deregister(&wdt_dev); misc_deregister(&wdt_dev);
unregister_reboot_notifier(&wdt_notifier); unregister_reboot_notifier(&wdt_notifier);
} }
#endif #endif
if (rtc)
rtc_device_unregister(rtc);
kfree(clientdata);
return 0; return 0;
} }