From patchwork Thu Mar 24 23:51:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 8666811 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C42E39F326 for ; Fri, 25 Mar 2016 00:00:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAC582034F for ; Fri, 25 Mar 2016 00:00:51 +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 250AB202EC for ; Fri, 25 Mar 2016 00:00:51 +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 1ajF9h-0005QX-K6; Thu, 24 Mar 2016 23:59:09 +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 1ajF6C-0000mI-C3 for linux-arm-kernel@lists.infradead.org; Thu, 24 Mar 2016 23:55:33 +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=yOCb15NQ1GCiXurTscdn/9pAUim6S6hlP2cgd0e1hck=; b=bOmbciBKsisTT 8I94DvJtuBEK7dZOe1dZxiWWE+kBIbls5UIdi8oGOQU3hSTxDSlZA5fMgaVkkqDP6vO2XyskOngpT Cp7pOm1P5m+9Acr8hNZe4MTVH+wcNVzVZxE0YdSN0aY6Qn0lLQYPAd4mSuXilyiiIRJHi0Lpo1sPo wdA2qhER1ZUnKGRZpUK+VrgUfyIMM2pSAEgeNa/VbjqQo1WDe8QS7Fm1TZbKBYghzrHvk4+ApBSXF 8W5igHhUBSosn9QmV5Wh00ZX+fz9eUTLCW8uJsj9aoFIhmxw9j5prdoreTLauMeNsq6U4okxDMJRC uaB968v6rIaPH+G27VisQ==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:47864 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.86_1) (envelope-from ) id 1ajF4s-000XIt-2J; Thu, 24 Mar 2016 19:54:10 -0400 From: David Lechner To: Subject: [PATCH v3 15/16] usb: musb: da8xx: Use devm in probe Date: Thu, 24 Mar 2016 18:51:40 -0500 Message-Id: <1458863503-31121-16-git-send-email-david@lechnology.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458863503-31121-1-git-send-email-david@lechnology.com> References: <1458863503-31121-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-20160324_165532_684600_DE4C7C45 X-CRM114-Status: UNSURE ( 8.63 ) X-CRM114-Notice: Please train this message. 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 , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "open list:USB SUBSYSTEM" , Russell King , David Lechner , Pawel Moll , Ian Campbell , Greg Kroah-Hartman , Kevin Hilman , Sekhar Nori , open list , Kishon Vijay Abraham I , petr@barix.com, Rob Herring , Alan Stern , "moderated list:ARM PORT" , Kumar Gala , David.Laight@ACULAB.COM, Lee Jones , sergei.shtylyov@cogentembedded.com, Bin Liu 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, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Signed-off-by: Bin Liu --- v3 changes: * Kept clk variable to minimize noise. drivers/usb/musb/da8xx.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index b03d3b8..0c1997c 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev) 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"); + clk = devm_clk_get(&pdev->dev, "usb20"); if (IS_ERR(clk)) { dev_err(&pdev->dev, "failed to get clock\n"); - ret = PTR_ERR(clk); - goto err3; + return PTR_ERR(clk); } ret = clk_enable(clk); @@ -560,12 +558,7 @@ err5: clk_disable(clk); err4: - clk_put(clk); - -err3: - kfree(glue); -err0: return ret; } @@ -576,8 +569,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; }