From patchwork Mon Jan 7 04:55:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13860 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3838A23E1F for ; Mon, 7 Jan 2013 05:03:35 +0000 (UTC) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by fiordland.canonical.com (Postfix) with ESMTP id CEBACA186B2 for ; Mon, 7 Jan 2013 05:03:34 +0000 (UTC) Received: by mail-vb0-f46.google.com with SMTP id b13so18607521vby.5 for ; Sun, 06 Jan 2013 21:03:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=IJOVJ63zKD2EJpic6buCFyax0ASPc8dvBT2FwHUiIQo=; b=JBt3gp34Bu/Pfw1Vyetl91pZkxg0by9Z1wabFD88tX8nKLx/dVoCKL+KETFw81N6QH fyOyfTh+i3O7m+MleX7MxyTKzghZBzwa+a3cPbNAuwtBdAhEV6YG3PtJ+z9Apa3HfboG wXJkEZOuuFxdnmMxxdMTH2cac+/BXpgWPDNecChlbJocZVfWKlH50V6m7h2nYjleBNxq /xBO8e987j7XmJUBsZG2uEUeS9/lOGPmlm/fnwTE8LCr90CO0J0u7yftsj0hmFyARqNt OTnmrxUt7WvcFBIZIzv1VOifZDSoZil7xn8jLFRvKmpyLJKR83KWhvWjggLOVWw6Pobb h4JA== X-Received: by 10.58.247.132 with SMTP id ye4mr84937252vec.9.1357535014330; Sun, 06 Jan 2013 21:03:34 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp46182veb; Sun, 6 Jan 2013 21:03:33 -0800 (PST) X-Received: by 10.68.233.7 with SMTP id ts7mr180855689pbc.136.1357535013476; Sun, 06 Jan 2013 21:03:33 -0800 (PST) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id d3si58365152paw.273.2013.01.06.21.03.33 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Jan 2013 21:03:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pb0-f50.google.com with SMTP id wz7so10349627pbc.9 for ; Sun, 06 Jan 2013 21:03:33 -0800 (PST) X-Received: by 10.66.72.225 with SMTP id g1mr174559697pav.79.1357535013111; Sun, 06 Jan 2013 21:03:33 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id i1sm37992462pav.35.2013.01.06.21.03.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 06 Jan 2013 21:03:32 -0800 (PST) From: Sachin Kamat To: linux-serial@vger.kernel.org Cc: gregkh@linuxfoundation.org, alan@linux.intel.com, jslaby@suse.cz, shawn.guo@linaro.org, s.hauer@pengutronix.de, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 5/5] serial: imx: Use devm_* APIs Date: Mon, 7 Jan 2013 10:25:06 +0530 Message-Id: <1357534506-30206-6-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1357534506-30206-1-git-send-email-sachin.kamat@linaro.org> References: <1357534506-30206-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQkO+le+J1dtRuqiz1x3JFWpWxxEwsWFBqrG/RhMg/gqQ/O7pV+A0BW/fW/qpoRXD7FSrIG0 devm_* APIs are device managed and make cleanup and exit code simpler and easier. Cc: Shawn Guo Cc: Sascha Hauer Signed-off-by: Sachin Kamat --- drivers/tty/serial/imx.c | 32 ++++++++++---------------------- 1 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 78f7936..1a24884 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1461,7 +1461,7 @@ static int serial_imx_probe(struct platform_device *pdev) struct resource *res; struct pinctrl *pinctrl; - sport = kzalloc(sizeof(*sport), GFP_KERNEL); + sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); if (!sport) return -ENOMEM; @@ -1469,19 +1469,15 @@ static int serial_imx_probe(struct platform_device *pdev) if (ret > 0) serial_imx_probe_pdata(sport, pdev); else if (ret < 0) - goto free; + return ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - ret = -ENODEV; - goto free; - } + if (!res) + return -ENODEV; - base = ioremap(res->start, PAGE_SIZE); - if (!base) { - ret = -ENOMEM; - goto free; - } + base = devm_ioremap(&pdev->dev, res->start, PAGE_SIZE); + if (!base) + return -ENOMEM; sport->port.dev = &pdev->dev; sport->port.mapbase = res->start; @@ -1503,21 +1499,21 @@ static int serial_imx_probe(struct platform_device *pdev) if (IS_ERR(pinctrl)) { ret = PTR_ERR(pinctrl); dev_err(&pdev->dev, "failed to get default pinctrl: %d\n", ret); - goto unmap; + return ret; } sport->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); if (IS_ERR(sport->clk_ipg)) { ret = PTR_ERR(sport->clk_ipg); dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret); - goto unmap; + return ret; } sport->clk_per = devm_clk_get(&pdev->dev, "per"); if (IS_ERR(sport->clk_per)) { ret = PTR_ERR(sport->clk_per); dev_err(&pdev->dev, "failed to get per clk: %d\n", ret); - goto unmap; + return ret; } clk_prepare_enable(sport->clk_per); @@ -1546,11 +1542,6 @@ deinit: clkput: clk_disable_unprepare(sport->clk_per); clk_disable_unprepare(sport->clk_ipg); -unmap: - iounmap(sport->port.membase); -free: - kfree(sport); - return ret; } @@ -1571,9 +1562,6 @@ static int serial_imx_remove(struct platform_device *pdev) if (pdata && pdata->exit) pdata->exit(pdev); - iounmap(sport->port.membase); - kfree(sport); - return 0; }