From: Joe Perches <joe@perches.com>
To: Manish Badarkhe <badarkhe.manish@gmail.com>
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
broonie@kernel.org, lgirdwood@gmail.com
Subject: Re: [PATCH V3 1/2] devres: introduce API "devm_kstrdup"
Date: Tue, 28 Jan 2014 20:18:44 -0800 [thread overview]
Message-ID: <1390969124.11756.43.camel@joe-AO722> (raw)
In-Reply-To: <1390968181-31800-2-git-send-email-badarkhe.manish@gmail.com>
On Wed, 2014-01-29 at 09:33 +0530, Manish Badarkhe wrote:
> This patch introduces "devm_kstrdup" API so that the
> device's driver can allocate memory and copy string.
[]
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
[]
> @@ -791,6 +791,32 @@ void * devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
> EXPORT_SYMBOL_GPL(devm_kmalloc);
>
> /**
> + * devm_kstrdup - Allocate resource managed space and
> + * and copy an existing string
> + * @dev: Device to allocate memory for
> + * @s: the string to duplicate
> + * @size: Allocation size
Why is size necessary at all?
I think it should be calculated by strlen
> +char *devm_kstrdup(struct device *dev,
> + const char *s, size_t size, gfp_t gfp)
> +{
> + char *buf;
> +
> + if (!s)
> + return NULL;
> +
> + buf = devm_kzalloc(dev, size, gfp);
If this is really necessary, please use devm_kmalloc
next prev parent reply other threads:[~2014-01-29 4:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-29 4:02 [PATCH V3 0/2] devm_* API operation for fixed regulator Manish Badarkhe
2014-01-29 4:03 ` [PATCH V3 1/2] devres: introduce API "devm_kstrdup" Manish Badarkhe
2014-01-29 4:18 ` Joe Perches [this message]
2014-01-29 11:08 ` Manish Badarkhe
2014-01-29 11:40 ` Mark Brown
2014-01-29 11:55 ` Manish Badarkhe
2014-01-29 4:03 ` [PATCH V3 2/2] regulator: fixed: update to devm_* API Manish Badarkhe
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=1390969124.11756.43.camel@joe-AO722 \
--to=joe@perches.com \
--cc=badarkhe.manish@gmail.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®