Commit fac42b41 authored by Jingoo Han's avatar Jingoo Han Committed by Linus Torvalds

rtc: rtc-rx8025: 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 618c3003
......@@ -549,7 +549,7 @@ static int rx8025_probe(struct i2c_client *client,
goto errout;
}
rx8025 = kzalloc(sizeof(*rx8025), GFP_KERNEL);
rx8025 = devm_kzalloc(&client->dev, sizeof(*rx8025), GFP_KERNEL);
if (!rx8025) {
dev_err(&adapter->dev, "failed to alloc memory\n");
err = -ENOMEM;
......@@ -562,7 +562,7 @@ static int rx8025_probe(struct i2c_client *client,
err = rx8025_init_client(client, &need_reset);
if (err)
goto errout_free;
goto errout;
if (need_reset) {
struct rtc_time tm;
......@@ -572,12 +572,12 @@ static int rx8025_probe(struct i2c_client *client,
rx8025_set_time(&client->dev, &tm);
}
rx8025->rtc = rtc_device_register(client->name, &client->dev,
rx8025->rtc = devm_rtc_device_register(&client->dev, client->name,
&rx8025_rtc_ops, THIS_MODULE);
if (IS_ERR(rx8025->rtc)) {
err = PTR_ERR(rx8025->rtc);
dev_err(&client->dev, "unable to register the class device\n");
goto errout_free;
goto errout;
}
if (client->irq > 0) {
......@@ -586,7 +586,7 @@ static int rx8025_probe(struct i2c_client *client,
0, "rx8025", client);
if (err) {
dev_err(&client->dev, "unable to request IRQ\n");
goto errout_reg;
goto errout;
}
}
......@@ -603,12 +603,6 @@ static int rx8025_probe(struct i2c_client *client,
if (client->irq > 0)
free_irq(client->irq, client);
errout_reg:
rtc_device_unregister(rx8025->rtc);
errout_free:
kfree(rx8025);
errout:
dev_err(&adapter->dev, "probing for rx8025 failed\n");
return err;
......@@ -629,8 +623,6 @@ static int rx8025_remove(struct i2c_client *client)
}
rx8025_sysfs_unregister(&client->dev);
rtc_device_unregister(rx8025->rtc);
kfree(rx8025);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment