From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device()
and devm_rtc_register_device() pair instead.

While at it: remove unnecessary goto label.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
 drivers/rtc/rtc-bq4802.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c
index 472e75668917..4661dfbddb17 100644
--- a/drivers/rtc/rtc-bq4802.c
+++ b/drivers/rtc/rtc-bq4802.c
@@ -145,16 +145,15 @@ static int bq4802_probe(struct platform_device *pdev)
        int err = -ENOMEM;
 
        if (!p)
-               goto out;
+               return err;
 
        spin_lock_init(&p->lock);
 
        p->r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!p->r) {
                p->r = platform_get_resource(pdev, IORESOURCE_IO, 0);
-               err = -EINVAL;
                if (!p->r)
-                       goto out;
+                       return -EINVAL;
        }
        if (p->r->flags & IORESOURCE_IO) {
                p->ioport = p->r->start;
@@ -163,29 +162,24 @@ static int bq4802_probe(struct platform_device *pdev)
        } else if (p->r->flags & IORESOURCE_MEM) {
                p->regs = devm_ioremap(&pdev->dev, p->r->start,
                                        resource_size(p->r));
-               if (!p->regs){
-                       err = -ENOMEM;
-                       goto out;
-               }
+               if (!p->regs)
+                       return -ENOMEM;
+
                p->read = bq4802_read_mem;
                p->write = bq4802_write_mem;
        } else {
-               err = -EINVAL;
-               goto out;
+               return -EINVAL;
        }
 
        platform_set_drvdata(pdev, p);
 
-       p->rtc = devm_rtc_device_register(&pdev->dev, "bq4802",
-                                       &bq4802_ops, THIS_MODULE);
-       if (IS_ERR(p->rtc)) {
-               err = PTR_ERR(p->rtc);
-               goto out;
-       }
+       p->rtc = devm_rtc_allocate_device(&pdev->dev);
+       if (IS_ERR(p->rtc))
+               return PTR_ERR(p->rtc);
+
+       p->rtc->ops = &bq4802_ops;
 
-       err = 0;
-out:
-       return err;
+       return devm_rtc_register_device(p->rtc);
 
 }
 
-- 
2.29.1

Reply via email to