From patchwork Thu Apr 11 09:29:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 235945 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 3BC172C01B5 for ; Fri, 12 Apr 2013 09:42:19 +1000 (EST) Received: from mail-bk0-x234.google.com (mail-bk0-x234.google.com [IPv6:2a00:1450:4008:c01::234]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 94C492C00EB; Thu, 11 Apr 2013 19:29:50 +1000 (EST) Received: by mail-bk0-f52.google.com with SMTP id it16so697170bkc.11 for ; Thu, 11 Apr 2013 02:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=7GY2j85NiIAf1m0x8TAIq/PBQNmyldWUyZtH+4kaTm8=; b=IBX1eF6nF0mIFo0VGXRAs8lWZDsufIcWRwKHqM74M4Z0EEjjFWoQXofwcnWWIvfABg GfBV0IvGKyPdFFL9ufv1/C01dwvgFYqes9Tv1R0msxbjoDBq9CLvceOtvMn4ZM/k2lCh zIsTRUhEMSih89CKJltrcYrTcCkSWeQH88FQPUWZsXZry05j51AtXW8tOfbn/iMt5nmS nSSpNaVy+KtQ1jclhF+41h0bYosg4c6yDD/0cQ8okjcDqC35w2TGaEA9t/GSzVk8rbtn bLpAH4NmPv1MJPIS33Ngb7mSq0X0+QliiU2aDRX14Y5vWUAFbCH0xT9ahES6r3vecyR7 KpVQ== X-Received: by 10.205.34.3 with SMTP id sq3mr2179413bkb.23.1365672586265; Thu, 11 Apr 2013 02:29:46 -0700 (PDT) Received: from edge.mip.uni-hannover.de (ip195.250.mip.uni-hannover.de. [130.75.250.195]) by mx.google.com with ESMTPS id da16sm1457004bkb.2.2013.04.11.02.29.44 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 02:29:45 -0700 (PDT) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v2 2/2] net: mv643xx_eth: use managed devm_kzalloc Date: Thu, 11 Apr 2013 11:29:34 +0200 Message-Id: <1365672574-31123-3-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365672574-31123-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1365672574-31123-1-git-send-email-sebastian.hesselbarth@gmail.com> X-Mailman-Approved-At: Fri, 12 Apr 2013 09:40:38 +1000 Cc: Andrew Lunn , Jason Cooper , Sergei Shtylyov , linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, Rob Herring , Paul Mackerras , Rob Landley , netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Florian Fainelli , Lennert Buytenhek X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This patch moves shared private data kzalloc to managed devm_kzalloc and cleans now unneccessary kfree and error handling. Signed-off-by: Sebastian Hesselbarth --- Changes from v1: - replaced EADDRNOTAVAIL with ENOMEM on failing ioremap (Reported by Sergei Shtylyov) Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Cc: Lennert Buytenhek Cc: Sebastian Hesselbarth Cc: Andrew Lunn Cc: Jason Cooper Cc: Florian Fainelli Cc: Sergei Shtylyov Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/ethernet/marvell/mv643xx_eth.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c index bbe6104..305038f 100644 --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2547,25 +2547,22 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) struct mv643xx_eth_shared_private *msp; const struct mbus_dram_target_info *dram; struct resource *res; - int ret; if (!mv643xx_eth_version_printed++) pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n", mv643xx_eth_driver_version); - ret = -EINVAL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (res == NULL) - goto out; + return -EINVAL; - ret = -ENOMEM; - msp = kzalloc(sizeof(*msp), GFP_KERNEL); + msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL); if (msp == NULL) - goto out; + return -ENOMEM; msp->base = ioremap(res->start, resource_size(res)); if (msp->base == NULL) - goto out_free; + return -ENOMEM; msp->clk = devm_clk_get(&pdev->dev, NULL); if (!IS_ERR(msp->clk)) @@ -2585,11 +2582,6 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) platform_set_drvdata(pdev, msp); return 0; - -out_free: - kfree(msp); -out: - return ret; } static int mv643xx_eth_shared_remove(struct platform_device *pdev) @@ -2599,7 +2591,6 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev) iounmap(msp->base); if (!IS_ERR(msp->clk)) clk_disable_unprepare(msp->clk); - kfree(msp); return 0; }