From: Jonathan Cameron <jic23@kernel.org>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/6] devres: introduce API "devm_kmemdup
Date: Tue, 29 Apr 2014 22:06:11 +0100 [thread overview]
Message-ID: <53601443.50306@kernel.org> (raw)
In-Reply-To: <1398729107-16748-2-git-send-email-srinivas.pandruvada@linux.intel.com>
On 29/04/14 00:51, Srinivas Pandruvada wrote:
> Introduce devm_kmemdup, which uses resource managed kmalloc.
> There are several request from maintainers to add this instead
> of using kmemdup.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the togreg branch of iio.git. Initially pushed out as testing
for the autobuilders to play.
Thanks,
> ---
> Documentation/driver-model/devres.txt | 1 +
> drivers/base/devres.c | 21 +++++++++++++++++++++
> include/linux/device.h | 2 ++
> 3 files changed, 24 insertions(+)
>
> diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
> index 4f7897e..4999518 100644
> --- a/Documentation/driver-model/devres.txt
> +++ b/Documentation/driver-model/devres.txt
> @@ -236,6 +236,7 @@ certainly invest a bit more effort into libata core layer).
> MEM
> devm_kzalloc()
> devm_kfree()
> + devm_kmemdup()
>
> IIO
> devm_iio_device_alloc()
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index db4e264..d0914cb 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -831,3 +831,24 @@ void devm_kfree(struct device *dev, void *p)
> WARN_ON(rc);
> }
> EXPORT_SYMBOL_GPL(devm_kfree);
> +
> +/**
> + * devm_kmemdup - Resource-managed kmemdup
> + * @dev: Device this memory belongs to
> + * @src: Memory region to duplicate
> + * @len: Memory region length
> + * @gfp: GFP mask to use
> + *
> + * Duplicate region of a memory using resource managed kmalloc
> + */
> +void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
> +{
> + void *p;
> +
> + p = devm_kmalloc(dev, len, gfp);
> + if (p)
> + memcpy(p, src, len);
> +
> + return p;
> +}
> +EXPORT_SYMBOL_GPL(devm_kmemdup);
> diff --git a/include/linux/device.h b/include/linux/device.h
> index d1d1c05..ab87158 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -623,6 +623,8 @@ static inline void *devm_kcalloc(struct device *dev,
> }
> extern void devm_kfree(struct device *dev, void *p);
> extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
> +extern void *devm_kmemdup(struct device *dev, const void *src, size_t len,
> + gfp_t gfp);
>
> void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
> void __iomem *devm_request_and_ioremap(struct device *dev,
>
next prev parent reply other threads:[~2014-04-29 21:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-28 23:51 [PATCH 0/6] Quaternion support Srinivas Pandruvada
2014-04-28 23:51 ` [PATCH 1/6] devres: introduce API "devm_kmemdup Srinivas Pandruvada
2014-04-29 21:06 ` Jonathan Cameron [this message]
2014-04-28 23:51 ` [PATCH 2/6] IIO: core: Introduce read_raw_multi Srinivas Pandruvada
2014-04-29 21:07 ` Jonathan Cameron
2014-04-28 23:51 ` [PATCH 3/6] IIO: core: Modify scan element type Srinivas Pandruvada
2014-04-29 21:08 ` Jonathan Cameron
2014-04-28 23:51 ` [PATCH 4/6] IIO: core: Add quaternion modifier Srinivas Pandruvada
2014-04-29 21:09 ` Jonathan Cameron
2014-04-28 23:51 ` [PATCH 5/6] iio: hid-sensors: Added device rotation support Srinivas Pandruvada
2014-04-29 21:13 ` Jonathan Cameron
2014-04-28 23:51 ` [PATCH 6/6] iio: Added ABI description for quaternion Srinivas Pandruvada
2014-04-29 21:14 ` Jonathan Cameron
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=53601443.50306@kernel.org \
--to=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.