From patchwork Sun Jun 17 13:44:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9364 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 D2F4723EE2 for ; Sun, 17 Jun 2012 13:45:05 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 92909A1826B for ; Sun, 17 Jun 2012 13:45:05 +0000 (UTC) Received: by mail-ob0-f180.google.com with SMTP id un3so7851061obb.11 for ; Sun, 17 Jun 2012 06:45:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=bsb+Vi6HUfajGFIoPJv3zdSJ/8mx/Kc1pgMQhekWj4g=; b=TPtiFf7Uru/ACJ2KE1wWXjq19AeaqM57Pj1DFCIiLgXEOZND+7w4hLlg7CG4WOB9Jz fMXPhqWYD8KEyVZ2rG7ivNawN82PH6MALLNJmwpR/sirGpfO41/ufpk82sidxiAoZtvG ONrLivmOi7bUIFfWoa7wmek9Rflq6i1rCg6kYV48IWIcP54fD6KHt0UhE6nA0wGLUIRa xEtveiaQb09VqRJVRHWTle4RmyeSuy5Q+lyhpn5X/InBkQEeU/bZ4wDnYHsTnkaq+1Aj DQ34Plbb5OIXPjGVFftTY+/rv2Vw5V7mCcB0PKpJwSx0k3ltzsVVrDUys5W6TxghGO8B YRsg== Received: by 10.50.87.227 with SMTP id bb3mr6079649igb.57.1339940705249; Sun, 17 Jun 2012 06:45:05 -0700 (PDT) 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.231.24.148 with SMTP id v20csp22743ibb; Sun, 17 Jun 2012 06:45:04 -0700 (PDT) Received: by 10.14.99.6 with SMTP id w6mr2777371eef.70.1339940704002; Sun, 17 Jun 2012 06:45:04 -0700 (PDT) Received: from eu1sys200aog108.obsmtp.com (eu1sys200aog108.obsmtp.com. [207.126.144.125]) by mx.google.com with SMTP id x9si7067209eea.140.2012.06.17.06.44.59 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jun 2012 06:45:03 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.125 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKT93fWjT3igbtnlwBDBlua3BKeUWOYLcS@postini.com; Sun, 17 Jun 2012 13:45:03 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 33ED140; Sun, 17 Jun 2012 13:43:52 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 7CA4A48; Sun, 17 Jun 2012 10:52:07 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 22D1D24C2F4; Sun, 17 Jun 2012 15:44:06 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Sun, 17 Jun 2012 15:44:13 +0200 From: Linus Walleij To: Greg Kroah-Hartman , Cc: , Linus Walleij Subject: [PATCH 1/2] serial/amba-pl011: use devm_* allocators Date: Sun, 17 Jun 2012 15:44:08 +0200 Message-ID: <1339940648-6847-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkBiwncP6v5lP6d263v2NCVvhfZ4dTfQyAMXCm5heVP1f2O8FeGnNN5O+Rzm+UmrWnThbo/ From: Linus Walleij This switches a bunch of allocation and remapping to use the devm_* garbage collected methods and cleans up the error path and remove() paths consequently. devm_ioremap() is only in so fix up the erroneous include as well. Signed-off-by: Linus Walleij --- drivers/tty/serial/amba-pl011.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index c17923e..3ce984f 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -53,8 +53,8 @@ #include #include #include +#include -#include #include #define UART_NR 14 @@ -1885,22 +1885,24 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) goto out; } - uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL); + uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port), + GFP_KERNEL); if (uap == NULL) { ret = -ENOMEM; goto out; } - base = ioremap(dev->res.start, resource_size(&dev->res)); + base = devm_ioremap(&dev->dev, dev->res.start, + resource_size(&dev->res)); if (!base) { ret = -ENOMEM; - goto free; + goto out; } uap->pinctrl = devm_pinctrl_get(&dev->dev); if (IS_ERR(uap->pinctrl)) { ret = PTR_ERR(uap->pinctrl); - goto unmap; + goto out; } uap->pins_default = pinctrl_lookup_state(uap->pinctrl, PINCTRL_STATE_DEFAULT); @@ -1915,7 +1917,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) uap->clk = clk_get(&dev->dev, NULL); if (IS_ERR(uap->clk)) { ret = PTR_ERR(uap->clk); - goto unmap; + goto out; } uap->vendor = vendor; @@ -1950,10 +1952,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id) amba_ports[i] = NULL; pl011_dma_remove(uap); clk_put(uap->clk); - unmap: - iounmap(base); - free: - kfree(uap); } out: return ret; @@ -1973,9 +1971,7 @@ static int pl011_remove(struct amba_device *dev) amba_ports[i] = NULL; pl011_dma_remove(uap); - iounmap(uap->port.membase); clk_put(uap->clk); - kfree(uap); return 0; }