diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-19 12:55:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-21 16:29:52 -0400 |
commit | 12b5c38f2dee5981c318171805fa62f2cd7475b3 (patch) | |
tree | 27a88d8c38f5a8b9096d56f42cb05329eb7bcd62 /drivers/net/ieee802154 | |
parent | 7e910357f620bbebe5c5cb038b70d408e624522f (diff) |
ieee802154: Introduce the use of the managed version of kzalloc
This patch moves data allocated using kzalloc to managed data allocated
using devm_kzalloc and cleans now unnecessary kfrees in probe and remove
functions. An explicit linux/device.h include is added to make sure
the devm_*() routine declarations are unambiguously available.
The following Coccinelle semantic patch was used for making the change:
@platform@
identifier p, probefn, removefn;
@@
struct platform_driver p = {
.probe = probefn,
.remove = removefn,
};
@prb@
identifier platform.probefn, pdev;
expression e, e1, e2;
@@
probefn(struct platform_device *pdev, ...) {
<+...
- e = kzalloc(e1, e2)
+ e = devm_kzalloc(&pdev->dev, e1, e2)
...
?-kfree(e);
...+>
}
@rem depends on prb@
identifier platform.removefn;
expression e;
@@
removefn(...) {
<...
- kfree(e);
...>
}
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ieee802154')
-rw-r--r-- | drivers/net/ieee802154/fakelb.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/ieee802154/fakelb.c b/drivers/net/ieee802154/fakelb.c index b8d22173925d..27d83207d24c 100644 --- a/drivers/net/ieee802154/fakelb.c +++ b/drivers/net/ieee802154/fakelb.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/timer.h> | 26 | #include <linux/timer.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/netdevice.h> | 28 | #include <linux/netdevice.h> |
29 | #include <linux/device.h> | ||
29 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
30 | #include <net/mac802154.h> | 31 | #include <net/mac802154.h> |
31 | #include <net/wpan-phy.h> | 32 | #include <net/wpan-phy.h> |
@@ -228,7 +229,8 @@ static int fakelb_probe(struct platform_device *pdev) | |||
228 | int err = -ENOMEM; | 229 | int err = -ENOMEM; |
229 | int i; | 230 | int i; |
230 | 231 | ||
231 | priv = kzalloc(sizeof(struct fakelb_priv), GFP_KERNEL); | 232 | priv = devm_kzalloc(&pdev->dev, sizeof(struct fakelb_priv), |
233 | GFP_KERNEL); | ||
232 | if (!priv) | 234 | if (!priv) |
233 | goto err_alloc; | 235 | goto err_alloc; |
234 | 236 | ||
@@ -248,7 +250,6 @@ static int fakelb_probe(struct platform_device *pdev) | |||
248 | err_slave: | 250 | err_slave: |
249 | list_for_each_entry(dp, &priv->list, list) | 251 | list_for_each_entry(dp, &priv->list, list) |
250 | fakelb_del(dp); | 252 | fakelb_del(dp); |
251 | kfree(priv); | ||
252 | err_alloc: | 253 | err_alloc: |
253 | return err; | 254 | return err; |
254 | } | 255 | } |
@@ -260,7 +261,6 @@ static int fakelb_remove(struct platform_device *pdev) | |||
260 | 261 | ||
261 | list_for_each_entry_safe(dp, temp, &priv->list, list) | 262 | list_for_each_entry_safe(dp, temp, &priv->list, list) |
262 | fakelb_del(dp); | 263 | fakelb_del(dp); |
263 | kfree(priv); | ||
264 | 264 | ||
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |