From patchwork Thu Jan 10 02:04:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 1958331 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id 75CCE40232 for ; Thu, 10 Jan 2013 02:04:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Tt7VW-0007fR-Ln; Thu, 10 Jan 2013 02:04:38 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Tt7VU-0007fG-FL for spi-devel-general@lists.sourceforge.net; Thu, 10 Jan 2013 02:04:36 +0000 X-ACL-Warn: Received: from mailout2.samsung.com ([203.254.224.25]) by sog-mx-2.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1Tt7VQ-0004Vp-MC for spi-devel-general@lists.sourceforge.net; Thu, 10 Jan 2013 02:04:36 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGE00IIB0D4OKJ0@mailout2.samsung.com> for spi-devel-general@lists.sourceforge.net; Thu, 10 Jan 2013 11:04:22 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.49]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 1E.E7.12699.6A12EE05; Thu, 10 Jan 2013 11:04:22 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-be-50ee21a61248 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id ED.E7.12699.5A12EE05; Thu, 10 Jan 2013 11:04:22 +0900 (KST) Received: from DOJG1HAN02 ([12.23.120.99]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MGE0066W0F9UU10@mmp1.samsung.com> for spi-devel-general@lists.sourceforge.net; Thu, 10 Jan 2013 11:04:21 +0900 (KST) From: Jingoo Han To: 'Grant Likely' References: In-reply-to: Subject: [PATCH v2] spi: s3c64xx: Use devm_clk_get() and devm_request_irq() Date: Thu, 10 Jan 2013 11:04:21 +0900 Message-id: <007301cdeed6$ce83f960$6b8bec20$%han@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac3uAz/utiS4ItQFSZSV37Zya3Mi4AA03qXw Content-language: ko x-cr-hashedpuzzle: AMqY AXiy EdYu G3ND Hz3n H9PT IPn4 MiEO OY/N S7nO WPUO WPVe dEGY dZhS fr1S gYzZ; 3; ZwByAGEAbgB0AC4AbABpAGsAZQBsAHkAQABzAGUAYwByAGUAdABsAGEAYgAuAGMAYQA7AGoAZwAxAC4AaABhAG4AQABzAGEAbQBzAHUAbgBnAC4AYwBvAG0AOwBzAHAAaQAtAGQAZQB2AGUAbAAtAGcAZQBuAGUAcgBhAGwAQABsAGkAcwB0AHMALgBzAG8AdQByAGMAZQBmAG8AcgBnAGUALgBuAGUAdAA=; Sosha1_v1; 7; {9997A2BB-AD1D-4103-A3CD-73B124EB146D}; agBnADEALgBoAGEAbgBAAHMAYQBtAHMAdQBuAGcALgBjAG8AbQA=; Thu, 10 Jan 2013 02:04:17 GMT; WwBQAEEAVABDAEgAIAB2ADIAXQAgAHMAcABpADoAIABzADMAYwA2ADQAeAB4ADoAIABVAHMAZQAgAGQAZQB2AG0AXwBjAGwAawBfAGcAZQB0ACgAKQAgAGEAbgBkACAAZABlAHYAbQBfAHIAZQBxAHUAZQBzAHQAXwBpAHIAcQAoACkA x-cr-puzzleid: {9997A2BB-AD1D-4103-A3CD-73B124EB146D} DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrHIsWRmVeSWpSXmKPExsVy+t8zQ91liu8CDBomsVscmdLI7sDosXvB Z6YAxigum5TUnMyy1CJ9uwSujJuHDrIU7JatOP3sN2MD40fxLkZODgkBE4mf78+yQNhiEhfu rWfrYuTiEBJYxiixf81c1i5GDrCi+ZdjIeKLGCW2XFrHBFXEJPFp43UmkG42ATWJL18Os4PY IgJ6EjcudDCC2MwC/hJPb24CGyQkwC2xujkIJMwpwCOx7k8nM4gtLOAtsb63CcxmEVCVmLjj FNhIXgFbiembVrFC2IISPybfY4EYqSWxfudxJghbXmLzmrfMEHeqSzz6qwtxgZHEwyP/2SFK RCT2vXjHCHKyhEAHq8Tm63eg6k0lLk9jhFgrIPFt8iEWiLCsxKYDzBDl+9glzi/dxAwJH0mJ gytusExglJqF5KJZSC6aheSiWUhWL2BkWcUomlqQXFCclJ5rpFecmFtcmpeul5yfu4kREonS OxhXNVgcYhTgYFTi4WX0fBsgxJpYVlyZe4hRgoNZSYQ3ZDtQiDclsbIqtSg/vqg0J7X4EKMP 0OUTmaVEk/OBSSKvJN7Q2NjEzMTUxNzS1NwUh7CSOC/jqScBQgLpiSWp2ampBalFMOOYODil GhjXzOQ0NVVa+eRYw24FscKEu48PSDjem+fg21C3XVDmeebeesMpXH/eKWk8TtBseftYe1XI 4RshL7OurP/3kNE/ofq036STah/Ph566Zm5yhXPxytLTjxolTr6ZwW9aNNmvYIGjcPCThLOO 9xbMf2by01nu/pV94Rq+jSunNImI7b27QX7Z3o1pSizFGYmGWsxFxYkAy4DP9vECAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42I5/e+xgO4yxXcBBtu6mC2OTGlkd2D02L3g M1MAY1QDo01GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO 0FglhbLEnFKgUEBicbGSvh2mCaEhbroWMI0Rur4hQXA9RgZoIGEdY8bNQwdZCnbLVpx+9pux gfGjeBcjB4eEgInE/MuxXYycQKaYxIV769m6GLk4hAQWMUpsubSOCcJZxiTxaeN1JpAqNgE1 iS9fDrOD2CICehI3LnQwgtjMAv4ST29uYgUZKiTALbG6OQgkzCnAI7HuTycziC0s4C2xvrcJ zGYRUJWYuOMU2EheAVuJ6ZtWsULYghI/Jt9jgRipJbF+53EmCFteYvOat8wQN6tLPPqrC3GB kcTDI//ZIUpEJPa9eMcIcrKEQAerxObrd6DqTSUuT2OcwCgyC8mGWUg2zEKyYRaSUQsYWVYx iqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBMf5M+kdjKsaLA4xCnAwKvHwMnq+DRBiTSwrrsw9 xCjBwawkwhuyHSjEm5JYWZValB9fVJqTWnyI0QcYABOZpUST84EpKK8k3tDYxMzI0sjMwsjE 3ByHsJI4L+OpJwFCAumJJanZqakFqUUw45g4OKUaGE1s+m+muM8yeGDzpb/P7f5ljnMz5S9c iS6qn7tv8+6DFXNT5aJinBs2ZFfGqp+YcunG4z0zNS+3T+WcW5JvqhYr4btz9q+nFd8FVmUv W7vr1TuWiKbw1WU8cW7qLzutHm7Ni6uI/ddwnY3l5EQRzxM3mlfrzjs1dZXASqG/FpvXi0um MZkJXFdiKc5INNRiLipOBADG8jD2IAMAAA== X-CFilter-Loop: Reflected X-Spam-Score: 0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1Tt7VQ-0004Vp-MC Cc: spi-devel-general@lists.sourceforge.net, 'Jingoo Han' X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net Use devm_clk_get() and devm_request_irq() rather than clk_get() and request_irq() to make cleanup paths more simple. Signed-off-by: Jingoo Han --- Changes since v1: - modified the commit message drivers/spi/spi-s3c64xx.c | 41 +++++++++++++++-------------------------- 1 files changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 6495352..55369b1 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1282,7 +1282,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) if (sdd->regs == NULL) { dev_err(&pdev->dev, "Unable to remap IO\n"); ret = -ENXIO; - goto err1; + goto err0; } if (!sci->cfg_gpio && pdev->dev.of_node) { @@ -1291,36 +1291,36 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) } else if (sci->cfg_gpio == NULL || sci->cfg_gpio()) { dev_err(&pdev->dev, "Unable to config gpio\n"); ret = -EBUSY; - goto err2; + goto err0; } /* Setup clocks */ - sdd->clk = clk_get(&pdev->dev, "spi"); + sdd->clk = devm_clk_get(&pdev->dev, "spi"); if (IS_ERR(sdd->clk)) { dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); ret = PTR_ERR(sdd->clk); - goto err3; + goto err1; } if (clk_prepare_enable(sdd->clk)) { dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); ret = -EBUSY; - goto err4; + goto err1; } sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); - sdd->src_clk = clk_get(&pdev->dev, clk_name); + sdd->src_clk = devm_clk_get(&pdev->dev, clk_name); if (IS_ERR(sdd->src_clk)) { dev_err(&pdev->dev, "Unable to acquire clock '%s'\n", clk_name); ret = PTR_ERR(sdd->src_clk); - goto err5; + goto err2; } if (clk_prepare_enable(sdd->src_clk)) { dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name); ret = -EBUSY; - goto err6; + goto err2; } /* Setup Deufult Mode */ @@ -1330,11 +1330,12 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) init_completion(&sdd->xfer_completion); INIT_LIST_HEAD(&sdd->queue); - ret = request_irq(irq, s3c64xx_spi_irq, 0, "spi-s3c64xx", sdd); + ret = devm_request_irq(&pdev->dev, irq, s3c64xx_spi_irq, 0, + "spi-s3c64xx", sdd); if (ret != 0) { dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n", irq, ret); - goto err7; + goto err3; } writel(S3C64XX_SPI_INT_RX_OVERRUN_EN | S3C64XX_SPI_INT_RX_UNDERRUN_EN | @@ -1344,7 +1345,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) if (spi_register_master(master)) { dev_err(&pdev->dev, "cannot register SPI master\n"); ret = -EBUSY; - goto err8; + goto err3; } dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d " @@ -1358,21 +1359,13 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev) return 0; -err8: - free_irq(irq, sdd); -err7: +err3: clk_disable_unprepare(sdd->src_clk); -err6: - clk_put(sdd->src_clk); -err5: +err2: clk_disable_unprepare(sdd->clk); -err4: - clk_put(sdd->clk); -err3: +err1: if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) s3c64xx_spi_dt_gpio_free(sdd); -err2: -err1: err0: platform_set_drvdata(pdev, NULL); spi_master_put(master); @@ -1391,13 +1384,9 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) writel(0, sdd->regs + S3C64XX_SPI_INT_EN); - free_irq(platform_get_irq(pdev, 0), sdd); - clk_disable_unprepare(sdd->src_clk); - clk_put(sdd->src_clk); clk_disable_unprepare(sdd->clk); - clk_put(sdd->clk); if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) s3c64xx_spi_dt_gpio_free(sdd);