* [PATCH] Input: tps6507x-ts: Introduce the use of the managed version of kzalloc
@ 2014-05-19 19:54 Himangi Saraogi
0 siblings, 0 replies; only message in thread
From: Himangi Saraogi @ 2014-05-19 19:54 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input, linux-kernel; +Cc: julia.lawall
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 err_free_mem 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>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
I would like to know if it is desirable to add a
devm_input_allocate_polled_device like devm_input_allocate_device. If
this is done, it seems that no change is required in
input_unregister_polled_device as there is a separate call to this
function, and then to input_free_polled_device (which would go away).
Please let me know if this reasoning is correct.
drivers/input/touchscreen/tps6507x-ts.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index 94cde2c..bd57be1 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -233,7 +233,7 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
*/
init_data = tps_board->tps6507x_ts_init_data;
- tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL);
+ tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL);
if (!tsc) {
dev_err(tps6507x_dev->dev, "failed to allocate driver data\n");
return -ENOMEM;
@@ -250,8 +250,7 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
poll_dev = input_allocate_polled_device();
if (!poll_dev) {
dev_err(tsc->dev, "Failed to allocate polled input device.\n");
- error = -ENOMEM;
- goto err_free_mem;
+ return -ENOMEM;
}
tsc->poll_dev = poll_dev;
@@ -293,8 +292,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
err_free_polled_dev:
input_free_polled_device(poll_dev);
-err_free_mem:
- kfree(tsc);
return error;
}
@@ -306,8 +303,6 @@ static int tps6507x_ts_remove(struct platform_device *pdev)
input_unregister_polled_device(poll_dev);
input_free_polled_device(poll_dev);
- kfree(tsc);
-
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-05-19 19:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19 19:54 [PATCH] Input: tps6507x-ts: Introduce the use of the managed version of kzalloc Himangi Saraogi
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).