From patchwork Wed Sep 26 14:48:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11735 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 683F82414B for ; Wed, 26 Sep 2012 14:49:03 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id EBA29A1808B for ; Wed, 26 Sep 2012 14:49:02 +0000 (UTC) Received: by ieje10 with SMTP id e10so1541174iej.11 for ; Wed, 26 Sep 2012 07:49:02 -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=Kjam/JgFlyRQb0Xfc2pMdaKA6AxiTl4DLVagnzCC0Ic=; b=FgPdDbl5Hopg3gj4z6yynYqQGrsjQJAMCXWcJ5gZP6+3sbtuRVgOpC5MU1mSqwkRgM /K+zVH326AN/3Ry5O4BV1VUSuVfCbpZ+fMQVkR94YluS1QxM5/9Qj7kcWlv3TNuFRLts PYbeYllOA4ujF/CuG4lGoVyI+6i01U579JFzoogczEsdEv1EX3S/pDwV5VB3U3iGTKGQ NaT2vPUWOQHrURmPj2wLvHKfTP55qYc0eLYkRLEgo67GbAPpOSHz2K6DhS26aFyaFaar 6Z0bNe7fIKHCD9Nvl1P9/gRTKpgteQGWYnkXUatGeskVNwMa9/9fDlUmc2NSZLDICihW FKGQ== Received: by 10.50.160.165 with SMTP id xl5mr1869793igb.0.1348670942294; Wed, 26 Sep 2012 07:49:02 -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.50.184.232 with SMTP id ex8csp360019igc; Wed, 26 Sep 2012 07:49:01 -0700 (PDT) Received: by 10.14.193.129 with SMTP id k1mr1644963een.13.1348670938926; Wed, 26 Sep 2012 07:48:58 -0700 (PDT) Received: from eu1sys200aog106.obsmtp.com (eu1sys200aog106.obsmtp.com [207.126.144.121]) by mx.google.com with SMTP id o42si2869884eep.131.2012.09.26.07.48.49 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 07:48:58 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.121; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.121 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 eu1sys200aob106.postini.com ([207.126.147.11]) with SMTP ID DSNKUGMV0fPRnimL2cVZEjhcVR+rMhVxQcWa@postini.com; Wed, 26 Sep 2012 14:48:58 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 20C9A41; Wed, 26 Sep 2012 14:48:12 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 7767B48; Wed, 26 Sep 2012 10:38:18 +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 79D5624C2C0; Wed, 26 Sep 2012 16:48:34 +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; Wed, 26 Sep 2012 16:48:41 +0200 From: Linus Walleij To: Grant Likely , Mark Brown , Cc: Anmar Oueja , Linus Walleij Subject: [PATCH] spi/pl022: use more managed resources Date: Wed, 26 Sep 2012 16:48:36 +0200 Message-ID: <1348670916-26267-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm3LE0WiK8Z2kIKY6KDFFNewgZ6n6fS8R2F9eaBcKvKyAAoC3jmcau1XqaxSjBrVEUaQyHV This switches the PL022 SPI driver to use devm_* managed resources for IRQ, clocks, ioremap and GPIO. Prior to this, the GPIOs would even leak. Signed-off-by: Linus Walleij --- drivers/spi/spi-pl022.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index f8568b4..15737bc 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1,7 +1,7 @@ /* * A driver for the ARM PL022 PrimeCell SSP/SPI bus master. * - * Copyright (C) 2008-2009 ST-Ericsson AB + * Copyright (C) 2008-2012 ST-Ericsson AB * Copyright (C) 2006 STMicroelectronics Pvt. Ltd. * * Author: Linus Walleij @@ -2074,24 +2074,21 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) if (!platform_info) { dev_err(dev, "probe: no platform data defined\n"); - status = -ENODEV; - goto err_no_pdata; + return -ENODEV; } if (platform_info->num_chipselect) { num_cs = platform_info->num_chipselect; } else { dev_err(dev, "probe: no chip select defined\n"); - status = -ENODEV; - goto err_no_pdata; + return -ENODEV; } /* Allocate master with space for data */ master = spi_alloc_master(dev, sizeof(struct pl022)); if (master == NULL) { dev_err(&adev->dev, "probe - cannot alloc SPI master\n"); - status = -ENOMEM; - goto err_no_master; + return -ENOMEM; } pl022 = spi_master_get_devdata(master); @@ -2153,7 +2150,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) pl022->chipselects[i] = cs_gpio; if (gpio_is_valid(cs_gpio)) { - if (gpio_request(cs_gpio, "ssp-pl022")) + if (devm_gpio_request(dev, cs_gpio, "ssp-pl022")) dev_err(&adev->dev, "could not request %d gpio\n", cs_gpio); @@ -2180,7 +2177,8 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) goto err_no_ioregion; pl022->phybase = adev->res.start; - pl022->virtbase = ioremap(adev->res.start, resource_size(&adev->res)); + pl022->virtbase = devm_ioremap(dev, adev->res.start, + resource_size(&adev->res)); if (pl022->virtbase == NULL) { status = -ENOMEM; goto err_no_ioremap; @@ -2190,7 +2188,7 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) pm_runtime_resume(dev); - pl022->clk = clk_get(&adev->dev, NULL); + pl022->clk = devm_clk_get(&adev->dev, NULL); if (IS_ERR(pl022->clk)) { status = PTR_ERR(pl022->clk); dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n"); @@ -2218,8 +2216,8 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) SSP_CR1(pl022->virtbase)); load_ssp_default_config(pl022); - status = request_irq(adev->irq[0], pl022_interrupt_handler, 0, "pl022", - pl022); + status = devm_request_irq(dev, adev->irq[0], pl022_interrupt_handler, + 0, "pl022", pl022); if (status < 0) { dev_err(&adev->dev, "probe - cannot get IRQ (%d)\n", status); goto err_no_irq; @@ -2259,24 +2257,18 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) err_spi_register: if (platform_info->enable_dma) pl022_dma_remove(pl022); - - free_irq(adev->irq[0], pl022); err_no_irq: clk_disable(pl022->clk); err_no_clk_en: clk_unprepare(pl022->clk); err_clk_prep: - clk_put(pl022->clk); err_no_clk: - iounmap(pl022->virtbase); err_no_ioremap: amba_release_regions(adev); err_no_ioregion: err_no_gpio: err_no_pinctrl: spi_master_put(master); - err_no_master: - err_no_pdata: return status; } @@ -2298,12 +2290,9 @@ pl022_remove(struct amba_device *adev) if (pl022->master_info->enable_dma) pl022_dma_remove(pl022); - free_irq(adev->irq[0], pl022); clk_disable(pl022->clk); clk_unprepare(pl022->clk); - clk_put(pl022->clk); pm_runtime_disable(&adev->dev); - iounmap(pl022->virtbase); amba_release_regions(adev); tasklet_disable(&pl022->pump_transfers); spi_unregister_master(pl022->master);