From patchwork Wed Jun 25 00:43:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 4415431 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6AFE39F402 for ; Wed, 25 Jun 2014 00:44:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 818372037B for ; Wed, 25 Jun 2014 00:44:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7BB4F201EF for ; Wed, 25 Jun 2014 00:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752853AbaFYAoU (ORCPT ); Tue, 24 Jun 2014 20:44:20 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:33785 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752612AbaFYAoT (ORCPT ); Tue, 24 Jun 2014 20:44:19 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5P0i1XQ008564; Tue, 24 Jun 2014 19:44:01 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5P0i0TR032697; Tue, 24 Jun 2014 19:44:00 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 24 Jun 2014 19:44:00 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5P0i01x011396; Tue, 24 Jun 2014 19:44:00 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.71.175]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s5P0i0t21937; Tue, 24 Jun 2014 19:44:00 -0500 (CDT) From: Suman Anna To: Tony Lindgren CC: Dave Gerlach , Jassi Brar , , , Suman Anna Subject: [PATCH 1/7] mailbox/omap: use devm_* interfaces Date: Tue, 24 Jun 2014 19:43:37 -0500 Message-ID: <1403657023-53897-2-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1403657023-53897-1-git-send-email-s-anna@ti.com> References: <1403657023-53897-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the various devm_ interfaces to simplify the cleanup in probe and remove functions in OMAP2+ mailbox driver. Signed-off-by: Suman Anna --- drivers/mailbox/mailbox-omap2.c | 64 ++++++++++++----------------------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/drivers/mailbox/mailbox-omap2.c b/drivers/mailbox/mailbox-omap2.c index 42d2b89..75fbc90 100644 --- a/drivers/mailbox/mailbox-omap2.c +++ b/drivers/mailbox/mailbox-omap2.c @@ -236,23 +236,24 @@ static int omap2_mbox_probe(struct platform_device *pdev) } /* allocate one extra for marking end of list */ - list = kzalloc((pdata->info_cnt + 1) * sizeof(*list), GFP_KERNEL); + list = devm_kzalloc(&pdev->dev, (pdata->info_cnt + 1) * sizeof(*list), + GFP_KERNEL); if (!list) return -ENOMEM; - mboxblk = mbox = kzalloc(pdata->info_cnt * sizeof(*mbox), GFP_KERNEL); - if (!mboxblk) { - ret = -ENOMEM; - goto free_list; - } + mboxblk = devm_kzalloc(&pdev->dev, pdata->info_cnt * sizeof(*mbox), + GFP_KERNEL); + if (!mboxblk) + return -ENOMEM; - privblk = priv = kzalloc(pdata->info_cnt * sizeof(*priv), GFP_KERNEL); - if (!privblk) { - ret = -ENOMEM; - goto free_mboxblk; - } + privblk = devm_kzalloc(&pdev->dev, pdata->info_cnt * sizeof(*priv), + GFP_KERNEL); + if (!privblk) + return -ENOMEM; info = pdata->info; + mbox = mboxblk; + priv = privblk; for (i = 0; i < pdata->info_cnt; i++, info++, priv++) { priv->tx_fifo.msg = MAILBOX_MESSAGE(info->tx_id); priv->tx_fifo.fifo_stat = MAILBOX_FIFOSTATUS(info->tx_id); @@ -276,55 +277,28 @@ static int omap2_mbox_probe(struct platform_device *pdev) mbox->name = info->name; mbox->ops = &omap2_mbox_ops; mbox->irq = platform_get_irq(pdev, info->irq_id); - if (mbox->irq < 0) { - ret = mbox->irq; - goto free_privblk; - } + if (mbox->irq < 0) + return mbox->irq; list[i] = mbox++; } mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem) { - ret = -ENOENT; - goto free_privblk; - } - - mbox_base = ioremap(mem->start, resource_size(mem)); - if (!mbox_base) { - ret = -ENOMEM; - goto free_privblk; - } + mbox_base = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(mbox_base)) + return PTR_ERR(mbox_base); ret = omap_mbox_register(&pdev->dev, list); if (ret) - goto unmap_mbox; + return ret; + platform_set_drvdata(pdev, list); return 0; - -unmap_mbox: - iounmap(mbox_base); -free_privblk: - kfree(privblk); -free_mboxblk: - kfree(mboxblk); -free_list: - kfree(list); - return ret; } static int omap2_mbox_remove(struct platform_device *pdev) { - struct omap_mbox2_priv *privblk; - struct omap_mbox **list = platform_get_drvdata(pdev); - struct omap_mbox *mboxblk = list[0]; - - privblk = mboxblk->priv; omap_mbox_unregister(); - iounmap(mbox_base); - kfree(privblk); - kfree(mboxblk); - kfree(list); return 0; }