From: "sangjung.woo" <sangjung.woo@samsung.com>
To: Joe Perches <joe@perches.com>
Cc: Alessandro Rubini <rubini@gnudd.com>,
Russell King <rmk+kernel@arm.linux.org.uk>,
rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org,
sangjung.woo@samsung.com
Subject: Re: [PATCH] rtc: pl030: Use devm_kzalloc() instead of kmalloc()
Date: Wed, 09 Oct 2013 13:36:52 +0900 [thread overview]
Message-ID: <5254DD64.4090205@samsung.com> (raw)
In-Reply-To: <1381291649.2040.1.camel@joe-AO722>
On 10/09/2013 01:07 PM, Joe Perches wrote:
> On Wed, 2013-10-09 at 13:00 +0900, Sangjung Woo wrote:
>> In order to be free automatically and make the cleanup paths more
>> simple, use devm_kzalloc() instead of kzalloc().
> []
>> diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
> []
>> @@ -106,7 +106,7 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id)
>> if (ret)
>> goto err_req;
>>
>> - rtc = kmalloc(sizeof(*rtc), GFP_KERNEL);
>> + rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL);
First of all, thanks for your review.
> You're not deleting a memset and you're
> converting a kmalloc.
You are right.
>
> Why do you need the zalloc version?
>
The key point of this patch is resource-managed memory allocation.
As you already know, memory space that is allocated by devm_kzalloc()
function
is automatically freed on driver detach. That makes the code tidy and
reduces human's mistakes not to kfree().
next prev parent reply other threads:[~2013-10-09 4:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 4:00 [PATCH] rtc: pl030: Use devm_kzalloc() instead of kmalloc() Sangjung Woo
2013-10-09 4:07 ` Joe Perches
2013-10-09 4:36 ` sangjung.woo [this message]
2013-10-09 4:59 ` Joe Perches
2013-10-09 5:32 ` sangjung.woo
2013-10-10 23:06 ` Andrew Morton
2013-10-10 23:14 ` Joe Perches
2013-10-10 23:46 ` Andrew Morton
2013-10-10 23:18 ` Tejun Heo
2013-10-10 23:25 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5254DD64.4090205@samsung.com \
--to=sangjung.woo@samsung.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=rtc-linux@googlegroups.com \
--cc=rubini@gnudd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox