All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Ardelean <alexandru.ardelean@analog.com>
To: <linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>
Cc: <lars@metafoo.de>, <Michael.Hennerich@analog.com>,
	<jic23@kernel.org>, <nuno.sa@analog.com>,
	<dragos.bogdan@analog.com>,
	Alexandru Ardelean <alexandru.ardelean@analog.com>
Subject: [PATCH v2 08/12][RESEND] iio: buffer: add helper to get the IIO device to which a buffer belongs
Date: Fri, 22 Jan 2021 18:25:25 +0200	[thread overview]
Message-ID: <20210122162529.84978-9-alexandru.ardelean@analog.com> (raw)
In-Reply-To: <20210122162529.84978-1-alexandru.ardelean@analog.com>

This is useful for drivers that may have a reference to an IIO buffer, to
be able to get a reference back to the IIO device.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/industrialio-buffer.c | 14 ++++++++++++++
 include/linux/iio/buffer.h        |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 8470921cf2fa..a2dd30567072 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1778,6 +1778,20 @@ void iio_buffer_put(struct iio_buffer *buffer)
 }
 EXPORT_SYMBOL_GPL(iio_buffer_put);
 
+/**
+ * iio_buffer_get_iio_dev - Get the IIO device to which this buffer belongs to
+ * @buffer: The buffer for which to retrieve the IIO device
+ *
+ * This function retrieves the IIO device to which this IIO buffer is attached
+ * to. Given that an IIO device may have multiple IIO buffers, it's useful
+ * for some drivers to obtain a reference back to the IIO device.
+ */
+struct iio_dev *iio_buffer_get_iio_dev(struct iio_buffer *buffer)
+{
+	return buffer->indio_dev;
+}
+EXPORT_SYMBOL_GPL(iio_buffer_get_iio_dev);
+
 /**
  * iio_device_attach_buffer - Attach a buffer to a IIO device
  * @indio_dev: The device the buffer should be attached to
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 8febc23f5f26..b27d8c81f32c 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -11,6 +11,8 @@
 
 struct iio_buffer;
 
+struct iio_dev *iio_buffer_get_iio_dev(struct iio_buffer *buffer);
+
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
 
 /**
-- 
2.17.1


  parent reply	other threads:[~2021-01-22 17:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 16:25 [PATCH v2 00/12][RESEND] iio: core,buffer: add support for multiple IIO buffers per IIO device Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 01/12][RESEND] iio: core: register chardev only if needed Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 02/12][RESEND] iio: buffer: add back-ref from iio_buffer to iio_dev Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 03/12][RESEND] iio: buffer: rework buffer & scan_elements dir creation Alexandru Ardelean
2021-01-24 18:11   ` Jonathan Cameron
2021-01-24 19:07     ` Alexandru Ardelean
2021-01-25 19:29       ` Greg Kroah-Hartman
2021-01-25 19:28     ` Greg Kroah-Hartman
2021-01-26  9:45       ` Alexandru Ardelean
2021-01-27 14:48         ` Jonathan Cameron
2021-01-22 16:25 ` [PATCH v2 04/12][RESEND] iio: buffer: add index to the first IIO buffer dir and symlink it back Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 05/12][RESEND] iio: core: split __iio_device_attr_init() to init only the attr object Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 06/12][RESEND] iio: buffer: re-route scan_elements via it's kobj_type Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 07/12][RESEND] iio: buffer: re-route core buffer attributes via it's new kobj_type Alexandru Ardelean
2021-01-22 16:25 ` Alexandru Ardelean [this message]
2021-01-22 16:25 ` [PATCH v2 09/12][RESEND] iio: re-route all buffer attributes through new buffer kobj_type Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 10/12][RESEND] iio: core: wrap iio device & buffer into struct for character devices Alexandru Ardelean
2021-01-22 16:25 ` [PATCH v2 11/12][RESEND] iio: buffer: introduce support for attaching more IIO buffers Alexandru Ardelean
2021-01-25 11:06   ` [kbuild] " Dan Carpenter
2021-01-25 11:06     ` Dan Carpenter
2021-01-25 11:06     ` Dan Carpenter
2021-01-22 16:25 ` [PATCH v2 12/12][RESEND] iio: buffer: add ioctl() to support opening extra buffers for IIO device Alexandru Ardelean
2021-01-24 18:38   ` Jonathan Cameron
2021-01-24 19:32     ` Alexandru Ardelean

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=20210122162529.84978-9-alexandru.ardelean@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=dragos.bogdan@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.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.