From patchwork Tue Apr 2 06:24:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 232895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qc0-x23d.google.com (mail-qc0-x23d.google.com [IPv6:2607:f8b0:400d:c01::23d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4D25A2C00D9 for ; Tue, 2 Apr 2013 17:37:37 +1100 (EST) Received: by mail-qc0-f189.google.com with SMTP id c11sf36344qca.16 for ; Mon, 01 Apr 2013 23:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-google-group-id :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=87seSBkoUi/W397TxV9KlKb3+oT3BYYnEcvSZXQwyf4=; b=Qhlg9jNsH30wvyH7YeT2Euq6UOtOJA15EZxrsqGeX2et7LANX1sCsw+Sn1IwFcjggQ CPTDz8jY1nxOez9j7O2D69+/kIkO9S8XZI6o95xiGiC7K+qcteyR1PiEC7ZkXG4Epl5A XIpFEbSd6BaU3h31oZgC9lPvmsmqCQt/KqxfAOXI1fdtlqHu7o/OAcOpyVK2LDWKP7Oy ajS9BtS4x3+v7xa8detUJqCox2EzRM52skDM5zgjDDyYD3KPlfQKhBsizuYkYZ4DmvtX ip8puAGJh/Zc3XDtO63l4PcTBQvRlqq1phHvaRB7DiMzzOqiSqHHLqlorw2YYUymOxWH EK6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=87seSBkoUi/W397TxV9KlKb3+oT3BYYnEcvSZXQwyf4=; b=dJYUhPfLJ2NjTqFJXYfk7PqGW57VrriSkQ4jzuZhKOREs+w3Jl6d5k7epfliI/vBSN oQweD9lOtQ0xVdDTo1YYNQHybPCA3jxrX7nmYmYwlqfycwiEJB/vDxUXKOhW2nQLpn9b AyKsNPOlOciWw97wzdxkHkA49hYJB/3SC6DlxgGfwW3JRRyg0Paz4ySKKhd6DAsJmKDs UAfDc+S8rdIvNixPRbTTWxRO7j2HYRi9zgo9q+6bP3fgKyNur/qIcD7dVt2EhoPhiRHC E9hmf/bck0HoDfsP6n6EJ4+Ftx2ADBnjSeUO1UJt1HgaiOT+1/14w7E5sCYkvftnCoWK pj4g== X-Received: by 10.50.150.166 with SMTP id uj6mr1092078igb.1.1364884654171; Mon, 01 Apr 2013 23:37:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.203.70 with SMTP id ko6ls1541234igc.36.canary; Mon, 01 Apr 2013 23:37:33 -0700 (PDT) X-Received: by 10.66.242.197 with SMTP id ws5mr2672992pac.32.1364884653917; Mon, 01 Apr 2013 23:37:33 -0700 (PDT) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by gmr-mx.google.com with ESMTPS id yl6si73882pbc.2.2013.04.01.23.37.33 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 23:37:33 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.49 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.49; Received: by mail-pa0-f49.google.com with SMTP id kp14so120276pab.22 for ; Mon, 01 Apr 2013 23:37:33 -0700 (PDT) X-Received: by 10.66.216.198 with SMTP id os6mr22801935pac.145.1364884653754; Mon, 01 Apr 2013 23:37:33 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPS id fc8sm1020265pad.21.2013.04.01.23.37.27 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 23:37:33 -0700 (PDT) From: Sachin Kamat To: rtc-linux@googlegroups.com Cc: a.zummo@towertech.it, akpm@linux-foundation.org, sachin.kamat@linaro.org, Srikanth Srinivasan Subject: [rtc-linux] [PATCH 5/8] drivers/rtc/rtc-ds3232.c: Use devm_* APIs Date: Tue, 2 Apr 2013 11:54:52 +0530 Message-Id: <1364883895-20865-5-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1364883895-20865-1-git-send-email-sachin.kamat@linaro.org> References: <1364883895-20865-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQlAzxNfkPfMtQQxqT39RB78GnccQBj9489gWS1XSiI5SkTYDKBEbiuUxKwi5D7CSHWGQee/ X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.220.49 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , devm_* functions are device managed and make cleanup code simpler. Signed-off-by: Sachin Kamat Cc: Srikanth Srinivasan --- drivers/rtc/rtc-ds3232.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index db0ca08..b83bb5a5 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c @@ -397,7 +397,7 @@ static int ds3232_probe(struct i2c_client *client, struct ds3232 *ds3232; int ret; - ds3232 = kzalloc(sizeof(struct ds3232), GFP_KERNEL); + ds3232 = devm_kzalloc(&client->dev, sizeof(struct ds3232), GFP_KERNEL); if (!ds3232) return -ENOMEM; @@ -409,34 +409,25 @@ static int ds3232_probe(struct i2c_client *client, ret = ds3232_check_rtc_status(client); if (ret) - goto out_free; + return ret; - ds3232->rtc = rtc_device_register(client->name, &client->dev, + ds3232->rtc = devm_rtc_device_register(&client->dev, client->name, &ds3232_rtc_ops, THIS_MODULE); if (IS_ERR(ds3232->rtc)) { - ret = PTR_ERR(ds3232->rtc); dev_err(&client->dev, "unable to register the class device\n"); - goto out_irq; + return PTR_ERR(ds3232->rtc); } if (client->irq >= 0) { - ret = request_irq(client->irq, ds3232_irq, 0, + ret = devm_request_irq(&client->dev, client->irq, ds3232_irq, 0, "ds3232", client); if (ret) { dev_err(&client->dev, "unable to request IRQ\n"); - goto out_free; + return ret; } } return 0; - -out_irq: - if (client->irq >= 0) - free_irq(client->irq, client); - -out_free: - kfree(ds3232); - return ret; } static int ds3232_remove(struct i2c_client *client) @@ -448,12 +439,10 @@ static int ds3232_remove(struct i2c_client *client) ds3232->exiting = 1; mutex_unlock(&ds3232->mutex); - free_irq(client->irq, client); + devm_free_irq(&client->dev, client->irq, client); cancel_work_sync(&ds3232->work); } - rtc_device_unregister(ds3232->rtc); - kfree(ds3232); return 0; }