From patchwork Thu Mar 17 02:26:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 8606931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ABB8EC0553 for ; Thu, 17 Mar 2016 03:46:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF65B20204 for ; Thu, 17 Mar 2016 03:46:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05883201FE for ; Thu, 17 Mar 2016 03:46:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1agOqz-0008P4-Kc; Thu, 17 Mar 2016 03:44:05 +0000 Received: from [50.115.127.205] (helo=vern.gendns.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1agOpq-000745-7S for linux-arm-kernel@lists.infradead.org; Thu, 17 Mar 2016 03:43:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From; bh=kW9jWqu+Svk9Dn6N0hHyY60mVIBACgh3eLmM9Lg81Po=; b=MlWOzNRJFnzSC nZv8oB2SkQ7p6YPS1IW4jfQhv+2GgYUnHv7AVIsnhwhACuDBgQ3+MlQIF79+3WSkjN/5jMQVlBQJ2 URwvqS9j7J94+DnILU8eXTqY/jyfxMyMQau9cONJP3mby8MMzxtwWGajisJ9LbIyF7ii6saebDPlo UaRwUOgq+u6ORifYPMutTWmISy/SEjZ/I68y0ED1c2Oi/IDioCucEvaYu2jRd1bDi4o4zSYN7aPe9 /pHJVF9g7xhCo438nnem251JChEZ/8qjLaxYaxwbmV3MaOTxPDz14pXDaq4gf5scsM4KW5HbyGLIe ubHCFlyMs/YIT7zsHw/Ig==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:51099 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.86_1) (envelope-from ) id 1agNhF-003yue-1i; Wed, 16 Mar 2016 22:29:57 -0400 From: David Lechner To: Subject: [PATCH v2 10/11] usb: musb: da8xx: Use devm in probe Date: Wed, 16 Mar 2016 21:26:43 -0500 Message-Id: <1458181615-27782-11-git-send-email-david@lechnology.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458181615-27782-1-git-send-email-david@lechnology.com> References: <1458181615-27782-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160316_204254_860930_82F09DBF X-CRM114-Status: GOOD ( 10.36 ) X-Spam-Score: -0.5 (/) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Tony Lindgren , Sekhar Nori , Robert Jarzmik , Russell King , Kevin Hilman , Kishon Vijay Abraham I , Alan Stern , devicetree@vger.kernel.org, David Lechner , Pawel Moll , Ian Campbell , Rob Herring , Bin Liu , linux-arm-kernel@lists.infradead.org, Sergei Shtylyov , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Kulhavy , Kumar Gala , =?UTF-8?q?Andreas=20F=C3=A4rber?= MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Simplify things a bit by using devm functions where possible. Signed-off-by: David Lechner --- v2 changes: This is part of a previous patch that was split. No changes from previous version. drivers/usb/musb/da8xx.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index b03d3b8..50f07a5 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -489,32 +489,27 @@ static int da8xx_probe(struct platform_device *pdev) struct platform_device *musb; struct da8xx_glue *glue; struct platform_device_info pinfo; - struct clk *clk; + int ret; - int ret = -ENOMEM; - - glue = kzalloc(sizeof(*glue), GFP_KERNEL); + glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); if (!glue) { dev_err(&pdev->dev, "failed to allocate glue context\n"); - goto err0; + return -ENOMEM; } - clk = clk_get(&pdev->dev, "usb20"); - if (IS_ERR(clk)) { + glue->clk = devm_clk_get(&pdev->dev, "usb20"); + if (IS_ERR(glue->clk)) { dev_err(&pdev->dev, "failed to get clock\n"); - ret = PTR_ERR(clk); - goto err3; + return PTR_ERR(glue->clk); } - ret = clk_enable(clk); + ret = clk_enable(glue->clk); if (ret) { dev_err(&pdev->dev, "failed to enable clock\n"); goto err4; } glue->dev = &pdev->dev; - glue->clk = clk; - pdata->platform_ops = &da8xx_ops; glue->phy = usb_phy_generic_register(); @@ -557,15 +552,10 @@ err6: usb_phy_generic_unregister(glue->phy); err5: - clk_disable(clk); + clk_disable(glue->clk); err4: - clk_put(clk); - -err3: - kfree(glue); -err0: return ret; } @@ -576,8 +566,6 @@ static int da8xx_remove(struct platform_device *pdev) platform_device_unregister(glue->musb); usb_phy_generic_unregister(glue->phy); clk_disable(glue->clk); - clk_put(glue->clk); - kfree(glue); return 0; }