From: Jonathan Cameron <jic23@kernel.org>
To: Karol Wrona <k.wrona@samsung.com>,
linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
linux-kernel@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Karol Wrona <wrona.vy@gmail.com>
Subject: Re: [PATCH v2 2/3] iio: kfifo: Add resource management devm_iio_kfifo_allocate/free
Date: Fri, 26 Dec 2014 11:40:56 +0000 [thread overview]
Message-ID: <549D4948.1040403@kernel.org> (raw)
In-Reply-To: <1419010766-13557-3-git-send-email-k.wrona@samsung.com>
On 19/12/14 17:39, Karol Wrona wrote:
> iio kfifo allocate/free gained their devm_ wrappers.
>
> Signed-off-by: Karol Wrona <k.wrona@samsung.com>
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
Applied to the togreg branch of iio.git.
One addition - added to the list of devm functions in
Documentation/device-model/devres.txt
> ---
> drivers/iio/kfifo_buf.c | 54 +++++++++++++++++++++++++++++++++++++++++
> include/linux/iio/kfifo_buf.h | 3 +++
> 2 files changed, 57 insertions(+)
>
> diff --git a/drivers/iio/kfifo_buf.c b/drivers/iio/kfifo_buf.c
> index a383291..5d44099 100644
> --- a/drivers/iio/kfifo_buf.c
> +++ b/drivers/iio/kfifo_buf.c
> @@ -191,4 +191,58 @@ void iio_kfifo_free(struct iio_buffer *r)
> }
> EXPORT_SYMBOL(iio_kfifo_free);
>
> +static void devm_iio_kfifo_release(struct device *dev, void *res)
> +{
> + iio_kfifo_free(*(struct iio_buffer **)res);
> +}
> +
> +static int devm_iio_kfifo_match(struct device *dev, void *res, void *data)
> +{
> + struct iio_buffer **r = res;
> +
> + if (WARN_ON(!r || !*r))
> + return 0;
> +
> + return *r == data;
> +}
> +
> +/**
> + * devm_iio_fifo_allocate - Resource-managed iio_kfifo_allocate()
> + * @dev: Device to allocate kfifo buffer for
> + *
> + * RETURNS:
> + * Pointer to allocated iio_buffer on success, NULL on failure.
> + */
> +struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev)
> +{
> + struct iio_buffer **ptr, *r;
> +
> + ptr = devres_alloc(devm_iio_kfifo_release, sizeof(*ptr), GFP_KERNEL);
> + if (!ptr)
> + return NULL;
> +
> + r = iio_kfifo_allocate();
> + if (r) {
> + *ptr = r;
> + devres_add(dev, ptr);
> + } else {
> + devres_free(ptr);
> + }
> +
> + return r;
> +}
> +EXPORT_SYMBOL(devm_iio_kfifo_allocate);
> +
> +/**
> + * devm_iio_fifo_free - Resource-managed iio_kfifo_free()
> + * @dev: Device the buffer belongs to
> + * @r: The buffer associated with the device
> + */
> +void devm_iio_kfifo_free(struct device *dev, struct iio_buffer *r)
> +{
> + WARN_ON(devres_release(dev, devm_iio_kfifo_release,
> + devm_iio_kfifo_match, r));
> +}
> +EXPORT_SYMBOL(devm_iio_kfifo_free);
> +
> MODULE_LICENSE("GPL");
> diff --git a/include/linux/iio/kfifo_buf.h b/include/linux/iio/kfifo_buf.h
> index 1a8d57a..1683bc7 100644
> --- a/include/linux/iio/kfifo_buf.h
> +++ b/include/linux/iio/kfifo_buf.h
> @@ -8,4 +8,7 @@
> struct iio_buffer *iio_kfifo_allocate(void);
> void iio_kfifo_free(struct iio_buffer *r);
>
> +struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev);
> +void devm_iio_kfifo_free(struct device *dev, struct iio_buffer *r);
> +
> #endif
>
next prev parent reply other threads:[~2014-12-26 11:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 17:39 [PATCH v2 0/3] iio: Add resource management kfifo alloc/free Karol Wrona
2014-12-19 17:39 ` [PATCH v2 1/3] iio: kfifo: Remove unused argument in iio_kfifo_allocate Karol Wrona
2014-12-26 11:35 ` Jonathan Cameron
2014-12-19 17:39 ` [PATCH v2 2/3] iio: kfifo: Add resource management devm_iio_kfifo_allocate/free Karol Wrona
2014-12-26 11:40 ` Jonathan Cameron [this message]
2014-12-19 17:39 ` [PATCH v2 3/3] iio: core: Get rid of misleading comment Karol Wrona
2014-12-26 11:41 ` 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=549D4948.1040403@kernel.org \
--to=jic23@kernel.org \
--cc=b.zolnierkie@samsung.com \
--cc=k.wrona@samsung.com \
--cc=knaack.h@gmx.de \
--cc=kyungmin.park@samsung.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
--cc=wrona.vy@gmail.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