From patchwork Thu Aug 7 11:02:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himangi Saraogi X-Patchwork-Id: 377813 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4EA3E1400AF for ; Thu, 7 Aug 2014 21:03:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932097AbaHGLC6 (ORCPT ); Thu, 7 Aug 2014 07:02:58 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:43882 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754566AbaHGLC5 (ORCPT ); Thu, 7 Aug 2014 07:02:57 -0400 Received: by mail-pd0-f179.google.com with SMTP id ft15so5063558pdb.10 for ; Thu, 07 Aug 2014 04:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=7kPK4IsO6hUsuX4meI++DP3YOmGjU5w4/TjXyxwpcLc=; b=NzzSnCyPTPRNttjVRmVDIozwi0ylYHq3LSn9dtgtZJk1xyzaO/5Lrio9zSM4qh5kiw VBiiJGjkxOtJZQm2mmgJR2r7Np+Le6FG02p9Qmj06pc/YmmwTbUgvqnyWiCy71gJ9JUr mlAjp52U+W+WPE1kOgjjXh3ajdcPI6nwAdjPvqE/nDXsL2FQyaQHErMjrePIcH1Cu3Pc RrPQXMNfR5xCK08czuJ9wmdTw4oX2pY7aZD+Bn2Spq5b4oMjKjfi3zZQaTfCy5UMRngH YCttRtd8wG6H/Pcbj7yatTm9Gky4ERw0jLW5GFNvSQQps8HCXIZt3+jF+wS2fulLKhNv rCyQ== X-Received: by 10.66.178.231 with SMTP id db7mr15925047pac.63.1407409376528; Thu, 07 Aug 2014 04:02:56 -0700 (PDT) Received: from localhost ([14.139.82.6]) by mx.google.com with ESMTPSA id or10sm5984074pdb.26.2014.08.07.04.02.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Aug 2014 04:02:55 -0700 (PDT) Date: Thu, 7 Aug 2014 16:32:45 +0530 From: Himangi Saraogi To: "John W. Linville" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Julia Lawall Subject: [PATCH] wireless: wlcore: Use devm_kzalloc Message-ID: <20140807110244.GA10257@himangi-Dell> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch introduces the use of devm_kzalloc and does away with the kfrees in the probe and remove functions. Also, a couple of labels and the initial assignment of the ret variable in the probe function are removed. Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall --- drivers/net/wireless/ti/wlcore/spi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/spi.c b/drivers/net/wireless/ti/wlcore/spi.c index 392c882..69601f6 100644 --- a/drivers/net/wireless/ti/wlcore/spi.c +++ b/drivers/net/wireless/ti/wlcore/spi.c @@ -327,23 +327,22 @@ static int wl1271_probe(struct spi_device *spi) struct wl12xx_spi_glue *glue; struct wlcore_platdev_data pdev_data; struct resource res[1]; - int ret = -ENOMEM; + int ret; memset(&pdev_data, 0x00, sizeof(pdev_data)); pdev_data.pdata = dev_get_platdata(&spi->dev); if (!pdev_data.pdata) { dev_err(&spi->dev, "no platform data\n"); - ret = -ENODEV; - goto out; + return -ENODEV; } pdev_data.if_ops = &spi_ops; - glue = kzalloc(sizeof(*glue), GFP_KERNEL); + glue = devm_kzalloc(&spi->dev, sizeof(*glue), GFP_KERNEL); if (!glue) { dev_err(&spi->dev, "can't allocate glue\n"); - goto out; + return -ENOMEM; } glue->dev = &spi->dev; @@ -357,14 +356,13 @@ static int wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { dev_err(glue->dev, "spi_setup failed\n"); - goto out_free_glue; + return ret; } glue->core = platform_device_alloc("wl12xx", PLATFORM_DEVID_AUTO); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device\n"); - ret = -ENOMEM; - goto out_free_glue; + return -ENOMEM; } glue->core->dev.parent = &spi->dev; @@ -398,11 +396,6 @@ static int wl1271_probe(struct spi_device *spi) out_dev_put: platform_device_put(glue->core); - -out_free_glue: - kfree(glue); - -out: return ret; } @@ -411,7 +404,6 @@ static int wl1271_remove(struct spi_device *spi) struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); platform_device_unregister(glue->core); - kfree(glue); return 0; }