From patchwork Tue Apr 2 06:24:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 232894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pb0-f64.google.com (mail-pb0-f64.google.com [209.85.160.64]) (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 994532C00E1 for ; Tue, 2 Apr 2013 17:37:29 +1100 (EST) Received: by mail-pb0-f64.google.com with SMTP id un15sf38739pbc.29 for ; Mon, 01 Apr 2013 23:37:27 -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=IKwQjQuMGzJOiW52XPVlekS8t89oA49A3ZIQjpc9hnQ=; b=M4KsFG+MSb5O2ERN40RlQdz5DSD7ydKN2KGgzQfQZWOh1QJnOv0HZmiNMVrD86hsHM BTKbkFx//2g9pYqyBzLCvoO3FVOb1fmxqhP9S60ijlu9ubvgdR5MkaJALID1oYMGYq9d ccx0odFlLDNExl/oOFL8fXSlIqChQqdl3Sg+dK4tCNtW4xs+VaK/my5U1TOiAPu7Y8L6 PQVklErjcGLuMhscQ/yGzOawGrqL3RFIUwZNdVrngrycIA9E4qhezIg0MRP/yXX1q+hJ JzQcExhK3L+26JcHNLPRmc6lUQx4qI71bufs2Yzv1WRAtMNpNNUkB++dkBtBoquzTxXs ujDQ== 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=IKwQjQuMGzJOiW52XPVlekS8t89oA49A3ZIQjpc9hnQ=; b=QaFqhsRDDphyvQrP5loTxvBRaaBK7x0EEP7nNhNNWT9/UpdZJ92gfdOnuygMOlm3ZF L+ZDAfr+QQtyy1dRupAiiPoVgWBLtVOSaAeoeeE68kRyFh9KauRkJaIh6s3Z2ocYfwq5 Bl/ouiIttw51eNywoSD69751NngIUI0PBDQt9NEWTHHeVz0VhlKoFfXMCPvsJe/DdFS4 hj0+h4GeNmGm4fASpfXuJ0vhWrmX8gsRdJTNam7ue0r/GdWDNmzc97mT6sQcSURNuVm0 Db4+cy/j+5M8zEtIcssFZf3QUVyfbFbw33uI0Lm4xq2gyOcX76/87D463jqY2jm7yeQq lzUA== X-Received: by 10.50.160.132 with SMTP id xk4mr1092247igb.7.1364884647216; Mon, 01 Apr 2013 23:37:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.95.198 with SMTP id dm6ls1555867igb.16.canary; Mon, 01 Apr 2013 23:37:26 -0700 (PDT) X-Received: by 10.66.120.207 with SMTP id le15mr2402917pab.20.1364884646916; Mon, 01 Apr 2013 23:37:26 -0700 (PDT) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by gmr-mx.google.com with ESMTPS id rs16si131320pac.1.2013.04.01.23.37.26 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 23:37:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.173 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.192.173; Received: by mail-pd0-f173.google.com with SMTP id v10so65799pde.32 for ; Mon, 01 Apr 2013 23:37:26 -0700 (PDT) X-Received: by 10.66.20.36 with SMTP id k4mr22991924pae.176.1364884646777; Mon, 01 Apr 2013 23:37:26 -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.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 23:37:26 -0700 (PDT) From: Sachin Kamat To: rtc-linux@googlegroups.com Cc: a.zummo@towertech.it, akpm@linux-foundation.org, sachin.kamat@linaro.org, Scott Wood Subject: [rtc-linux] [PATCH 4/8] drivers/rtc/rtc-ds1374.c: Use devm_* APIs Date: Tue, 2 Apr 2013 11:54:51 +0530 Message-Id: <1364883895-20865-4-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: ALoCoQliKkDVK4vQsID16eCJm6dKALXfywX3lDV9M30RVBt3bPVFSJDyaWuD4UNE4W2uahWvP35a X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.192.173 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: Scott Wood --- drivers/rtc/rtc-ds1374.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 67cd1e3..94366e1 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c @@ -347,7 +347,7 @@ static int ds1374_probe(struct i2c_client *client, struct ds1374 *ds1374; int ret; - ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL); + ds1374 = devm_kzalloc(&client->dev, sizeof(struct ds1374), GFP_KERNEL); if (!ds1374) return -ENOMEM; @@ -359,36 +359,27 @@ static int ds1374_probe(struct i2c_client *client, ret = ds1374_check_rtc_status(client); if (ret) - goto out_free; + return ret; if (client->irq > 0) { - ret = request_irq(client->irq, ds1374_irq, 0, + ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0, "ds1374", client); if (ret) { dev_err(&client->dev, "unable to request IRQ\n"); - goto out_free; + return ret; } device_set_wakeup_capable(&client->dev, 1); } - ds1374->rtc = rtc_device_register(client->name, &client->dev, + ds1374->rtc = devm_rtc_device_register(&client->dev, client->name, &ds1374_rtc_ops, THIS_MODULE); if (IS_ERR(ds1374->rtc)) { - ret = PTR_ERR(ds1374->rtc); dev_err(&client->dev, "unable to register the class device\n"); - goto out_irq; + return PTR_ERR(ds1374->rtc); } return 0; - -out_irq: - if (client->irq > 0) - free_irq(client->irq, client); - -out_free: - kfree(ds1374); - return ret; } static int ds1374_remove(struct i2c_client *client) @@ -400,12 +391,10 @@ static int ds1374_remove(struct i2c_client *client) ds1374->exiting = 1; mutex_unlock(&ds1374->mutex); - free_irq(client->irq, client); + devm_free_irq(&client->dev, client->irq, client); cancel_work_sync(&ds1374->work); } - rtc_device_unregister(ds1374->rtc); - kfree(ds1374); return 0; }