]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rtc: rtc-rx8025: use devm_*() functions
authorJingoo Han <jg1.han@samsung.com>
Fri, 7 Jun 2013 00:09:16 +0000 (10:09 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Jun 2013 05:43:03 +0000 (15:43 +1000)
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>
drivers/rtc/rtc-rx8025.c

index 0722d36b9c9adcdb5e112105baa0eb77a95c1ac7..8fa23eabcb68109d6636b44405cfaf9965aa6be6 100644 (file)
@@ -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 @@ errout_irq:
        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;
 }