hwmon: (ultra45_env) Introduce managed version of kzalloc
authorHimangi Saraogi <himangi774@gmail.com>
Tue, 20 May 2014 18:15:37 +0000 (23:45 +0530)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 21 May 2014 23:02:27 +0000 (16:02 -0700)
commite8cba3cda44e1b042a64ab43d15d4d77c2038235
tree6af1bb362281982527c8c58dee1e8013581b8ef9
parent41082d66bfd6fafe001c0902bb4622d7aee6f128
hwmon: (ultra45_env) Introduce 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. Also, the unnecessary label out_free is removed.

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>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ultra45_env.c