Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ebabb78 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds
Browse files

rtc: rtc-m41t80: use devm_*() functions



Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent dc831f97
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -637,7 +637,8 @@ static int m41t80_probe(struct i2c_client *client,
	dev_info(&client->dev,
		 "chip found, driver version " DRV_VERSION "\n");

	clientdata = kzalloc(sizeof(*clientdata), GFP_KERNEL);
	clientdata = devm_kzalloc(&client->dev, sizeof(*clientdata),
				GFP_KERNEL);
	if (!clientdata) {
		rc = -ENOMEM;
		goto exit;
@@ -646,7 +647,7 @@ static int m41t80_probe(struct i2c_client *client,
	clientdata->features = id->driver_data;
	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);
	if (IS_ERR(rtc)) {
		rc = PTR_ERR(rtc);
@@ -718,26 +719,19 @@ static int m41t80_probe(struct i2c_client *client,
	goto exit;

exit:
	if (rtc)
		rtc_device_unregister(rtc);
	kfree(clientdata);
	return rc;
}

static int m41t80_remove(struct i2c_client *client)
{
#ifdef CONFIG_RTC_DRV_M41T80_WDT
	struct m41t80_data *clientdata = i2c_get_clientdata(client);
	struct rtc_device *rtc = clientdata->rtc;

#ifdef CONFIG_RTC_DRV_M41T80_WDT
	if (clientdata->features & M41T80_FEATURE_HT) {
		misc_deregister(&wdt_dev);
		unregister_reboot_notifier(&wdt_notifier);
	}
#endif
	if (rtc)
		rtc_device_unregister(rtc);
	kfree(clientdata);

	return 0;
}