* [PATCH] Input: wm831x-on - Convert to devm_kzalloc()
@ 2011-12-26 18:45 Mark Brown
2011-12-26 19:08 ` Marek Vasut
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2011-12-26 18:45 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Mark Brown
Saves a small amount of code and reduces the potential for leaks.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/input/misc/wm831x-on.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/input/misc/wm831x-on.c b/drivers/input/misc/wm831x-on.c
index 47f18d6..aee53fb 100644
--- a/drivers/input/misc/wm831x-on.c
+++ b/drivers/input/misc/wm831x-on.c
@@ -76,7 +76,8 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)
int irq = platform_get_irq(pdev, 0);
int ret;
- wm831x_on = kzalloc(sizeof(struct wm831x_on), GFP_KERNEL);
+ wm831x_on = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_on),
+ GFP_KERNEL);
if (!wm831x_on) {
dev_err(&pdev->dev, "Can't allocate data\n");
return -ENOMEM;
@@ -120,7 +121,6 @@ err_irq:
err_input_dev:
input_free_device(wm831x_on->dev);
err:
- kfree(wm831x_on);
return ret;
}
@@ -132,7 +132,6 @@ static int __devexit wm831x_on_remove(struct platform_device *pdev)
free_irq(irq, wm831x_on);
cancel_delayed_work_sync(&wm831x_on->work);
input_unregister_device(wm831x_on->dev);
- kfree(wm831x_on);
return 0;
}
--
1.7.7.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: wm831x-on - Convert to devm_kzalloc()
2011-12-26 18:45 [PATCH] Input: wm831x-on - Convert to devm_kzalloc() Mark Brown
@ 2011-12-26 19:08 ` Marek Vasut
2011-12-26 19:26 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2011-12-26 19:08 UTC (permalink / raw)
To: Mark Brown; +Cc: Dmitry Torokhov, linux-input
> Saves a small amount of code and reduces the potential for leaks.
Shouldn't you still be kind and free the memory anyway?
M
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/input/misc/wm831x-on.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/misc/wm831x-on.c
> b/drivers/input/misc/wm831x-on.c index 47f18d6..aee53fb 100644
> --- a/drivers/input/misc/wm831x-on.c
> +++ b/drivers/input/misc/wm831x-on.c
> @@ -76,7 +76,8 @@ static int __devinit wm831x_on_probe(struct
> platform_device *pdev) int irq = platform_get_irq(pdev, 0);
> int ret;
>
> - wm831x_on = kzalloc(sizeof(struct wm831x_on), GFP_KERNEL);
> + wm831x_on = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_on),
> + GFP_KERNEL);
> if (!wm831x_on) {
> dev_err(&pdev->dev, "Can't allocate data\n");
> return -ENOMEM;
> @@ -120,7 +121,6 @@ err_irq:
> err_input_dev:
> input_free_device(wm831x_on->dev);
> err:
> - kfree(wm831x_on);
> return ret;
> }
>
> @@ -132,7 +132,6 @@ static int __devexit wm831x_on_remove(struct
> platform_device *pdev) free_irq(irq, wm831x_on);
> cancel_delayed_work_sync(&wm831x_on->work);
> input_unregister_device(wm831x_on->dev);
> - kfree(wm831x_on);
>
> return 0;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Input: wm831x-on - Convert to devm_kzalloc()
2011-12-26 19:08 ` Marek Vasut
@ 2011-12-26 19:26 ` Mark Brown
0 siblings, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-12-26 19:26 UTC (permalink / raw)
To: Marek Vasut; +Cc: Dmitry Torokhov, linux-input
On Mon, Dec 26, 2011 at 08:08:46PM +0100, Marek Vasut wrote:
> > Saves a small amount of code and reduces the potential for leaks.
> Shouldn't you still be kind and free the memory anyway?
There doesn't seem to be much point if it's going to be freed
immediately anyway and half the point of the helpers is to avoid having
to write the cleanup code.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-12-26 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-26 18:45 [PATCH] Input: wm831x-on - Convert to devm_kzalloc() Mark Brown
2011-12-26 19:08 ` Marek Vasut
2011-12-26 19:26 ` Mark Brown
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).