diff options
author | Neil Armstrong <narmstrong@baylibre.com> | 2015-10-06 10:40:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-07 07:56:09 -0400 |
commit | d4ac35d6ed82e6c96ed5c016ea46fad31294fa7a (patch) | |
tree | 8b4ec5226bd82050a1ad66aef2bf751b0e326049 /net | |
parent | cbc5d90b378cd255ffedeb12f5affe243230d47e (diff) |
net: dsa: switch to devm_ calls and remove kfree calls
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 <f.fainelli@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/dsa/dsa.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 61559232861b..d5a162cda087 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) | |||
306 | if (ret < 0) | 306 | if (ret < 0) |
307 | goto out; | 307 | goto out; |
308 | 308 | ||
309 | ds->slave_mii_bus = mdiobus_alloc(); | 309 | ds->slave_mii_bus = devm_mdiobus_alloc(parent); |
310 | if (ds->slave_mii_bus == NULL) { | 310 | if (ds->slave_mii_bus == NULL) { |
311 | ret = -ENOMEM; | 311 | ret = -ENOMEM; |
312 | goto out; | 312 | goto out; |
@@ -315,7 +315,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | |||
315 | 315 | ||
316 | ret = mdiobus_register(ds->slave_mii_bus); | 316 | ret = mdiobus_register(ds->slave_mii_bus); |
317 | if (ret < 0) | 317 | if (ret < 0) |
318 | goto out_free; | 318 | goto out; |
319 | 319 | ||
320 | 320 | ||
321 | /* | 321 | /* |
@@ -368,10 +368,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent) | |||
368 | 368 | ||
369 | return ret; | 369 | return ret; |
370 | 370 | ||
371 | out_free: | ||
372 | mdiobus_free(ds->slave_mii_bus); | ||
373 | out: | 371 | out: |
374 | kfree(ds); | ||
375 | return ret; | 372 | return ret; |
376 | } | 373 | } |
377 | 374 | ||
@@ -401,7 +398,7 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index, | |||
401 | /* | 398 | /* |
402 | * Allocate and initialise switch state. | 399 | * Allocate and initialise switch state. |
403 | */ | 400 | */ |
404 | ds = kzalloc(sizeof(*ds) + drv->priv_size, GFP_KERNEL); | 401 | ds = devm_kzalloc(parent, sizeof(*ds) + drv->priv_size, GFP_KERNEL); |
405 | if (ds == NULL) | 402 | if (ds == NULL) |
406 | return ERR_PTR(-ENOMEM); | 403 | return ERR_PTR(-ENOMEM); |
407 | 404 | ||
@@ -462,7 +459,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds) | |||
462 | } | 459 | } |
463 | 460 | ||
464 | mdiobus_unregister(ds->slave_mii_bus); | 461 | mdiobus_unregister(ds->slave_mii_bus); |
465 | mdiobus_free(ds->slave_mii_bus); | ||
466 | } | 462 | } |
467 | 463 | ||
468 | #ifdef CONFIG_PM_SLEEP | 464 | #ifdef CONFIG_PM_SLEEP |
@@ -922,7 +918,7 @@ static int dsa_probe(struct platform_device *pdev) | |||
922 | goto out; | 918 | goto out; |
923 | } | 919 | } |
924 | 920 | ||
925 | dst = kzalloc(sizeof(*dst), GFP_KERNEL); | 921 | dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); |
926 | if (dst == NULL) { | 922 | if (dst == NULL) { |
927 | dev_put(dev); | 923 | dev_put(dev); |
928 | ret = -ENOMEM; | 924 | ret = -ENOMEM; |
@@ -953,10 +949,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst) | |||
953 | for (i = 0; i < dst->pd->nr_chips; i++) { | 949 | for (i = 0; i < dst->pd->nr_chips; i++) { |
954 | struct dsa_switch *ds = dst->ds[i]; | 950 | struct dsa_switch *ds = dst->ds[i]; |
955 | 951 | ||
956 | if (ds) { | 952 | if (ds) |
957 | dsa_switch_destroy(ds); | 953 | dsa_switch_destroy(ds); |
958 | kfree(ds); | ||
959 | } | ||
960 | } | 954 | } |
961 | } | 955 | } |
962 | 956 | ||
@@ -965,7 +959,6 @@ static int dsa_remove(struct platform_device *pdev) | |||
965 | struct dsa_switch_tree *dst = platform_get_drvdata(pdev); | 959 | struct dsa_switch_tree *dst = platform_get_drvdata(pdev); |
966 | 960 | ||
967 | dsa_remove_dst(dst); | 961 | dsa_remove_dst(dst); |
968 | kfree(dst); | ||
969 | dsa_of_remove(&pdev->dev); | 962 | dsa_of_remove(&pdev->dev); |
970 | 963 | ||
971 | return 0; | 964 | return 0; |