From: Alexandru Ardelean <alexandru.ardelean@analog.com>
To: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <jic23@kernel.org>, <lars@metafoo.de>,
Alexandru Ardelean <alexandru.ardelean@analog.com>
Subject: [PATCH 1/5] iio: core: register buffer fileops only if buffer present
Date: Fri, 10 Apr 2020 14:56:51 +0300 [thread overview]
Message-ID: <20200410115655.79217-2-alexandru.ardelean@analog.com> (raw)
In-Reply-To: <20200410115655.79217-1-alexandru.ardelean@analog.com>
The intent is to localize all buffer ops into the industrialio-buffer.c
file, to be able to add support for multiple buffers per IIO device.
We still need to allocate a chardev in __iio_device_register() to be able
to pass event ioctl commands. So, if the IIO device has no buffer, we
create the legacy chardev for the event ioctl() command.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
drivers/iio/industrialio-core.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 157d95a24faa..c8c074602709 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1707,6 +1707,15 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
static const struct iio_buffer_setup_ops noop_ring_setup_ops;
+static const struct file_operations iio_event_fileops = {
+ .release = iio_chrdev_release,
+ .open = iio_chrdev_open,
+ .owner = THIS_MODULE,
+ .llseek = noop_llseek,
+ .unlocked_ioctl = iio_ioctl,
+ .compat_ioctl = compat_ptr_ioctl,
+};
+
int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
{
int ret;
@@ -1757,7 +1766,10 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
indio_dev->setup_ops == NULL)
indio_dev->setup_ops = &noop_ring_setup_ops;
- cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
+ if (indio_dev->buffer)
+ cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
+ else
+ cdev_init(&indio_dev->chrdev, &iio_event_fileops);
indio_dev->chrdev.owner = this_mod;
--
2.17.1
next prev parent reply other threads:[~2020-04-10 11:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 11:56 [PATCH 0/5] iio: core,buffer: re-organize chardev creation Alexandru Ardelean
2020-04-10 11:56 ` Alexandru Ardelean [this message]
2020-04-10 11:56 ` [PATCH 2/5] iio: buffer: add back-ref from iio_buffer to iio_dev Alexandru Ardelean
2020-04-10 11:56 ` [PATCH 3/5] iio: buffer: move iio buffer chrdev in industrialio-buffer.c Alexandru Ardelean
2020-04-10 11:56 ` [PATCH 4/5] iio: buffer: move sysfs alloc/free " Alexandru Ardelean
2020-04-10 11:56 ` [PATCH 5/5] iio: event: move event-only chardev in industrialio-event.c 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=20200410115655.79217-2-alexandru.ardelean@analog.com \
--to=alexandru.ardelean@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).