From patchwork Tue Oct 6 14:40:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 526792 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 65B20140D6C for ; Wed, 7 Oct 2015 01:41:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752919AbbJFOkm (ORCPT ); Tue, 6 Oct 2015 10:40:42 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:38596 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752887AbbJFOkk (ORCPT ); Tue, 6 Oct 2015 10:40:40 -0400 Received: by wiclk2 with SMTP id lk2so162563130wic.1 for ; Tue, 06 Oct 2015 07:40:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:organization:message-id:date :user-agent:mime-version:content-type:content-transfer-encoding; bh=o8v9moZwVeP8MH2puK+ZTYkc+rSqQ/1RLKuL4+xJ7rc=; b=CCKGaSmgNIpCncZ8UcIHeRQYgqGpPnpneWUL/HRsCeKcLBA2tc0Ws8zjioEdJT1w6D SmKL0A3E1i2dItfK0KTmpyaENYtdIk7BwBBNPNv9Drj5X0QjSTq3VLYg9a35FxlM3QPv Ih5llQuGOyMZmnKLsIz/jkfhhVAbuQyQwrnYLZnd5/ZHJ4e1VdeQDyRlzUBa9Ib/3IOm LeMYvKuancdTqwBckH4zFLuISg1drHJGM31lwdUEOD+hdb5BeSbDxUBmsGI8IC4rihlC t/tigcsC8Em45rYEZ5QLB0aP9Dp1aHHzkYAOXOKoHzh/hOW8HHebS57TYtOganq722yZ S+2Q== X-Gm-Message-State: ALoCoQk4L12PtsVcsPdTAq8PKdESu22f7xye/UWD5iwjGRKU9D8S72E9hbUYUsLatwQ4cAOaJlg2 X-Received: by 10.194.174.227 with SMTP id bv3mr41045869wjc.142.1444142438902; Tue, 06 Oct 2015 07:40:38 -0700 (PDT) Received: from [10.200.207.21] ([89.101.192.72]) by smtp.gmail.com with ESMTPSA id s2sm20119824wib.15.2015.10.06.07.40.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Oct 2015 07:40:38 -0700 (PDT) From: Neil Armstrong To: "David S. Miller" , Florian Fainelli , Guenter Roeck , vivien.didelot@savoirfairelinux.com, Andrew Lunn , Fabian Frederick , Pavel Nakonechny , Joe Perches , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, nbd@openwrt.org, sergei.shtylyov@cogentembedded.com Subject: [PATCH v3 4/5] net: dsa: switch to devm_ calls and remove kfree calls X-Enigmail-Draft-Status: N1110 Organization: Baylibre Message-ID: <5613DD65.2050806@baylibre.com> Date: Tue, 6 Oct 2015 15:40:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now the kfree calls exists in the the remove functions, remove them in all places except the of_probe functions and replace allocation calls with their devm_ counterparts. Reviewed-by: Florian Fainelli Signed-off-by: Neil Armstrong --- net/dsa/dsa.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 6155923..d5a162c 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -306,7 +306,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) if (ret < 0) goto out; - ds->slave_mii_bus = mdiobus_alloc(); + ds->slave_mii_bus = devm_mdiobus_alloc(parent); if (ds->slave_mii_bus == NULL) { ret = -ENOMEM; goto out; @@ -315,7 +315,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) ret = mdiobus_register(ds->slave_mii_bus); if (ret < 0) - goto out_free; + goto out; /* @@ -368,10 +368,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) return ret; -out_free: - mdiobus_free(ds->slave_mii_bus); out: - kfree(ds); return ret; } @@ -401,7 +398,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, /* * Allocate and initialise switch state. */ - ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL); + ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL); if (ds == NULL) return ERR_PTR(-ENOMEM); @@ -462,7 +459,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds) } mdiobus_unregister(ds->slave_mii_bus); - mdiobus_free(ds->slave_mii_bus); } #ifdef CONFIG_PM_SLEEP @@ -922,7 +918,7 @@ static int dsa_probe(struct platform_device *pdev) goto out; } - dst = kzalloc(sizeof(*dst), GFP_KERNEL); + dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); if (dst == NULL) { dev_put(dev); ret = -ENOMEM; @@ -953,10 +949,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst) for (i = 0; i < dst->pd->nr_chips; i++) { struct dsa_switch *ds = dst->ds[i]; - if (ds) { + if (ds) dsa_switch_destroy(ds); - kfree(ds); - } } } @@ -965,7 +959,6 @@ static int dsa_remove(struct platform_device *pdev) struct dsa_switch_tree *dst = platform_get_drvdata(pdev); dsa_remove_dst(dst); - kfree(dst); dsa_of_remove(&pdev->dev); return 0;