* [PATCH v2 4/5] net: dsa: switch to devm_ calls and remove kfree calls
@ 2015-10-03 14:26 Neil Armstrong
2015-10-03 20:28 ` Florian Fainelli
0 siblings, 1 reply; 2+ messages in thread
From: Neil Armstrong @ 2015-10-03 14:26 UTC (permalink / raw)
To: David S. Miller, Florian Fainelli, Guenter Roeck, vivien.didelot,
Andrew Lunn, Fabian Frederick, Pavel Nakonechny, Joe Perches,
netdev, linux-kernel, nbd, sergei.shtylyov
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.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
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 f937f7a..dd171ff 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);
@@ -461,7 +458,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
@@ -921,7 +917,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;
@@ -952,10 +948,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 != NULL) {
+ if (ds != NULL)
dsa_switch_destroy(ds);
- kfree(ds);
- }
}
}
@@ -964,7 +958,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;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 4/5] net: dsa: switch to devm_ calls and remove kfree calls
2015-10-03 14:26 [PATCH v2 4/5] net: dsa: switch to devm_ calls and remove kfree calls Neil Armstrong
@ 2015-10-03 20:28 ` Florian Fainelli
0 siblings, 0 replies; 2+ messages in thread
From: Florian Fainelli @ 2015-10-03 20:28 UTC (permalink / raw)
To: Neil Armstrong, David S. Miller, Guenter Roeck, vivien.didelot,
Andrew Lunn, Fabian Frederick, Pavel Nakonechny, Joe Perches,
netdev, linux-kernel, nbd, sergei.shtylyov
Le 03/10/2015 07:26, Neil Armstrong a écrit :
> 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.
>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-03 20:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-03 14:26 [PATCH v2 4/5] net: dsa: switch to devm_ calls and remove kfree calls Neil Armstrong
2015-10-03 20:28 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).