* [PATCH 2/2] i2c: stu300: use devm allocation @ 2012-06-12 17:33 Linus Walleij [not found] ` <1339522417-606-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: Linus Walleij @ 2012-06-12 17:33 UTC (permalink / raw) To: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Linus Walleij From: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Allocate memory for device state using devm_kzalloc() to simplify accounting. Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> --- drivers/i2c/busses/i2c-stu300.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c index 79b7851..e5c10c5 100644 --- a/drivers/i2c/busses/i2c-stu300.c +++ b/drivers/i2c/busses/i2c-stu300.c @@ -873,7 +873,7 @@ stu300_probe(struct platform_device *pdev) int ret = 0; char clk_name[] = "I2C0"; - dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); + dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL); if (!dev) { dev_err(&pdev->dev, "could not allocate device struct\n"); ret = -ENOMEM; @@ -971,7 +971,6 @@ stu300_probe(struct platform_device *pdev) err_no_resource: clk_put(dev->clk); err_no_clk: - kfree(dev); err_no_devmem: dev_err(&pdev->dev, "failed to add " NAME " adapter: %d\n", pdev->id); @@ -1020,7 +1019,6 @@ stu300_remove(struct platform_device *pdev) clk_unprepare(dev->clk); clk_put(dev->clk); platform_set_drvdata(pdev, NULL); - kfree(dev); return 0; } -- 1.7.9.2 ^ permalink raw reply related [flat|nested] 2+ messages in thread
[parent not found: <1339522417-606-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org>]
* Re: [PATCH 2/2] i2c: stu300: use devm allocation [not found] ` <1339522417-606-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org> @ 2012-07-09 12:20 ` Wolfram Sang 0 siblings, 0 replies; 2+ messages in thread From: Wolfram Sang @ 2012-07-09 12:20 UTC (permalink / raw) To: Linus Walleij; +Cc: Ben Dooks, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Linus Walleij [-- Attachment #1: Type: text/plain, Size: 1683 bytes --] On Tue, Jun 12, 2012 at 07:33:37PM +0200, Linus Walleij wrote: > From: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> > > Allocate memory for device state using devm_kzalloc() to > simplify accounting. > > Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Please use devm_* for resource allocation, too, then... > --- > drivers/i2c/busses/i2c-stu300.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c > index 79b7851..e5c10c5 100644 > --- a/drivers/i2c/busses/i2c-stu300.c > +++ b/drivers/i2c/busses/i2c-stu300.c > @@ -873,7 +873,7 @@ stu300_probe(struct platform_device *pdev) > int ret = 0; > char clk_name[] = "I2C0"; > > - dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); > + dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL); > if (!dev) { > dev_err(&pdev->dev, "could not allocate device struct\n"); > ret = -ENOMEM; > @@ -971,7 +971,6 @@ stu300_probe(struct platform_device *pdev) > err_no_resource: > clk_put(dev->clk); > err_no_clk: > - kfree(dev); > err_no_devmem: > dev_err(&pdev->dev, "failed to add " NAME " adapter: %d\n", > pdev->id); > @@ -1020,7 +1019,6 @@ stu300_remove(struct platform_device *pdev) > clk_unprepare(dev->clk); > clk_put(dev->clk); > platform_set_drvdata(pdev, NULL); > - kfree(dev); > return 0; > } > > -- > 1.7.9.2 > -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-09 12:20 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-12 17:33 [PATCH 2/2] i2c: stu300: use devm allocation Linus Walleij [not found] ` <1339522417-606-1-git-send-email-linus.walleij-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org> 2012-07-09 12:20 ` Wolfram Sang
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).