rtc: rtc-test: use devm_rtc_device_register()
devm_rtc_device_register() is device managed and makes 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:
parent
cc40d642f8
commit
dd8d8137f5
@ -99,8 +99,10 @@ static DEVICE_ATTR(irq, S_IRUGO | S_IWUSR, test_irq_show, test_irq_store);
|
|||||||
static int test_probe(struct platform_device *plat_dev)
|
static int test_probe(struct platform_device *plat_dev)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct rtc_device *rtc = rtc_device_register("test", &plat_dev->dev,
|
struct rtc_device *rtc;
|
||||||
&test_rtc_ops, THIS_MODULE);
|
|
||||||
|
rtc = devm_rtc_device_register(&plat_dev->dev, "test",
|
||||||
|
&test_rtc_ops, THIS_MODULE);
|
||||||
if (IS_ERR(rtc)) {
|
if (IS_ERR(rtc)) {
|
||||||
err = PTR_ERR(rtc);
|
err = PTR_ERR(rtc);
|
||||||
return err;
|
return err;
|
||||||
@ -115,15 +117,11 @@ static int test_probe(struct platform_device *plat_dev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
rtc_device_unregister(rtc);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_remove(struct platform_device *plat_dev)
|
static int test_remove(struct platform_device *plat_dev)
|
||||||
{
|
{
|
||||||
struct rtc_device *rtc = platform_get_drvdata(plat_dev);
|
|
||||||
|
|
||||||
rtc_device_unregister(rtc);
|
|
||||||
device_remove_file(&plat_dev->dev, &dev_attr_irq);
|
device_remove_file(&plat_dev->dev, &dev_attr_irq);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user